Change how Cairo is presented to Lua scripts.

Makes the whole thing a bit more stable and less weird.
This commit is contained in:
2012-08-12 06:10:27 +02:00
parent 9366c42026
commit a1b79a55d2
20 changed files with 385 additions and 374 deletions

View File

@@ -17,20 +17,20 @@ local terminals = {{-1, 0}, {1, 0}}
-- Rendering
local render = function (cr)
-- The vertical lines
cr.move_to (-0.2, -1)
cr.line_to (-0.2, 1)
cr:move_to (-0.2, -1)
cr:line_to (-0.2, 1)
cr.move_to (0.2, -2)
cr.line_to (0.2, 2)
cr:move_to (0.2, -2)
cr:line_to (0.2, 2)
-- The terminals
cr.move_to (-1, 0)
cr.line_to (-0.2, 0)
cr:move_to (-1, 0)
cr:line_to (-0.2, 0)
cr.move_to (0.2, 0)
cr.line_to (1, 0)
cr:move_to (0.2, 0)
cr:line_to (1, 0)
cr.stroke ()
cr:stroke ()
end
-- Register the symbol

View File

@@ -17,20 +17,20 @@ local terminals = {{0, -1}}
-- Rendering
local render = function (cr)
-- The vertical line
cr.move_to (0, -1)
cr.line_to (0, 0.5)
cr:move_to (0, -1)
cr:line_to (0, 0.5)
-- The horizontal lines
cr.move_to (-1, 0.5)
cr.line_to (1, 0.5)
cr:move_to (-1, 0.5)
cr:line_to (1, 0.5)
cr.move_to (-0.75, 1.1)
cr.line_to (0.75, 1.1)
cr:move_to (-0.75, 1.1)
cr:line_to (0.75, 1.1)
cr.move_to (-0.5, 1.7)
cr.line_to (0.5, 1.7)
cr:move_to (-0.5, 1.7)
cr:line_to (0.5, 1.7)
cr.stroke ()
cr:stroke ()
end
-- Register the symbol

View File

@@ -17,8 +17,8 @@ local terminals = {}
-- Rendering
local render = function (cr)
-- The disk
cr.arc (0, 0, 0.3, 0, math.pi * 2)
cr.fill ()
cr:arc (0, 0, 0.3, 0, math.pi * 2)
cr:fill ()
end
-- Register the symbol

View File

@@ -17,29 +17,29 @@ local terminals = {{-2, 0}, {2, 0}}
-- Rendering
local render = function (cr)
-- The circle
cr.save ()
cr:save ()
cr.arc (0, 0, 1, 0, 2 * math.pi)
cr.stroke_preserve ()
cr.clip ()
cr:arc (0, 0, 1, 0, 2 * math.pi)
cr:stroke_preserve ()
cr:clip ()
cr.move_to (-1, -1)
cr.line_to (1, 1)
cr:move_to (-1, -1)
cr:line_to (1, 1)
cr.move_to (1, -1)
cr.line_to (-1, 1)
cr:move_to (1, -1)
cr:line_to (-1, 1)
cr.stroke ()
cr.restore ()
cr:stroke ()
cr:restore ()
-- The terminals
cr.move_to (-2, 0)
cr.line_to (-1, 0)
cr:move_to (-2, 0)
cr:line_to (-1, 0)
cr.move_to (1, 0)
cr.line_to (2, 0)
cr:move_to (1, 0)
cr:line_to (2, 0)
cr.stroke ()
cr:stroke ()
end
-- Register the symbol

View File

