vector formats: comments are specs only
This commit is contained in:
1 parent
d91dc6c597
commit
89a2047349
10 files changed
+34
-126
No files matched your search
@@ -1,7 +1,5 @@
|
||||
--!strict
|
||||
-- vector/svg/Write: a Types.Vector to SVG text: <svg> with width / height / viewBox / preserveAspectRatio, gradients
|
||||
-- and clip paths in <defs>, groups as nested <g opacity clip-path>, every path as <path d transform fill stroke ...>
|
||||
-- (colour alpha as fill- / stroke-opacity). Never throws: bad values return nil, message.
|
||||
-- vector/svg/Write: a Types.Vector to SVG text; never throws (bad values return nil, message).
|
||||
local Xml = require("@rosetta/codecs/text/Xml")
|
||||
local Types = require("@rosetta/Types")
|
||||
local PathData = require("@rosetta/vector/svg/PathData")
|
||||
@@ -41,7 +39,6 @@ local function matrix(m: any): string?
|
||||
return "matrix(" .. table.concat(parts, " ") .. ")"
|
||||
end
|
||||
|
||||
-- write(v) -> SVG text | nil, message
|
||||
function Write.vector(v: Types.Vector): (string?, string?)
|
||||
if type(v) ~= "table" or type(v.paths) ~= "table" or type(v.width) ~= "number" or type(v.height) ~= "number" then
|
||||
return nil, "needs a Vector value"
|
||||
@@ -51,7 +48,6 @@ function Write.vector(v: Types.Vector): (string?, string?)
|
||||
local clips: { any } = if type(meta.clips) == "table" then meta.clips else {}
|
||||
local defs = {}
|
||||
local gradients = 0
|
||||
-- paints -> attribute values (gradients go to defs)
|
||||
local function paintAttrs(p: any, which: string): { { any } }
|
||||
if type(p) ~= "table" then
|
||||
return { { which, "none" } }
|
||||
@@ -109,7 +105,6 @@ function Write.vector(v: Types.Vector): (string?, string?)
|
||||
return "url(#" .. clipIds[id] .. ")"
|
||||
end
|
||||
local root = {}
|
||||
-- the open <g> stack: { id, children }
|
||||
local stack: { { id: number?, kids: { any } } } = { { id = nil, kids = root } }
|
||||
local function chain(g: number?): { number }
|
||||
local out = {}
|
||||
|
||||
Reference in new issue
Block a user