summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua102
1 files changed, 98 insertions, 4 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua
index 0ad475fbf3e..90519e23d55 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/bindings/BindingToPGF.lua,v 1.11 2015/06/08 21:58:24 tantau Exp $
+-- @release $Header$
@@ -63,10 +63,16 @@ require("pgf.gd.bindings").BindingToPGF = BindingToPGF
-- Imports
local lib = require "pgf.gd.lib"
+local Coordinate = require "pgf.gd.model.Coordinate"
+local Path = require "pgf.gd.model.Path"
+
-- The implementation
-- Forward
local table_in_pgf_syntax
+local animations_in_pgf_syntax
+local path_in_pgf_syntax
+local coordinate_in_pgf_syntax
@@ -140,7 +146,7 @@ function BindingToPGF:renderVertex(v)
local info = assert(self.storage[v], "thou shalt not modify the syntactic digraph")
tex.print(
string.format(
- "\\pgfgdcallbackrendernode{%s}{%.12fpt}{%.12fpt}{%.12fpt}{%.12fpt}{%.12fpt}{%.12fpt}{%s}",
+ "\\pgfgdcallbackrendernode{%s}{%.12fpt}{%.12fpt}{%.12fpt}{%.12fpt}{%.12fpt}{%.12fpt}{%s}{%s}",
'not yet positionedPGFINTERNAL' .. v.name,
info.x_min,
info.x_max,
@@ -148,7 +154,8 @@ function BindingToPGF:renderVertex(v)
info.y_max,
v.pos.x,
v.pos.y,
- info.box_count))
+ info.box_count,
+ animations_in_pgf_syntax(v.animations)))
end
function BindingToPGF:retrieveBox(index, box_num)
@@ -230,6 +237,7 @@ function BindingToPGF:renderEdge(e)
end
callback [#callback + 1] = '}'
+ callback [#callback + 1] = '{' .. animations_in_pgf_syntax(e.animations) .. '}'
-- hand TikZ code over to TeX
tex.print(table.concat(callback))
@@ -276,5 +284,91 @@ function table_in_pgf_syntax (t)
end
+function animations_in_pgf_syntax (a)
+ return
+ table.concat(
+ lib.imap(
+ a,
+ function(animation)
+ return "\\pgfanimateattribute{" .. animation.attribute .. "}{whom=pgf@gd," ..
+ table.concat(
+ lib.imap (
+ animation.entries,
+ function (entry)
+ return "entry={" .. entry.t .. "s}{" .. to_pgf(entry.value) .. "}"
+ end
+ ), ",") ..
+ "," ..
+ table.concat(
+ lib.imap(
+ animation.options or {},
+ function(table)
+ if table.value then
+ return table.key .. "={" .. to_pgf(table.value) .. "}"
+ else
+ return table.key
+ end
+ end), ",")
+ .. "}"
+ end)
+ )
+end
+
+
+function to_pgf(x)
+ if type (x) == "table" then
+ if getmetatable(x) == Coordinate then
+ return coordinate_in_pgf_syntax(x)
+ elseif getmetatable(x) == Path then
+ return path_in_pgf_syntax(x)
+ else
+ error("illegal table in value of a key to be passed back to pgf")
+ end
+ else
+ return tostring(x)
+ end
+end
+
+function path_in_pgf_syntax (p)
+
+ local s = {}
+
+ local i = 1
+ while i <= #p do
+ local c = p[i]
+ assert (type(c) == "string", "illegal path operand")
+
+ if c == "lineto" then
+ i = i + 1
+ local d = rigid(p[i])
+ s [#s + 1] = '\\pgfpathlineto{\\pgfqpoint{' .. to_pt(d.x) .. '}{' .. to_pt(d.y) .. '}}'
+ i = i + 1
+ elseif c == "moveto" then
+ i = i + 1
+ local d = rigid(p[i])
+ s [#s + 1] = '\\pgfpathmoveto{\\pgfqpoint{' .. to_pt(d.x) .. '}{' .. to_pt(d.y) .. '}}'
+ i = i + 1
+ elseif c == "closepath" then
+ s [#s + 1] = '\\pgfpathclose'
+ i = i + 1
+ elseif c == "curveto" then
+ local d1, d2, d3 = rigid(p[i+1]), rigid(p[i+2]), rigid(p[i+3])
+ i = i + 3
+ s [#s + 1] = '\\pgfpathcurveto{\\pgfqpoint{' .. to_pt(d1.x) .. '}{' .. to_pt(d1.y) .. '}}{\\pgfqpoint{'
+ .. to_pt(d2.x) .. '}{' .. to_pt(d2.y) .. '}}{\\pgfqpoint{'
+ .. to_pt(d3.x) .. '}{' .. to_pt(d3.y) .. '}}'
+ i = i + 1
+ else
+ error("illegal operation in edge path")
+ end
+ end
+
+ return table.concat(s)
+end
+
+function coordinate_in_pgf_syntax(c)
+ return '\\pgfqpoint{'..to_pt(c.x) .. '}{'.. to_pt(c.y) .. '}'
+end
+
-return BindingToPGF \ No newline at end of file
+return BindingToPGF