[READ-ONLY] Mirror of https://github.com/thoda-dev/svg-lua. svg lua library
0

Configure Feed

Select the types of activity you want to include in your feed.

add circle element

Thomas DAGES (Dec 6, 2018, 4:12 PM +0100) 9ed59f34 0d4f39b3

+34 -7
+15 -6
README.md
··· 25 25 26 26 - width: number => width of the drawing, default to 100 27 27 - height: number => height of the drawing, default to 100 28 - - stroke: string => lines color, default to '#000000' 29 - - fill: string => fill color, default to 'transparent' 28 + - stroke: string => lines color, default to "#000000" 29 + - fill: string => fill color, default to "transparent" 30 30 31 31 **svg:add(element)** *add an element to the drawing* 32 32 ··· 35 35 **svg:draw()** *return the svg formated string* 36 36 37 37 ### Elements for svg:add() 38 - **svg:Rect()** *add a rectangle* 38 + **svg:Rect(x, y, width, height, stroke, strokeWidth, fill, rx, ry)** *add a rectangle* 39 39 40 40 - x: number => Horizontal position from top left corner, default to 10 41 41 - y: number => Vertical position from top left corner, default to 10 42 42 - width: number => Width of the rectangle, default to 10 43 43 - height: number => Height of the rectangle, default to 10 44 - - stroke: string => lines color, default to '#000000' 44 + - stroke: string => lines color, default to svg:create() parameter *("#000000")* 45 45 - strokeWidth: string => lines width, default to 1 46 - - fill: string => fill color, default to transparent 46 + - fill: string => fill color, default to svg:create() parameter *("transparent")* 47 47 - rx: number => Horizontal raduis of the corners, default to 0 48 - - ry: number => Vertical radius of the corners, default to 0 48 + - ry: number => Vertical radius of the corners, default to 0 49 + 50 + **svg:Circle(r, cx, cy, stroke, strokeWidth, fill)** *add a circle* 51 + 52 + - r: number => circle radius, default to 25 53 + - cx: number => Horizontal position of the center, default to 30 54 + - cy: number => Vertical position of the center, default to 30 55 + - stroke: string => lines color, default to svg:create() parameter *("#000000")* 56 + - strokeWidth: string => lines width, default to 1 57 + - fill: string => fill color, default to svg:create() parameter *("transparent")*
+18
svg.lua
··· 78 78 rx = rx or 0, 79 79 ry = ry or 0 80 80 }) 81 + end 82 + 83 + -- function to create a circle 84 + -- r: number => circle radius 85 + -- cx: number => Horizontal position of the center 86 + -- cy: number => Vertical position of the center 87 + -- stroke: string => lines color 88 + -- strokeWidth: string => lines width 89 + -- fill: string => fill color 90 + function svg:Circle(r, cx, cy, stroke, strokeWidth, fill) 91 + return self.Element.create("circle", { 92 + r = r or 25, 93 + cx = cx or 30, 94 + cy = cy or 30, 95 + stroke = stroke or self.stroke, 96 + ["stroke-width"] = strokeWidth or 1, 97 + fill = fill or self.fill 98 + }) 81 99 end
+1 -1
svg.min.lua
··· 1 - 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)local h={}setmetatable(h,e.Element)h.name=f;h.strElement="<"..f.." "for i,j in pairs(g)do h[i]=j;h.strElement=h.strElement..i.."=\""..j.."\" "end;h.strElement=h.strElement.."/>"return h end;return e end;function svg:add(k)table.insert(self.elements,k)end;function svg:draw()local l="<svg width=\""..self.width.."\" height=\""..self.height.."\" fill=\""..self.fill.."\" stroke=\""..self.stroke.."\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">"for m,n in pairs(self.elements)do l=l..n.strElement end;l=l.."</svg>"return l end;function svg:Rect(o,p,a,height,c,q,d,r,s)return self.Element:create("rect",{x=o or 10,y=p or 10,width=a or 10,height=height or 10,stroke=c or self.stroke,fill=d or self.fill,["stroke-width"]=q or 1,rx=r or 0,ry=s or 0})end 1 + 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)local h={}setmetatable(h,e.Element)h.name=f;h.strElement="<"..f.." "for i,j in pairs(g)do h[i]=j;h.strElement=h.strElement..i.."=\""..j.."\" "end;h.strElement=h.strElement.."/>"return h end;return e end;function svg:add(k)table.insert(self.elements,k)end;function svg:draw()local l="<svg width=\""..self.width.."\" height=\""..self.height.."\" fill=\""..self.fill.."\" stroke=\""..self.stroke.."\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">"for m,n in pairs(self.elements)do l=l..n.strElement end;l=l.."</svg>"return l end;function svg:Rect(o,p,a,height,c,q,d,r,s)return self.Element:create("rect",{x=o or 10,y=p or 10,width=a or 10,height=height or 10,stroke=c or self.stroke,fill=d or self.fill,["stroke-width"]=q or 1,rx=r or 0,ry=s or 0})end;function svg:Circle(t,u,v,c,q,d)return self.Element.create("circle",{r=t or 25,cx=u or 30,cy=v or 30,stroke=c or self.stroke,["stroke-width"]=q or 1,fill=d or self.fill})end