Graphics Commands |
Top Previous Next |
The 2D command set features many built in high speed graphic drawing functions specifically designed to take the most advantage of DirectX. These primitive drawing commands can be used along side the built in Emergence BASIC ones. When using an 8 bit screen with any of the drawing commands substitute a palette number for the RGB color in the examples. Line drawing Drawing a solid line is done with the DRAWLINE command. The line is always one pixel wide and can be any color. The line can be drawn on the back buffer (default), the front buffer or the sprite buffer set with the the SpriteToBuffer command. Examples: DRAWLINE 0, 0, 100, 200, RGB(255,0,255) A line can be drawn alpha blended into the background using DRAWALPHALINE. The line is always one pixel wide and can be any color. The line can be drawn on either the back buffer (default) or the front buffer. Examples: DRAWALPHALINE 0, 0, 100, 200, RGB(255,0,255), 128 An anti-aliased line can be drawn with the DRAWAALINE command. Anti-aliasing uses a software algorithm to remove the jagged edges normally seen on lines drawn at an angle. DRAWAALINE 0, 0, 100, 200, RGB(255,0,255)
Rectangles A rectangle outline is drawn with the DRAWRECT command. The interior of the rectangle is transparent and will show anything underneath. DRAWRECT 0, 0, 180, 200, RGB(255,255,255) Filled rectangles are drawn with the DRAWFILLEDRECT command. DRAWFILLEDRECT 10,10, 100, 100, RGB(100,100,100)
Writing pixels Writing a pixel in any color can be done with the WRITEPIXEL command. WRITEPIXEL 0,100, RGB(77,255,255) An alpha blended pixel can be written to a buffer with the WRITEALPHAPIXEL command WRITEALPHAPIXEL 0, 230, RGB(20,200,20), 110 For high speed effects and advanced uses the WRITEPIXELFAST command uses hand optimized machine language to write the pixel to the buffer in the fastest time possible. WRITEPIXELFAST requires locking of the buffer ahead of time before use. LOCKBUFFER You must be very careful not to write outside of the screen dimensions. There are no boundary checks done with WRITEPIXELFAST. Writing outside of the buffer will result in an access violation.
Drawing text Text can be drawn to a buffer using the WRITETEXT command. WRITETEXT is significantly faster than using PRINT. WRITETEXT 0, 0, "Press any key to close" The font, color and drawing mode of the text is set using the commands from Emergence BASIC which will be covered next.
Using Emergence BASIC's drawing commands. All of the drawing commands and functions from the Emergence BASIC core command set can be used with your 2D screens. The built in variables FrontBuffer, BackBuffer and SpriteBuffer substitute for WINDOW variables in any of the drawing commands. For example: 'Change the text color, mode and font of the back buffer When using EBASIC's drawing commands with 8 bit screens the PALETTEINDEX function must be used to map a screens palette to the RGB color needed for the command. Example: SETPALETTECOLOR 3,RGB(0,0,255)
|