PAINT - QB64 Wiki

PAINT

From QB64 Wiki

Jump to: navigation, search

The PAINT statement is used to color enclosed graphic objects with a designated fill color up to a border COLOR.


Color Syntax:

PAINT [STEP] (column%, row%), fillcolor[, bordercolor%]

Tiling Syntax:

PAINT [STEP] (column%, row%), background$[, bordercolor%]


Parameters:

  • Can use the STEP keyword for relative coordinate placements. STEP(0, 0) can be used after CIRCLE to fill it with color.
  • Graphic column and row INTEGER pixel coordinates should be inside of a fully enclosed border.
  • The fillcolor can be either a numerical or a string value:
  • INTEGER or LONG 32 bit Fillcolor is the color to paint the inside of an object. Colors limited to SCREEN mode used.
  • A STRING paint argument has PAINT do "tiling," a process that paints a pattern rather than a solid color.
  • Optional INTEGER or LONG 32 bit border color is the color of the enclosed shape's border when different from the fill color.
  • Optional background ASCII character sets the tiling style. Omitted background Default is CHR$(0).
PAINT(x, y), CHR$(arg1) + CHR$(arg2)... + CHR$(argn)
Where the CHR$ arguments are numerical values between 0 and 255, represented in binary form across the x column axis.


Usage:

  • The enclosed border color must be one color value only. The object border should be fully enclosed!
  • PAINT coordinates MUST be inside of a closed shape to be colored. Paint will not do anything when placed on the border color.
  • If the border color does not enclose the area, PAINT may flood the screen or go beyond the border area.
  • If the shape is not totally enclosed, every color except the border color may be painted over.
  • DRAW shapes can be filled using the string "P fillcolor, bordercolor". Use a "B" blind move to offset from shape's border.


Example 1: Painting a CIRCLE immediately after it is drawn using STEP(0, 0) to paint from the circle's center point.

SCREEN 12 x = 200: y = 200 CIRCLE (x, y), 100, 10 PAINT STEP(0, 0), 2, 10

Results: A circle located at x and y with a bright green border filled in dark green. The last coordinate used was the circle's center point and PAINT used it also with the STEP relative coordinates being zero.


Example 2: Routine to check a DRAW string to make sure that the drawn shape is fully enclosed so that a PAINT does not bleed.

SCREEN 12 drw$ = "C15S20R9D4R6U3R3D3R7U5H3U2R9D3G2D6F1D3F5L10D1G1L4H2L7G2L3H2L3U8L2U5R1BF4" FOR i = 1 TO LEN(drw$) tmp$ = UCASE$(MID$(drw$, i, 1)) check = 1 SELECT CASE tmp$ CASE "U": ver = -1: hor = 0 CASE "D": ver = 1: hor = 0 CASE "E": ver = -1: hor = 1 CASE "F": ver = 1: hor = 1 CASE "G": ver = 1: hor = -1 CASE "H": ver = -1: hor = -1 CASE "L": ver = 0: hor = -1 CASE "R": ver = 0: hor = 1 CASE ELSE: check = 0 END SELECT IF check THEN snum$ = "" FOR j = i + 1 TO i + 4 'set for up to 4 digits and spaces IF j > LEN(drw$) THEN EXIT FOR n$ = MID$(drw$, j, 1) num = ASC(n$) IF (num > 47 AND num < 58) OR num = 32 THEN snum$ = snum$ + n$ ELSE: EXIT FOR END IF NEXT vertical = vertical + (ver * VAL(snum$)) horizont = horizont + (hor * VAL(snum$)) END IF PRINT tmp$, horizont, vertical 'SLEEP NEXT PSET (300, 300): DRAW drw$

Explanation: If the DRAW string is enclosed, the end values should each be 0! In the example, the proper result should be 4, 4 as there is a BF4 offset for PAINT which cannot be on a border. The result is 4, 5 because the shape is not completely enclosed.


Example 3: Tiling using PAINT to create a red brick pattern inside a yellow border:

DIM Row$(1 TO 8) SCREEN 12 'make red-brick wall Row$(1) = CHR$(&H0) + CHR$(&H0) + CHR$(&HFE) + CHR$(&HFE) Row$(2) = Row$(1) Row$(3) = Row$(1) Row$(4) = CHR$(&H0) + CHR$(&H0) + CHR$(&H0) + CHR$(&H0) Row$(5) = CHR$(&H0) + CHR$(&H0) + CHR$(&HEF) + CHR$(&HEF) Row$(6) = Row$(5) Row$(7) = Row$(5) Row$(8) = Row$(4) Tile$ = Row$(1) + Row$(2) + Row$(3) + Row$(4) + Row$(5) + Row$(6) + Row$(7) + Row$(8) LINE (59, 124)-(581, 336), 14, B 'yellow box border to paint inside PAINT (320, 240), Tile$, 14 'paints brick tiles within yellow border

Tiling currently does not work in QB64!


See also:



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
Views
  • Page
  • Discussion
  • View source
  • History
Personal tools
  • Log in
Toolbox
  • What links here
  • Related changes
  • Special pages
  • Printable version