BASIC Graphic functions - Bricksnspace/MegaBASIC GitHub Wiki
Graphic functions are available only on graphic display. If you use serial console or text-only display (like 1602 modules), graphic functions are parsed and parameter are consumed, but no operations are executed on display.
Coordinate 0,0 are top left on screen, x grows from left to right, y grows from top to bottom.
Index
BGR r,g,b
Change current background color for text and graphic. Parameters are red, green and blue component for new color, from 0 to 255. If display is monochrome, r=g=b=0 is black (pixel is off), if any component is not zero, it is used as white (pixel is on).
30 COLOR 0,0,0
40 REM black
50 BGR 255,255,0
60 REM yellow
50 PRINT "Hello!"
Print "Hello!" in black on yellow background.
CIRCLE x,y,r
Draws a circle centered in x,y with radius r in pixel, using current color.
30 COLOR 0,255,255
40 REM cyan
50 CIRCLE 100,100,30
Draws a cyan circle.
COLOR r,g,b
Change current color for text and graphic functions. Parameters are red, green and blue component for new color, from 0 to 255.
If display is monochrome, r=g=b=0 is black (pixel is off), if any component is not zero, it is used as white (pixel is on).
30 COLOR 0,0,0
40 REM black
50 PLOT 10,10
60 COLOR 1,0,0
70 REM color is white for monochrome diplay
80 PLOT 11,10
LINE x,y,x1,y1
Draw a line on screen from point x,y to point x1,y1 using current color.
20 COLOR 255,0,0
30 LINE 0,0,100,0
40 LINE 100,0,100,50
50 LINE 100,50,0,50
60 LINE 0,50,0,0
Draws a red rectangle.
PLOT x,y
Draw a single pixel on screen using current color.
10 COLOR 0,255,0
20 FOR x=0 TO 180
30 y = COS(x) * 30 + 30
50 PLOT x,y
60 NEXT x
Draw cosine function in green.
RECT x,y,w,h
Draw a rectangle. Top left corner is at x,y
coordinates, rectangle is w
pixel wide and h
pixel high.
20 COLOR 255,0,0
30 RECT 10,10,100,50
Draw a red rectangle.