I can understand your desire to remove unnecessary parts but I think you over did it.
Code: Select all
Procedure BoxXY(x1, y1, x2, y2, Colour = #PB_Default)
If x2 < x1 : Swap x1, x2 : EndIf
If y2 < y1 : Swap y1, y2 : EndIf
Box(x1, y1, x2 - x1 + 1, y2 - y1 + 1, Colour)
EndProcedure
Procedure BoxXY2(x1, y1, x2, y2, Colour = #PB_Default)
If x2 < x1 : Swap x1, x2 : EndIf
If y2 < y1 : Swap y1, y2 : EndIf
If Colour = #PB_Default
Box(x1, y1, x2 - x1 + 1, y2 - y1 + 1)
Else
Box(x1, y1, x2 - x1 + 1, y2 - y1 + 1, Colour)
EndIf
EndProcedure
#Size = 50
OpenWindow(0, 0, 0, 215, 180,"Example Colors",#PB_Window_SystemMenu)
CreateImage(0, #Size * 3, #Size * 3, 32)
StartDrawing(ImageOutput(0))
;these boxes should use the default FrontColor()
BoxXY(0, 0, #Size - 2, #Size - 2)
Box(#Size, 0, #Size - 1, #Size - 1)
BoxXY2(#Size * 2, 0, #Size * 3 - 2, #Size - 2)
;these boxes should use the specified color
BoxXY(0, #Size, #Size - 2, #Size * 2 - 2, RGB(0, 255, 0))
Box(#Size, #Size, #Size - 1, #Size - 1, RGB(0, 255, 0))
BoxXY2(#Size * 2, #Size, #Size * 3 - 2, #Size * 2 - 2, RGB(0, 255, 0))
;these boxes should use the specified FrontColor()
FrontColor(RGB(255, 0, 0))
BoxXY(0, #Size * 2, #Size - 2, #Size * 3 - 2) ; <=== this one doesn't
Box(#Size, #Size * 2, #Size - 1, #Size - 1)
BoxXY2(#Size * 2, #Size * 2, #Size * 3 - 2, #Size * 3 - 2)
StopDrawing()
ImageGadget(0, 0, 20, 0, 0, ImageID(0))
TextGadget(1, 0 , 0 , #Size, 20, "BoxXY()" , #PB_Text_Center)
TextGadget(2, #Size , 0 , #Size, 20, "Box()" , #PB_Text_Center)
TextGadget(3, #Size * 2 , 0 , #Size, 20, "BoxXY2()", #PB_Text_Center)
TextGadget(4, 10 + #Size * 3, 30 , #Size, 40, "Default FrontColor")
TextGadget(5, 10 + #Size * 3, 30 + #Size , #Size, 40, "Green")
TextGadget(6, 10 + #Size * 3, 30 + #Size * 2, #Size, 40, "Red FrontColor")
Repeat: Until WaitWindowEvent() = #PB_Event_CloseWindow
Only the BoxXY2() uses the FrontColor() when the color isn't specified. I would presume this would be the desired way.