Creating SVG images with Liberty BASIC

SVG images are VECTOR images, so they can be displayed at increasing resolution without becoming pixellated & blocky. The file specification is an XML text file, & can allow easy generation of custom shapes from LB.

A bitmap image, and what it looks like if enlarged.

A SVG image, and what it looks like if enlarged.

Note that by creating it with smaller steps I can improve the size of the straight-line steps. It would be neater to make it a Bezier curve...

My particular interest was to provide svg files to use in InkScape, which is free software with a custom output to control an eggbot. Cartesian ( x/y) & polar ( r/theta) graphs are the most useful. Anything you can draw to a graphic window in lb AT A FIXED RESOLUTION can be directed to a SVG file as shown below. You'll note I practice on lampbulbs rather than eggs- you can wipe them clean. Brian Schmalz's fantastic 'eibot' driver board is connected by USB and soes the hard part. My motors and gears are all cannibalised from hard drives, CD players, etc. Only downside is that complicated patterns may take hours to draw....

Internet Explorer can't display SVG files except in versions 9 & 10, so not on XP. I use FireFox anyway, which has been svg enabled for years- and is free.

Hardware & Software

My eggbot uses two geared 48-step motors, with reduction gears ( so I didn't have to buy 200 or 400-steppers) and are driven with 16 micro-steps per single full step. The drawing area is about 1920 steps round the egg's equator, and about +/- 400 towards each egg-pole'.


radius =250
pi     =  3.14159265

open "outfile.svg"  for output as #os

#os "<svg xmlns="; chr$( 34); ""; chr$( 34); _
    " width=";     chr$( 34); "1000px";                     chr$( 34); _
    " height=";    chr$( 34); "800px";                      chr$( 34); _
    " version=";   chr$( 34); "1.1";                        chr$( 34); _

#os "<polyline points="; chr$( 34);

for i =0 to 10 *2 *pi step 0.01  '   10 rotations

    r =20 +radius *( 1 +sin( 12.13 *i)) /2

    x2   =300 +int( r *sin( i))
    x2$  =right$( "000" +str$( x2), 3)

    y2   =300 +int( r *cos( i))
    y2$  =right$( "000" +str$( y2), 3)

    #os x2$; ",";  y2$; " ";
    x1$  =x2$
    y1$  =y2$

    radius =radius *0.9999
next i

#os chr$( 34); " style="; chr$( 34); " fill:none; stroke:black; stroke-width:1"; chr$( 34); "/>"

#os "</svg>"

close #os

address$ ="outfile.svg"
run "C:\Program Files\Mozilla Firefox\firefox.exe "; address$
'   use run "explorer.exe" if you have IE9 or 10- so not in XP!!

I can be contacted on mr dot john dot f at