@@ -35,45 +35,45 @@ local terminals = {{-2, 0}, {2, 0}, {0, -2}, {0, 2}}
-- Rendering
local render_A = function (cr)
-- The circle
cr.arc (0, 0, 2, 0, math.pi * 2)
cr:arc (0, 0, 2, 0, math.pi * 2)
-- The letter A
cr.move_to (-0.4, 0.5)
cr.line_to (0, -0.5)
cr.line_to (0.4, 0.5)
cr:move_to (-0.4, 0.5)
cr:line_to (0, -0.5)
cr:line_to (0.4, 0.5)
cr.move_to (-0.3, 0.25)
cr.line_to (0.3, 0.25)
cr:move_to (-0.3, 0.25)
cr:line_to (0.3, 0.25)
cr.stroke ()
cr:stroke ()
end
local render_V = function (cr)
-- The circle
cr.arc (0, 0, 2, 0, math.pi * 2)
cr:arc (0, 0, 2, 0, math.pi * 2)
-- The letter V
cr.move_to (-0.4, -0.5)
cr.line_to (0, 0.5)
cr.line_to (0.4, -0.5)
cr:move_to (-0.4, -0.5)
cr:line_to (0, 0.5)
cr:line_to (0.4, -0.5)
cr.stroke ()
cr:stroke ()
end
local render_ohm = function (cr)
-- The circle
cr.arc (0, 0, 2, 0, math.pi * 2)
cr:arc (0, 0, 2, 0, math.pi * 2)
-- The capital letter omega
cr.move_to (-0.5, 0.5)
cr.line_to (-0.15, 0.5)
cr.curve_to (-0.15, 0.5, -0.4, 0.3, -0.4, 0)
cr.curve_to (-0.4, -0.25, -0.25, -0.5, 0, -0.5)
cr.curve_to (0.25, -0.5, 0.4, -0.25, 0.4, 0)
cr.curve_to (0.4, 0.3, 0.15, 0.5, 0.15, 0.5)
cr.line_to (0.5, 0.5)
cr:move_to (-0.5, 0.5)
cr:line_to (-0.15, 0.5)
cr:curve_to (-0.15, 0.5, -0.4, 0.3, -0.4, 0)
cr:curve_to (-0.4, -0.25, -0.25, -0.5, 0, -0.5)
cr:curve_to (0.25, -0.5, 0.4, -0.25, 0.4, 0)
cr:curve_to (0.4, 0.3, 0.15, 0.5, 0.15, 0.5)
cr:line_to (0.5, 0.5)
cr.stroke ()
cr:stroke ()
end
-- Register the symbols

View File

@@ -26,21 +26,21 @@ local terminals = {}
-- Rendering
local render_plus = function (cr)
-- The plus sign
cr.move_to (0, -0.4)
cr.line_to (0, 0.4)
cr:move_to (0, -0.4)
cr:line_to (0, 0.4)
cr.move_to (-0.4, 0)
cr.line_to (0.4, 0)
cr:move_to (-0.4, 0)
cr:line_to (0.4, 0)
cr.stroke ()
cr:stroke ()
end
local render_minus = function (cr)
-- The minus sign
cr.move_to (-0.4, 0)
cr.line_to (0.4, 0)
cr:move_to (-0.4, 0)
cr:line_to (0.4, 0)
cr.stroke ()
cr:stroke ()
end
-- Register the symbols

View File

@@ -17,17 +17,17 @@ local terminals = {{-2, 0}, {2, 0}}
-- Rendering
local render = function (cr)
-- The switch contact
cr.move_to (1.3, -1.3)
cr.line_to (-1, 0)
cr:move_to (1.3, -1.3)
cr:line_to (-1, 0)
-- The terminals
cr.move_to (-2, 0)
cr.line_to (-1, 0)
cr:move_to (-2, 0)
cr:line_to (-1, 0)
cr.move_to (1, 0)
cr.line_to (2, 0)
cr:move_to (1, 0)
cr:line_to (2, 0)
cr.stroke ()
cr:stroke ()
end
-- Register the symbol

View File

@@ -17,13 +17,13 @@ local terminals = {{-1, 0}}
-- Rendering
local render = function (cr)
-- The circle
cr.arc (0, 0, 0.3, 0, math.pi * 2)
cr:arc (0, 0, 0.3, 0, math.pi * 2)
-- The contact
cr.move_to (-1, 0)
cr.line_to (-0.3, 0)
cr:move_to (-1, 0)
cr:line_to (-0.3, 0)
cr.stroke ()
cr:stroke ()
end
-- Register the symbol

View File

@@ -26,35 +26,35 @@ local terminals = {{-2, 0}, {2, 0}, {0, -2}, {0, 2}}
-- Rendering
local render = function (cr)
-- The circle
cr.arc (0, 0, 2, 0, math.pi * 2)
cr:arc (0, 0, 2, 0, math.pi * 2)
cr.stroke ()
cr:stroke ()
end
local render_ac = function (cr)
render (cr)
-- The AC symbol
cr.move_to (-1, 0.25)
cr.curve_to (-0.4, -1.5, 0.4, 1.5, 1, -0.25)
cr:move_to (-1, 0.25)
cr:curve_to (-0.4, -1.5, 0.4, 1.5, 1, -0.25)
cr.stroke ()
cr:stroke ()
end
local render_dc = function (cr)
render (cr)
-- The DC symbol
cr.move_to (-1, -0.25)
cr.line_to (1, -0.25)
cr:move_to (-1, -0.25)
cr:line_to (1, -0.25)
cr.move_to (-1, 0.25)
cr.line_to (-0.2, 0.25)
cr:move_to (-1, 0.25)
cr:line_to (-0.2, 0.25)
cr.move_to (0.2, 0.25)
cr.line_to (1, 0.25)
cr:move_to (0.2, 0.25)
cr:line_to (1, 0.25)
cr.stroke ()
cr:stroke ()
end
-- Register the symbols