Graphics

fractal_fern.bas


CLS
iii=0
RANDOMIZE TIMER
'x = 60
'y = 60
WHILE iii<100000
r = RND
IF (r <= .01) THEN
a = 0: b = 0: c = 0: d = .16: e = 0: f = 0
ELSEIF r > .01 AND r <= .86 THEN
a = .85: b = .04: c = -.04: d = .85: e = 0: f = 1.6
ELSEIF r > .86 AND r <= .93 THEN
a = .2: b = -.26: c = .23: d = .22: e = 0: f = 1.6
ELSE
a = -.15: b = .28: c = .26: d = .24: e = 0: f = .44
END IF
newx = (a * x) + (b * y) + e
newy = (c * x) + (d * y) + f
x = newx
y = newy
PSET x*50+150, y*50, 2

lakeshore_demo.bas


' A small water waving/flickering program
' For SB(fltk) 2 Jan 2009 , by Keijo Koskinen
' You can download lakeshore1.jpg from:
' http://users.csolve.net/~keiko/smallbasic/lakeshore1.jpg
' When lakeshore1.jpg appears to screen,
' ..right clic it and choose save as
' ..to your bas_home directory

' *** load image ***
'img= env("C:\sb_fltk_97\FLTK_0.9.7\Bas-Home")+"lakeshore1.jpg"
' or
img= env("Bas-Home")+"lakeshore1.jpg"
if (!exist(img)) then
?

sphere.bas


' A small 3D globe rotation program
' Converted to SB(fltk) 23,may 2006, from an old basic code
' by Keijo koskinen
' You can download sphere.gif from:
' http://users.csolve.net/~keiko/smallbasic/sphere.gif
' When sphere.gif appears to screen, ..right clic it and shoose save as ..to your bas_home directory

img= env("Bas_Home")+"sphere.gif"
if
(!exist(img)) then
? "Sphere.gif does not exist "
? "then we are rolling this text"
?

ripples.bas

Submitted by user: decomputer on 05/01/2008 - 18:35


'ripples.bas-run on palm only, will crash windows 98
' 21/08/2006
cls
pen on
while inkey$<>"."
randomize
circle pen(1), pen(2), fix(rnd*60)
sound (pen(1)*7), (pen(2)*0.5)
circle pen(1), pen(2), fix(rnd*60) color 15
sound (pen(1)*7), (pen(2)*0.5)
wend
pen off

end

IMAGE

Graphics command IMAGE

10
20  IMAGE #handle, index, x, y [,sx,sy [,w,h]]
30
Display a graphical image.

See examples

TXTH

Graphics function TXTH

10
20  TXTH (s)
30
Returns the text height of string s in pixels. See TEXTHEIGHT.

See examples

Graphics

SmallBASIC’s graphics commands use integers (2D algebra commands use reals).

Colors

  • Monochrome 0 = black, 15 = white
  • 2bit (4 colors) 0 = black, 15 = white, 1-6, 8 = dark-gray, 7, 9-14 = light-gray
  • 4bit (16 colors) 16 Standard VGA colors, 16 colors of gray (on PalmOS)
  • 8bit (256 paletted colors) 16 Standard VGA colors. The remaining colors are ignored.
  • 15bit (32K colors), 16bit (64K colors) and 24bit (1.7M colors) Color 0..15 is the standard VGA colors, full 24-bit RGB colors can be passed by using negative number.

Points

IMAGEW

Graphics function IMAGEW

10
20  IMAGEW #handle, index
30
Returns the width of the image in pixels.

See examples

PAINT

Graphics command PAINT

10
20  PAINT [STEP] x, y [,fill-color [,border-color]]
30
Fills an enclosed area on the graphics screen with a specific color. x,y = Screen coordinate (column, row) within the area that is to be filled.

See examples

If border-color is specified then PAINT will fill outwards until is meets the specified border-color – (fill-until, color!=point(x,y))

If the border-color is NOT specified then PAINT will fill the area with the same color as the pixel at x,y – (fill-while, color=point(x,y))

XPOS

Graphics function XPOS

10
20  XPOS
30
Returns the current X position of the cursor in "characters".

See examples

Syndicate content