From 3bda4a1788300055acb2dfd13f5e607c28721bcd Mon Sep 17 00:00:00 2001 From: Thomas DAGES Date: Fri, 7 Dec 2018 11:36:10 +0100 Subject: [PATCH] added transform option for alla elements --- README.md | 11 +++++++---- svg.lua | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 90a3cd3..310fd1e 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ If you are using a custom test file, replace `test.lua` by your file name. * `fill: self.fill` svg:create() parameter ("transparent" by default) - tranform: string => transformation options (eg: rotation) -**svg:Rect(x, y, width, height, stroke, strokeWidth, fill, rx, ry)** *add a rectangle* +**svg:Rect(x, y, width, height, stroke, strokeWidth, fill, rx, ry, transform)** *add a rectangle* - x: number => Horizontal position from top left corner, default to 10 - y: number => Vertical position from top left corner, default to 10 @@ -80,8 +80,9 @@ If you are using a custom test file, replace `test.lua` by your file name. - fill: string => fill color, default to svg:create() parameter ("transparent" by default) - rx: number => Horizontal raduis of the corners, default to 0 - ry: number => Vertical radius of the corners, default to 0 + - tranform: string => transformation options (eg: rotation) -**svg:Circle(r, cx, cy, stroke, strokeWidth, fill)** *add a circle* +**svg:Circle(r, cx, cy, stroke, strokeWidth, fill, transform)** *add a circle* - r: number => circle radius, default to 25 - cx: number => Horizontal position of the center, default to 30 @@ -89,8 +90,9 @@ If you are using a custom test file, replace `test.lua` by your file name. - stroke: string => lines color, default to svg:create() parameter ("#000000" by default) - strokeWidth: string => lines width, default to 1 - fill: string => fill color, default to svg:create() parameter ("transparent" by default) + - tranform: string => transformation options (eg: rotation) -**svg:Ellipse(cx, cy, rx, ry, stroke, strokeWidth, fill)** *add an ellipse* +**svg:Ellipse(cx, cy, rx, ry, stroke, strokeWidth, fill, transform)** *add an ellipse* - cx: number => Horizontal position of the center, default to 30 - cy: number => Vertical position of the center, default to 30 @@ -98,4 +100,5 @@ If you are using a custom test file, replace `test.lua` by your file name. - ry: number => Vertical radius of the ellipse, default to 15 - stroke: string => lines color, default to svg:create() parameter ("#000000" by default) - strokeWidth: string => lines width, default to 1 - - fill: string => fill color, default to svg:create() parameter ("transparent" by default) \ No newline at end of file + - fill: string => fill color, default to svg:create() parameter ("transparent" by default) + - tranform: string => transformation options (eg: rotation) \ No newline at end of file diff --git a/svg.lua b/svg.lua index feecd1d..51988e3 100644 --- a/svg.lua +++ b/svg.lua @@ -85,7 +85,8 @@ end -- fill: string => fill color -- rx: number => Rayon x des coins du rectangle -- ry: number => Rayon y des coins du rectangle -function svg:Rect(x, y, width, height, stroke, strokeWidth, fill, rx, ry) +-- tranform: string => transformation options (eg: rotation) +function svg:Rect(x, y, width, height, stroke, strokeWidth, fill, rx, ry, transform) return self.Element:create("rect", { x = x or 10, y = y or 10, @@ -95,7 +96,8 @@ function svg:Rect(x, y, width, height, stroke, strokeWidth, fill, rx, ry) fill = fill or self.fill, ["stroke-width"] = strokeWidth or 1, rx = rx or 0, - ry = ry or 0 + ry = ry or 0, + transform = transform or "" }) end @@ -106,14 +108,16 @@ end -- stroke: string => lines color -- strokeWidth: string => lines width -- fill: string => fill color -function svg:Circle(r, cx, cy, stroke, strokeWidth, fill) +-- tranform: string => transformation options (eg: rotation) +function svg:Circle(r, cx, cy, stroke, strokeWidth, fill, transform) return self.Element:create("circle", { r = r or 25, cx = cx or 30, cy = cy or 30, stroke = stroke or self.stroke, ["stroke-width"] = strokeWidth or 1, - fill = fill or self.fill + fill = fill or self.fill, + transform = transform or "" }) end @@ -125,7 +129,8 @@ end -- stroke: string => lines color -- strokeWidth: string => lines width -- fill: string => fill color -function svg:Ellipse(cx, cy, rx, ry, stroke, strokeWidth, fill) +-- tranform: string => transformation options (eg: rotation) +function svg:Ellipse(cx, cy, rx, ry, stroke, strokeWidth, fill, transform) return self.Element:create("ellipse", { rx = r or 25, ry = r or 15, @@ -133,6 +138,7 @@ function svg:Ellipse(cx, cy, rx, ry, stroke, strokeWidth, fill) cy = cy or 30, stroke = stroke or self.stroke, ["stroke-width"] = strokeWidth or 1, - fill = fill or self.fill + fill = fill or self.fill, + transform = transform or "" }) end \ No newline at end of file -- 2.51.2