| Home CBM ASCII-X BASIC Disk Commands Enter RUN mode Program Format Secret Variables Variable Format Expressions Keywords (divide) (equal) (less) (minus) (more) (multiply) (plus) (power) Abs And Append Asc Atn Auto Backup Bank Begin Bend Bload Boot Box Bsave Bump Catalog Char Chr Circle Close Clr Cmd Collect Collision Color Concat Cont Copy Cos Data Dclear Dclose Dec Def Delete Dim Directory Dispose Dload Do Dopen Draw Ds Ds string Dsave Dverify El Else End Envelope Er Err Exit Exp Fast Fetch Filter Fn For Fre Get Get num Getkey Go Gosub Goto Graphic Gshape Header Help Hex If Input Input num Instr Int Joy Key Left Len Let List Load Locate Log Loop Mid Monitor Movspr New Next Not Off On Open Or Paint Peek Pen Pi Play Pointer Poke Pos Pot Print num Pudef Quit Rclr Rdot Read Record Rem Rename Renumber Restore Resume Return Rgr Right Rlum Rnd Rreg Rspcolor Rsppos Rsprite Run Rwindow Save Scale Scnclr Scratch Sgn Sin Sleep Slow Sound Spc Sprcolor Sprdef Sprite Sprsav Sqr Sshape St Stash Step Stop Str Swap Sys Tab Tan Tempo Then Ti Ti string To Trap Troff Tron Until Using Usr Val Verify Vol Wait While Width Window Xor Syntax Tokens C128 D64plus Disk Escape Codes Hardware PCxface PETSCII Pet2asc Futurama IBM PC-AT Contact Games Glossary Hall of fame Hall of shame Miscellaneous Privacy policy Programming Twisty puzzles |
PAINT [ colorSource ] [ , { [ + | - ] xVal [ , [ + | - ] yVal ] | distance ; angle } [ , stopMode ] ] ...
*Due to a bug in the original C128 ROMs (start-up message says (c)1985), only positive/unsigned values of 0 to 65535 may be used.
Fill an enclosed region of the bitmap.
All parameters are optional. Without any parameters, PAINT begins at the pixel cursor (the last pixel updated by the previous bitmap command). Following the optional colorSource is the optional (but recommended) starting point for PAINT. If the point is not specified, it defaults to the pixel cursor. A specified coordinate will be effected by SCALE if it is active. The resulting value may be off-screen (in which case PAINT does nothing), but is acceptable as long as it is "legal" as shown above. A point specified as a polar coordinate will always be relative to the pixel cursor. A point specified in rectangular form will normally be an absolute coordinate (independ of the pixel cursor), but using a + or - in front of the xVal or yVal will make that ordinate relative to the pixel cursor. The x and y ordinates are processed independantly; either, neither, or both ordinates of the rectangular coordinate may be in relative form (whichever use a leading + or -). Note these must be literal + and - characters in the command/statement. So if you have a variable X with a negative value (like -10) then it will be used an absolute coordinate unless you preced it with + or - sign. You normally wouldn't put a - sign unless you want to reverse the direction of the variable. So, for this example, use +X for a relative ordinate. As opposed to a variable, if you want to enter a literal negative value (for an absolute ordinate), you must enclose it in parentheses; otherwise it would interpreted as a relative ordinate. Sorry if that is confusing! If so, you need to play with relative and absolute coordinates to see clearly what I mean. PAINT will fill an area of the bitmap until it matches the "stopping color source". By default, this is the same as colorSource. If you specfiy a value of 1 for stopMode, instead of the default of 0, then PAINT will stop at any non-background color instead. This alternate stopMode only makes sense for multi-color mode (because there is only 1 non-background color for high-resolution bitmap mode). If the initial point already matches the "stopping color source" then PAINT does nothing. Otherwise it calls the BASIC garbage collection routine to discard all temporary strings before it begins. Once it starts, it follows this (not quite accurate) algorithm:
The above just gives you an idea how it works. The actual algorithm is a bit more sophisticated; for example it doesn't test the direction it just came from. It also doesn't push a coordinate onto the "paint stack" until it finds a "stopping color source" in the direction it is heading. Nonetheless, because of multiple tests at each point, it can take quite a while to paint a large area. Alternatives include the use of CHAR, GSHAPE, and BOX (with fill option), but these are only practical if you want to fill a (rotated) rectangular area. It also important to be sure the starting point is really inside an enclosed area. If there are any gaps in the boundry, PAINT will "leak out" and produce undesirable results, perhaps even filling the whole screen! Any floating-point numbers will first be converted to integers (see INT). If any value is out-of-range (see above) an ILLEGAL QUANTITY ERROR is generated. If no bitmap has been setup (see GRAPHIC), a NO GRAPHICS AREA is generated. Example of optional colorSource and optional point:
Example of relative rectangular and polar coordinate:
Example of stopModes:
© H2Obsession, 2014 |