Please keep this in mind when using the PAINT statement:
Although painting will not go beyond a pixel coordinate with the specified area edge color, painting will also not go beyond a screen coordinate with the specified paint color.
It is easier to explain and understand the behaviour via some code.
The goal is to create two overlapping circles, and to fill the right-most circle with the same color as the edge color of the left-most circle. So we want code that will create:
The following three snippets of code demonstrate the behaviour of PAINT, as implemented in BASIC Anywhere Machine:
' the center of the second circle
' is exactly on the right-side edge of the first circle
CIRCLE( 20, 20 ), 20, 63
CIRCLE( 40, 20 ), 20, 62
CIRCLE( 40, 20 ), 20, 62
PAINT( 40, 20 ), 63, 62 ' paint on the edge
CIRCLE( 82, 20 ), 20, 63
CIRCLE( 102, 20 ), 20, 62
PAINT( 101, 20 ), 63, 62 'paint just left of the edge
CIRCLE( 144, 20 ), 20, 63
CIRCLE( 164, 20 ), 20, 62
PAINT( 165, 20 ), 63, 62 'paint just right of the edge
To paint everything within a bounded area, you should first "clear" the area (including the area's edges) via a reserved color (one color from whatever palette applicable to the screen mode you are using) that is only ever used as a temporary color for a process of painting)
After you've cleared the area, go ahead and draw the shape with the intended color, then paint the shape with the intended color. We get the results we are looking for with the following code:
CIRCLE( 20, 62 ), 20, 63
' clean/prepare the area for the second circle
CIRCLE( 40, 62 ), 20, 61
PAINT( 39, 62 ), 61, 61
' now, create the second circle
CIRCLE( 40, 62 ), 20, 62
PAINT( 39, 62 ), 63, 62
CIRCLE( 82, 62 ), 20, 63
' clean/prepare the area for the second circle
CIRCLE( 102, 62 ), 20, 61
PAINT( 101, 62 ), 61, 61
' now, create the second circle
CIRCLE( 102, 62 ), 20, 62
PAINT( 101, 62 ), 63, 62
CIRCLE( 144, 62 ), 20, 63
' clean/prepare the area for the second circle
CIRCLE( 164, 62 ), 20, 61
PAINT( 165, 62 ), 61, 61
' now, create the second circle
CIRCLE( 164, 62 ), 20, 62
PAINT( 165, 62 ), 63, 62
All three examples give the exact same result. Here is the result after each CIRCLE and each PAINT statement:
No comments:
Post a Comment