| 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 |
GSHAPE image [ , { [ + | - ] xVal [ , [ + | - ] yVal ] | distance ; angle } [ , renderMode ] ]
*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.
Render a saved image on the bitmap screen.
The image is typically generated by either SSHAPE or SPRSAV, and is thus typically a string variable. However BASIC will accept any string. If seems to do nothing if the string is less than 5 characters. As you might expect, if the string wasn't generated properly, you get a bunch of garbage on the screen! All I can say is the string consists of raw pixel data, no color data, and is terminated by a "footer" that specifies the width and height of the image. If image is not a string, a TYPE MISMATCH ERROR is generated. Following the image is an optional point of the bitmap to begin rendering the image (starting at the top-left pixel). The default point is the pixel cursor. A specified point will be effected by SCALE if it is active. The resulting value may be off-screen, 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. The image may be drawn either partially or completely off-screen. Going off-screen does not generate an error. Portions of the image that are rendered on-screen will done according to the renderMode which defaults to zero. The zero mode simply stores the pixels saved in the string back to bitmap; this completely over-writes any pixels currently on the bitmap. A renderMode of 1 does essentially the same thing, but each pixel read from the image is inverted before being rendered on the bitmap. Note the bit-values of the pixel are inverted; not the actual color of the pixel. The renderModes 2 to 4 operate differently (than 0 and 1). These modes combine the bits of the image's pixel with the current bitmap's pixel by using a bit-wise boolean operator: OR for mode 2, AND for mode 3, and XOR for 4. Using GSHAPE twice, both times with the XOR mode and at the same point, you can both draw and erase the same image on the bitmap, so you could use it for slow animation. The OR mode will act similar to a transparency; anywhere the image has a background color, the original bitmap's pixels will show through. The AND mode is kind of like an inverted transparency; anywhere the image has a non-background color, the original bitmap's pixels will show through (and image pixels that are background will output render the background color). Note in order to specify a renderMode, you must specify a point (otherwise the point is optional). To use the default point anyway, just specify a relative offset of +0 for both xVal and yVal (see example). Unfortunately there is no way to clip or scale the image or reverse the horizontal or vertical direction (i.e., "no mirror X nor mirror Y"). Note if SCALE is in effect, it only affects the (specified, non-default) starting point, but not the size of the rendered image. Perhaps worse, the image only contains bitmap pixels. The colors those pixels had when the image was saved are nowhere to be found. When using GSHAPE, the values currently assigned to the various colorSources are used instead (see COLOR). Any floating-point numbers will first be converted to integers (see INT). If any numeric 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. I believe GSHAPE is short for "Graph Shape", although I have seen no offical definition. Example of optional point:
Example of relative rectangular and polar coordinate:
Example of renderModes:
© H2Obsession, 2014 |