···7171<rect y="10" x="10" stroke-width="1" height="10" width="10" rx="0" ry="0" />
7272```
73737474+for several elements, you can use the normal usage and replace the `draw()` method by the `innerdraw()`
7575+7676+```lua
7777+mon_dessin = svg:create()
7878+mon_dessin:addRect()
7979+mon_dessin:addCircle()
8080+mon_dessin:innerdraw()
8181+```
8282+8383+result for `print(mon_dessin:innerdraw())` :
8484+8585+```html
8686+<rect y="10" x="10" stroke-width="1" height="10" width="10" rx="0" ry="0" />
8787+<circle stroke-width="1" r="25" cy="30" cx="30" transform="" fill="transparent" stroke="#000000" />
8888+```
8989+7490### testing
75917692can be tested [here](https://www.jdoodle.com/execute-lua-online)
···180196 - element: svg.Element => see farther for element list
181197182198**svg:draw()** *return the svg formated string*
199199+200200+**svg:draw()** *return the svg formated string for elements added to the drawing, without the outer `<svg>`*
183201184202### Elements for svg:add(element) or elements rendering only
185203
···11-svg={}svg.__index=svg;function svg:create(a,b,c,d)local e={}setmetatable(e,svg)e.width=a or 100;e.height=height or 100;e.stroke=c or"#000000"e.fill=d or"transparent"e.elements={}e.Element={}e.Element.__index=svg.Element;function e.Element:create(f,g,h)local i={}setmetatable(i,e.Element)i.name=f;i.strElement="<"..f.." "for j,k in pairs(g)do i[j]=k;i.strElement=i.strElement..j.."=\""..k.."\" "end;if h~=nil then i.strElement=i.strElement..">"..h.."</"..f..">"else i.strElement=i.strElement.."/>"end;return i end;return e end;function svg:add(l)table.insert(self.elements,l)end;function svg:draw()local m="<svg width=\""..self.width.."\" height=\""..self.height.."\" fill=\""..self.fill.."\" stroke=\""..self.stroke.."\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">"for n,o in pairs(self.elements)do m=m..o.strElement end;m=m.."</svg>"return m end;function svg:Text(p,q,s,t,u)return self.Element:create("text",{x=q or 10,y=s or 50,style=t or"font-family: Verdana; font-size: 10; stroke: "..self.stroke.."; fill: "..self.fill..";",transform=u or""},p)end;function svg:addText(p,q,s,t,u)self:add(self:Text(p,q,s,t,u))end;function svg:Rect(q,s,a,height,c,v,d,w,x,u)return self.Element:create("rect",{x=q or 10,y=s or 10,width=a or 10,height=height or 10,stroke=c or self.stroke,fill=d or self.fill,["stroke-width"]=v or 1,rx=w or 0,ry=x or 0,transform=u or""})end;function svg:addRect(q,s,a,height,c,v,d,w,x,u)self:add(self:Rect(q,s,a,height,c,v,d,w,x,u))end;function svg:Circle(r,cx,cy,c,v,d,u)return self.Element:create("circle",{r=r or 25,cx=cx or 30,cy=cy or 30,stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill,transform=u or""})end;function svg:addCircle(r,cx,cy,c,v,d,u)self:add(self:Circle(r,cx,cy,c,v,d,u))end;function svg:Ellipse(cx,cy,w,x,c,v,d,u)return self.Element:create("ellipse",{rx=r or 25,ry=r or 15,cx=cx or 30,cy=cy or 30,stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill,transform=u or""})end;function svg:addEllipse(cx,cy,w,x,c,v,d,u)self:add(self:Ellipse(cx,cy,w,x,c,v,d,u))end;function svg:Line(y,z,A,B,c,v,d)return self.Element:create("line",{x1=r or 15,y1=r or 15,x2=cx or 50,y2=cy or 45,stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill})end;function svg:addLine(y,z,A,B,c,v,d)self:add(self:Line(y,z,A,B,c,v,d))end;function svg:Polyline(C,c,v,d,u)return self.Element:create("polyline",{points=C or"10,10 50,50 50,25 75,25",stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill,transform=u or""})end;function svg:addPolyline(C,c,v,d,u)self:add(self:Polyline(C,c,v,d,u))end;function svg:Path(D,c,v,d,u)return self.Element:create("path",{d=D or"M50 0 L75 100 L25 100 Z",stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill,transform=u or""})end;function svg:addPath(D,c,v,d,u)self:add(self:Path(D,c,v,d,u))end
11+svg={}svg.__index=svg;function svg:create(a,b,c,d)local e={}setmetatable(e,svg)e.width=a or 100;e.height=height or 100;e.stroke=c or"#000000"e.fill=d or"transparent"e.elements={}e.Element={}e.Element.__index=svg.Element;function e.Element:create(f,g,h)local i={}setmetatable(i,e.Element)i.name=f;i.strElement="<"..f.." "for j,k in pairs(g)do i[j]=k;i.strElement=i.strElement..j.."=\""..k.."\" "end;if h~=nil then i.strElement=i.strElement..">"..h.."</"..f..">"else i.strElement=i.strElement.."/>"end;return i end;return e end;function svg:add(l)table.insert(self.elements,l)end;function svg:draw()local m="<svg width=\""..self.width.."\" height=\""..self.height.."\" fill=\""..self.fill.."\" stroke=\""..self.stroke.."\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">"for n,o in pairs(self.elements)do m=m..o.strElement end;m=m.."</svg>"return m end;function svg:innerdraw()local m=""for n,o in pairs(self.elements)do m=m..o.strElement end;return m end;function svg:Text(p,q,s,t,u)return self.Element:create("text",{x=q or 10,y=s or 50,style=t or"font-family: Verdana; font-size: 10; stroke: "..self.stroke.."; fill: "..self.fill..";",transform=u or""},p)end;function svg:addText(p,q,s,t,u)self:add(self:Text(p,q,s,t,u))end;function svg:Rect(q,s,a,height,c,v,d,w,x,u)return self.Element:create("rect",{x=q or 10,y=s or 10,width=a or 10,height=height or 10,stroke=c or self.stroke,fill=d or self.fill,["stroke-width"]=v or 1,rx=w or 0,ry=x or 0,transform=u or""})end;function svg:addRect(q,s,a,height,c,v,d,w,x,u)self:add(self:Rect(q,s,a,height,c,v,d,w,x,u))end;function svg:Circle(r,cx,cy,c,v,d,u)return self.Element:create("circle",{r=r or 25,cx=cx or 30,cy=cy or 30,stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill,transform=u or""})end;function svg:addCircle(r,cx,cy,c,v,d,u)self:add(self:Circle(r,cx,cy,c,v,d,u))end;function svg:Ellipse(cx,cy,w,x,c,v,d,u)return self.Element:create("ellipse",{rx=r or 25,ry=r or 15,cx=cx or 30,cy=cy or 30,stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill,transform=u or""})end;function svg:addEllipse(cx,cy,w,x,c,v,d,u)self:add(self:Ellipse(cx,cy,w,x,c,v,d,u))end;function svg:Line(y,z,A,B,c,v,d)return self.Element:create("line",{x1=r or 15,y1=r or 15,x2=cx or 50,y2=cy or 45,stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill})end;function svg:addLine(y,z,A,B,c,v,d)self:add(self:Line(y,z,A,B,c,v,d))end;function svg:Polyline(C,c,v,d,u)return self.Element:create("polyline",{points=C or"10,10 50,50 50,25 75,25",stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill,transform=u or""})end;function svg:addPolyline(C,c,v,d,u)self:add(self:Polyline(C,c,v,d,u))end;function svg:Path(D,c,v,d,u)return self.Element:create("path",{d=D or"M50 0 L75 100 L25 100 Z",stroke=c or self.stroke,["stroke-width"]=v or 1,fill=d or self.fill,transform=u or""})end;function svg:addPath(D,c,v,d,u)self:add(self:Path(D,c,v,d,u))end
+9
svg.lua
···6060 return svgStr
6161end
62626363+-- function to get the string formatted for the svg elements whithout the outer <svg>
6464+function svg:innerdraw()
6565+ local svgStr = ""
6666+ for k,v in pairs(self.elements) do
6767+ svgStr = svgStr .. v.strElement
6868+ end
6969+ return svgStr
7070+end
7171+6372-- function to add text
6473-- text: string => the text to write
6574-- x: number => Horizontal position