-- an empty page, A4 in landscape; a point {x, y} is a fraction of the width and the height of the page pl = Graphics.New() -- a line through three points, 0.004 wide, blue pl.Add({ {0.05,0.55}, {0.15,0.9}, {0.25,0.55} }, {{"Line Width",0.004}, {"Color",0x0000C0}}) -- a closed triangle, filled with a half transparent red pl.Add({ {0.3,0.55}, {0.4,0.9}, {0.5,0.55} }, {{"Close",true}, {"Fill Color",0x80FF0000}}) -- a curve of two pieces; each point is {xL,yL, x,y, xR,yR}, with the control points before and after it pl.Add({ {0.55,0.55, 0.55,0.55, 0.55,0.9}, {0.65,0.9, 0.75,0.9, 0.85,0.9}, {0.95,0.55, 0.95,0.55, 0.95,0.55} }, {{"Line Width",0.004}, {"Color",0x00A000}}) -- a circle, and a quarter of a disc from 0 to 90 degrees, closed through its centre and filled pl.Add({"Arc", {0.15,0.25}, 0.1}) pl.Add({"Arc", {0.3,0.2}, 0.1, 0, Pi/2}, {{"Close",true}, {"Fill Color",0xFF8000}}) -- a bitmap of 3 by 2 pixels, the first row at the top, drawn with sharp pixels pl.Add({"BitMap", {0.45,0.1}, {0.6,0.35}, { {{255,0,0}, {0,160,0}, {0,0,255}}, {0, 128, 255} }}, {{"Pixelated",true}}) -- texts: centred, and turned by 90 degrees pl.Add("Graphics.Add", 0.5, 0.45, {{"Size",0.06}, {"Alignment","c"}}) pl.Add("turned", 0.68, 0.1, {{"Angle",Pi/2}, {"Color",0x0000C0}}) -- a layer: a small page of its own, 60 mm by 50 mm with its lower left corner at (220 mm, 15 mm) Inset = Graphics.New({{"Canvas.Size.X",60}, {"Canvas.Size.Y",50}, {"Canvas.Origin.X",220}, {"Canvas.Origin.Y",15}}) Inset.Add({ {0,0}, {1,0}, {1,1}, {0,1} }, {{"Close",true}, {"Fill Color",0xE0E0E0}}) pl.Add(Inset) -- the option Layer adds to layer 1, so (0.5, 0.5) is the middle of the inset pl.Add("inset", 0.5, 0.5, {{"Layer",1}, {"Alignment","c"}, {"Size",0.15}}) print("lines", pl.NLine, "curves", pl.NCurve, "arcs", pl.NArc, "texts", pl.NText, "bitmaps", pl.NBitMap, "layers", pl.NLayer) -- the function form returns a new Graphics object and leaves pl as it is pl2 = Graphics.Add(pl, "a third text", 0.05, 0.02) print("texts", pl.NText, pl2.NText) file = io.open("Add.svg", "w") file:write(Graphics.ToSVG(pl, {{"RelativeSize",true}})) file:close()