2D_FLOOD

2D_FLOOD X,Y,R,G,B

PAINTS A SURFACE FROM A POINT

  • Type: Command
  • Parameters: 5
  • Group: Drawing

ACTION

The command 2D_FLOOD X,Y,R,G,B fills a surface from the point (X,Y), replacing the color found at point (X,Y) by the color (R,G,B).

The filling is determined by moving outward from the point (X,Y): if the color found at the point (X,Y) is encountered, it is replaced by the color (R,G,B) but when another color is encountered, the flood stops.

Remark 1: the filling mode must be the solid one (2D_FILL_SOLID).

Remark 2: the filling color is the color resulting of the addition of the 3 specified primary components: red (R), green (G) and blue (B).

The intensity of each primary component can vary from 0 to 255. (0 = no color, 255 = full intensity)

When all the 3 primary components are 0, the result color is black (no color), when all the 3 primary components are 255, the result color is white (addition of the 3 primary colors at maximum intensity).

Recall:

- yellow color (red + green) when B = 0

- gray color when R=G=B

- violet color (red + blue) when G = 0

- black color when R=0, G=0, B=0

- white color when R=255, G=255, B=255

SYNTAX: 2D_FLOOD X,Y,R,G,B

  • X = X-component value (integer or real) of the point.
  • Y = Y-component value (integer or real) of the point.
  • R = Red component value (integer or real) of the result color.
  • G = Green component value (integer or real) of the result color.
  • B = Blue component value (integer or real) of the result color.

USE

  • The command 2D_FLOOD is used to fill a colored surface with another color.

ERROR

  • If X or Y is not a correct expression.
  • If R or G or B is less than 0 or greater than 255.
  • If R or G or B is not a correct expression.

EXAMPLE

dim x0,y0,r,Px,Py,Px2,Py2,j%,n%,Pi,a

x0=100:Y0=100:rem center coordinates

r=100:rem radius

n%=10:rem side number

a=10:rem starting angle

Pi = 3.1415926535898

Px = r * Cos(a) + x0

Py = r * Sin(a) + y0

2D_poly_from Px,Py

For j% = 1 To n%

Px2 = r*Cos(a + 2*Pi*j%/n%) + x0

Py2 = r*Sin(a + 2*Pi*j%/n%) + y0

2D_poly_to Px2, Py2

Px = Px2

Py = Py2

next j%

2d_flood x0,y0,100,50,200

SEE ALSO

-