Change how Cairo is presented to Lua scripts.
Makes the whole thing a bit more stable and less weird.
This commit is contained in:
@@ -26,50 +26,50 @@ local terminals = {{-2, 0}, {2, 2}, {2, -2}}
|
||||
-- Rendering
|
||||
local render = function (cr)
|
||||
-- The terminals
|
||||
cr.move_to (-2, 0)
|
||||
cr.line_to (0, 0)
|
||||
cr:move_to (-2, 0)
|
||||
cr:line_to (0, 0)
|
||||
|
||||
cr.move_to (0, 0.5)
|
||||
cr.line_to (2, 2)
|
||||
cr:move_to (0, 0.5)
|
||||
cr:line_to (2, 2)
|
||||
|
||||
cr.move_to (0, -0.5)
|
||||
cr.line_to (2, -2)
|
||||
cr:move_to (0, -0.5)
|
||||
cr:line_to (2, -2)
|
||||
|
||||
-- The ohmic connection
|
||||
cr.move_to (0, -1)
|
||||
cr.line_to (0, 1)
|
||||
cr:move_to (0, -1)
|
||||
cr:line_to (0, 1)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
local render_npn = function (cr)
|
||||
render (cr)
|
||||
|
||||
cr.save ()
|
||||
cr.translate (0, 0.5)
|
||||
cr.rotate (math.atan2 (-2, 1.5))
|
||||
cr:save ()
|
||||
cr:translate (0, 0.5)
|
||||
cr:rotate (math.atan2 (-2, 1.5))
|
||||
|
||||
cr.move_to (-0.4, 0.8)
|
||||
cr.line_to (0, 1.4)
|
||||
cr.line_to (0.4, 0.8)
|
||||
cr:move_to (-0.4, 0.8)
|
||||
cr:line_to (0, 1.4)
|
||||
cr:line_to (0.4, 0.8)
|
||||
|
||||
cr.stroke ()
|
||||
cr.restore ()
|
||||
cr:stroke ()
|
||||
cr:restore ()
|
||||
end
|
||||
|
||||
local render_pnp = function (cr)
|
||||
render (cr)
|
||||
|
||||
cr.save ()
|
||||
cr.translate (2, -2)
|
||||
cr.rotate (math.atan2 (2, 1.5))
|
||||
cr:save ()
|
||||
cr:translate (2, -2)
|
||||
cr:rotate (math.atan2 (2, 1.5))
|
||||
|
||||
cr.move_to (-0.4, 1.3)
|
||||
cr.line_to (0, 1.9)
|
||||
cr.line_to (0.4, 1.3)
|
||||
cr:move_to (-0.4, 1.3)
|
||||
cr:line_to (0, 1.9)
|
||||
cr:line_to (0.4, 1.3)
|
||||
|
||||
cr.stroke ()
|
||||
cr.restore ()
|
||||
cr:stroke ()
|
||||
cr:restore ()
|
||||
end
|
||||
|
||||
-- Register the symbols
|
||||
|
||||
@@ -27,59 +27,59 @@ local terminals_p = {{-2, -1}, {2, 1}, {2, 0}, {2, -1}}
|
||||
-- Rendering
|
||||
local render = function (cr)
|
||||
-- The terminals
|
||||
cr.move_to (-0.3, 1)
|
||||
cr.line_to (-0.3, -1)
|
||||
cr:move_to (-0.3, 1)
|
||||
cr:line_to (-0.3, -1)
|
||||
|
||||
cr.move_to (0, 1)
|
||||
cr.line_to (2, 1)
|
||||
cr:move_to (0, 1)
|
||||
cr:line_to (2, 1)
|
||||
|
||||
cr.move_to (0, 0)
|
||||
cr.line_to (2, 0)
|
||||
cr:move_to (0, 0)
|
||||
cr:line_to (2, 0)
|
||||
|
||||
cr.move_to (0, -1)
|
||||
cr.line_to (2, -1)
|
||||
cr:move_to (0, -1)
|
||||
cr:line_to (2, -1)
|
||||
|
||||
-- Source, gate, drain
|
||||
cr.move_to (0, -1.5)
|
||||
cr.line_to (0, -0.5)
|
||||
cr:move_to (0, -1.5)
|
||||
cr:line_to (0, -0.5)
|
||||
|
||||
cr.move_to (0, -0.3)
|
||||
cr.line_to (0, 0.3)
|
||||
cr:move_to (0, -0.3)
|
||||
cr:line_to (0, 0.3)
|
||||
|
||||
cr.move_to (0, 0.5)
|
||||
cr.line_to (0, 1.5)
|
||||
cr:move_to (0, 0.5)
|
||||
cr:line_to (0, 1.5)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
local render_n = function (cr)
|
||||
render (cr)
|
||||
|
||||
-- The left-side terminal
|
||||
cr.move_to (-2, 1)
|
||||
cr.line_to (-0.3, 1)
|
||||
cr:move_to (-2, 1)
|
||||
cr:line_to (-0.3, 1)
|
||||
|
||||
-- The arrow
|
||||
cr.move_to (0.9, -0.4)
|
||||
cr.line_to (0.4, 0)
|
||||
cr.line_to (0.9, 0.4)
|
||||
cr:move_to (0.9, -0.4)
|
||||
cr:line_to (0.4, 0)
|
||||
cr:line_to (0.9, 0.4)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
local render_p = function (cr)
|
||||
render (cr)
|
||||
|
||||
-- The left-side terminal
|
||||
cr.move_to (-2, -1)
|
||||
cr.line_to (-0.3, -1)
|
||||
cr:move_to (-2, -1)
|
||||
cr:line_to (-0.3, -1)
|
||||
|
||||
-- The arrow
|
||||
cr.move_to (0.4, -0.4)
|
||||
cr.line_to (0.9, 0)
|
||||
cr.line_to (0.4, 0.4)
|
||||
cr:move_to (0.4, -0.4)
|
||||
cr:line_to (0.9, 0)
|
||||
cr:line_to (0.4, 0.4)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
-- Register the symbols
|
||||
|
||||
@@ -27,47 +27,47 @@ local terminals_p = {{-2, -1}, {2, 1}, {2, -1}}
|
||||
-- Rendering
|
||||
local render = function (cr)
|
||||
-- The terminals
|
||||
cr.move_to (0, 1)
|
||||
cr.line_to (2, 1)
|
||||
cr:move_to (0, 1)
|
||||
cr:line_to (2, 1)
|
||||
|
||||
cr.move_to (0, -1)
|
||||
cr.line_to (2, -1)
|
||||
cr:move_to (0, -1)
|
||||
cr:line_to (2, -1)
|
||||
|
||||
-- The ohmic connection
|
||||
cr.move_to (0, -1.5)
|
||||
cr.line_to (0, 1.5)
|
||||
cr:move_to (0, -1.5)
|
||||
cr:line_to (0, 1.5)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
local render_n = function (cr)
|
||||
render (cr)
|
||||
|
||||
-- The left-side terminal
|
||||
cr.move_to (-2, 1)
|
||||
cr.line_to (0, 1)
|
||||
cr:move_to (-2, 1)
|
||||
cr:line_to (0, 1)
|
||||
|
||||
-- The arrow
|
||||
cr.move_to (-1, 0.6)
|
||||
cr.line_to (-0.5, 1)
|
||||
cr.line_to (-1, 1.4)
|
||||
cr:move_to (-1, 0.6)
|
||||
cr:line_to (-0.5, 1)
|
||||
cr:line_to (-1, 1.4)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
local render_p = function (cr)
|
||||
render (cr)
|
||||
|
||||
-- The left-side terminal
|
||||
cr.move_to (-2, -1)
|
||||
cr.line_to (0, -1)
|
||||
cr:move_to (-2, -1)
|
||||
cr:line_to (0, -1)
|
||||
|
||||
-- The arrow
|
||||
cr.move_to (-0.4, -0.6)
|
||||
cr.line_to (-1, -1)
|
||||
cr.line_to (-0.4, -1.4)
|
||||
cr:move_to (-0.4, -0.6)
|
||||
cr:line_to (-1, -1)
|
||||
cr:line_to (-0.4, -1.4)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
-- Register the symbols
|
||||
|
||||
@@ -17,23 +17,23 @@ local terminals = {{-4, -1}, {-4, 1}, {5, 0}}
|
||||
-- Rendering
|
||||
local render = function (cr)
|
||||
-- The main shape
|
||||
cr.move_to (-2, -2)
|
||||
cr.line_to (1, -2)
|
||||
cr.arc (1, 0, 2, math.pi * 1.5, math.pi * 0.5)
|
||||
cr.line_to (-2, 2)
|
||||
cr.close_path ()
|
||||
cr:move_to (-2, -2)
|
||||
cr:line_to (1, -2)
|
||||
cr:arc (1, 0, 2, math.pi * 1.5, math.pi * 0.5)
|
||||
cr:line_to (-2, 2)
|
||||
cr:close_path ()
|
||||
|
||||
-- The terminals
|
||||
cr.move_to (-4, -1)
|
||||
cr.line_to (-2, -1)
|
||||
cr:move_to (-4, -1)
|
||||
cr:line_to (-2, -1)
|
||||
|
||||
cr.move_to (-4, 1)
|
||||
cr.line_to (-2, 1)
|
||||
cr:move_to (-4, 1)
|
||||
cr:line_to (-2, 1)
|
||||
|
||||
cr.move_to (3, 0)
|
||||
cr.line_to (5, 0)
|
||||
cr:move_to (3, 0)
|
||||
cr:line_to (5, 0)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
-- Register the symbol
|
||||
|
||||
@@ -17,23 +17,23 @@ local terminals = {{-4, 0}, {4, 0}}
|
||||
-- Rendering
|
||||
local render = function (cr)
|
||||
-- The triangle
|
||||
cr.move_to (-2, -2)
|
||||
cr.line_to (2, 0)
|
||||
cr.line_to (-2, 2)
|
||||
cr.close_path ()
|
||||
cr:move_to (-2, -2)
|
||||
cr:line_to (2, 0)
|
||||
cr:line_to (-2, 2)
|
||||
cr:close_path ()
|
||||
|
||||
-- The circle
|
||||
cr.new_sub_path ()
|
||||
cr.arc (2.25, 0, 0.25, 0, 2 * math.pi)
|
||||
cr:new_sub_path ()
|
||||
cr:arc (2.25, 0, 0.25, 0, 2 * math.pi)
|
||||
|
||||
-- The terminals
|
||||
cr.move_to (-4, 0)
|
||||
cr.line_to (-2, 0)
|
||||
cr:move_to (-4, 0)
|
||||
cr:line_to (-2, 0)
|
||||
|
||||
cr.move_to (2.5, 0)
|
||||
cr.line_to (4, 0)
|
||||
cr:move_to (2.5, 0)
|
||||
cr:line_to (4, 0)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
-- Register the symbol
|
||||
|
||||
@@ -17,38 +17,38 @@ local terminals = {{-4, -1}, {-4, 1}, {5, 0}}
|
||||
-- Rendering
|
||||
local render = function (cr)
|
||||
-- The main shape
|
||||
cr.move_to (-2, -2)
|
||||
cr.line_to (0, -2)
|
||||
cr.curve_to (2, -2, 3, 0, 3, 0)
|
||||
cr.curve_to (3, 0, 2, 2, 0, 2)
|
||||
cr.line_to (-2, 2)
|
||||
cr.curve_to (-1, 1, -1, -1, -2, -2)
|
||||
cr.stroke ()
|
||||
cr:move_to (-2, -2)
|
||||
cr:line_to (0, -2)
|
||||
cr:curve_to (2, -2, 3, 0, 3, 0)
|
||||
cr:curve_to (3, 0, 2, 2, 0, 2)
|
||||
cr:line_to (-2, 2)
|
||||
cr:curve_to (-1, 1, -1, -1, -2, -2)
|
||||
cr:stroke ()
|
||||
|
||||
-- The terminals
|
||||
cr.save ()
|
||||
cr:save ()
|
||||
|
||||
-- Crop the contacts according to
|
||||
-- the left side of the main shape
|
||||
cr.move_to (-4, 2)
|
||||
cr.line_to (-2, 2)
|
||||
cr.curve_to (-1, 1, -1, -1, -2, -2)
|
||||
cr.line_to (-4, -2)
|
||||
cr.close_path ()
|
||||
cr.clip ()
|
||||
cr:move_to (-4, 2)
|
||||
cr:line_to (-2, 2)
|
||||
cr:curve_to (-1, 1, -1, -1, -2, -2)
|
||||
cr:line_to (-4, -2)
|
||||
cr:close_path ()
|
||||
cr:clip ()
|
||||
|
||||
cr.move_to (-4, -1)
|
||||
cr.line_to (-1, -1)
|
||||
cr:move_to (-4, -1)
|
||||
cr:line_to (-1, -1)
|
||||
|
||||
cr.move_to (-4, 1)
|
||||
cr.line_to (-1, 1)
|
||||
cr:move_to (-4, 1)
|
||||
cr:line_to (-1, 1)
|
||||
|
||||
cr.stroke ()
|
||||
cr.restore ()
|
||||
cr:stroke ()
|
||||
cr:restore ()
|
||||
|
||||
cr.move_to (3, 0)
|
||||
cr.line_to (5, 0)
|
||||
cr.stroke ()
|
||||
cr:move_to (3, 0)
|
||||
cr:line_to (5, 0)
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
-- Register the symbol
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -17,20 +17,20 @@ local terminals = {{-2, 0}, {2, 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, -1)
|
||||
cr.line_to (0.2, 1)
|
||||
cr:move_to (0.2, -1)
|
||||
cr:line_to (0.2, 1)
|
||||
|
||||
-- The terminals
|
||||
cr.move_to (-2, 0)
|
||||
cr.line_to (-0.2, 0)
|
||||
cr:move_to (-2, 0)
|
||||
cr:line_to (-0.2, 0)
|
||||
|
||||
cr.move_to (0.2, 0)
|
||||
cr.line_to (2, 0)
|
||||
cr:move_to (0.2, 0)
|
||||
cr:line_to (2, 0)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
-- Register the symbol
|
||||
|
||||
@@ -45,79 +45,79 @@ local terminals = {{-2, 0}, {2, 0}}
|
||||
-- Rendering
|
||||
local render = function (cr)
|
||||
-- The triangle
|
||||
cr.move_to (-1, -1)
|
||||
cr.line_to (1, 0)
|
||||
cr.line_to (-1, 1)
|
||||
cr.line_to (-1, -1)
|
||||
cr:move_to (-1, -1)
|
||||
cr:line_to (1, 0)
|
||||
cr:line_to (-1, 1)
|
||||
cr:line_to (-1, -1)
|
||||
|
||||
-- The vertical line
|
||||
cr.move_to (1, 1)
|
||||
cr.line_to (1, -1)
|
||||
cr:move_to (1, 1)
|
||||
cr:line_to (1, -1)
|
||||
|
||||
-- The terminals
|
||||
cr.move_to (-2, 0)
|
||||
cr.line_to (2, 0)
|
||||
cr:move_to (-2, 0)
|
||||
cr:line_to (2, 0)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
local render_zener = function (cr)
|
||||
render (cr)
|
||||
|
||||
cr.move_to (1, 1)
|
||||
cr.line_to (0.5, 1)
|
||||
cr:move_to (1, 1)
|
||||
cr:line_to (0.5, 1)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
local render_arrow = function (cr)
|
||||
cr.move_to (0, 0)
|
||||
cr.line_to (0, -1.5)
|
||||
cr:move_to (0, 0)
|
||||
cr:line_to (0, -1.5)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
|
||||
cr.move_to (-0.3, -0.7)
|
||||
cr.line_to (0, -1.5)
|
||||
cr.line_to (0.3, -0.7)
|
||||
cr.close_path ()
|
||||
cr:move_to (-0.3, -0.7)
|
||||
cr:line_to (0, -1.5)
|
||||
cr:line_to (0.3, -0.7)
|
||||
cr:close_path ()
|
||||
|
||||
cr.fill ()
|
||||
cr:fill ()
|
||||
end
|
||||
|
||||
local render_radiation = function (cr)
|
||||
cr.save ()
|
||||
cr.translate (-0.4, 0)
|
||||
cr:save ()
|
||||
cr:translate (-0.4, 0)
|
||||
render_arrow (cr)
|
||||
cr.restore ()
|
||||
cr:restore ()
|
||||
|
||||
cr.save ()
|
||||
cr.translate (0.4, 0)
|
||||
cr:save ()
|
||||
cr:translate (0.4, 0)
|
||||
render_arrow (cr)
|
||||
cr.restore ()
|
||||
cr:restore ()
|
||||
end
|
||||
|
||||
local render_led = function (cr)
|
||||
render (cr)
|
||||
|
||||
cr.save ()
|
||||
cr.translate (-0.3, -1.0)
|
||||
cr.rotate (math.atan2 (1, 1))
|
||||
cr:save ()
|
||||
cr:translate (-0.3, -1.0)
|
||||
cr:rotate (math.atan2 (1, 1))
|
||||
|
||||
render_radiation (cr)
|
||||
|
||||
cr.restore ()
|
||||
cr:restore ()
|
||||
end
|
||||
|
||||
local render_photo = function (cr)
|
||||
render (cr)
|
||||
|
||||
cr.save ()
|
||||
cr.translate (0.75, -2.05)
|
||||
cr.rotate (math.atan2 (-1, -1))
|
||||
cr:save ()
|
||||
cr:translate (0.75, -2.05)
|
||||
cr:rotate (math.atan2 (-1, -1))
|
||||
|
||||
render_radiation (cr)
|
||||
|
||||
cr.restore ()
|
||||
cr:restore ()
|
||||
end
|
||||
|
||||
-- Register the symbol
|
||||
|
||||
@@ -26,22 +26,22 @@ local terminals = {{-2, 0}, {2, 0}}
|
||||
-- Rendering
|
||||
local render = function (cr)
|
||||
-- The arcs
|
||||
cr.arc (-1.5, 0, 0.5, math.pi, 0)
|
||||
cr.arc (-0.5, 0, 0.5, math.pi, 0)
|
||||
cr.arc (0.5, 0, 0.5, math.pi, 0)
|
||||
cr.arc (1.5, 0, 0.5, math.pi, 0)
|
||||
cr:arc (-1.5, 0, 0.5, math.pi, 0)
|
||||
cr:arc (-0.5, 0, 0.5, math.pi, 0)
|
||||
cr:arc (0.5, 0, 0.5, math.pi, 0)
|
||||
cr:arc (1.5, 0, 0.5, math.pi, 0)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
local render_core = function (cr)
|
||||
render (cr)
|
||||
|
||||
-- The core
|
||||
cr.move_to (-2, -1)
|
||||
cr.line_to (2, -1)
|
||||
cr:move_to (-2, -1)
|
||||
cr:line_to (2, -1)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
-- Register the symbols
|
||||
|
||||
@@ -38,63 +38,63 @@ local terminals_pot = {{-2, 0}, {2, 0}, {2, -2}}
|
||||
-- Rendering
|
||||
local render = function (cr)
|
||||
-- The rectangle
|
||||
cr.move_to (-1.5, -0.5)
|
||||
cr.line_to (1.5, -0.5)
|
||||
cr.line_to (1.5, 0.5)
|
||||
cr.line_to (-1.5, 0.5)
|
||||
cr.line_to (-1.5, -0.5)
|
||||
cr:move_to (-1.5, -0.5)
|
||||
cr:line_to (1.5, -0.5)
|
||||
cr:line_to (1.5, 0.5)
|
||||
cr:line_to (-1.5, 0.5)
|
||||
cr:line_to (-1.5, -0.5)
|
||||
|
||||
-- The terminals
|
||||
cr.move_to (-2, 0)
|
||||
cr.line_to (-1.5, 0)
|
||||
cr:move_to (-2, 0)
|
||||
cr:line_to (-1.5, 0)
|
||||
|
||||
cr.move_to (1.5, 0)
|
||||
cr.line_to (2, 0)
|
||||
cr:move_to (1.5, 0)
|
||||
cr:line_to (2, 0)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
end
|
||||
|
||||
local render_adj = function (cr)
|
||||
render (cr)
|
||||
|
||||
-- The arrow
|
||||
cr.move_to (-1, 1)
|
||||
cr.line_to (1, -1)
|
||||
cr:move_to (-1, 1)
|
||||
cr:line_to (1, -1)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
|
||||
cr.save ()
|
||||
cr.translate (1.5, -1.5)
|
||||
cr.rotate (math.atan2 (1, 1))
|
||||
cr:save ()
|
||||
cr:translate (1.5, -1.5)
|
||||
cr:rotate (math.atan2 (1, 1))
|
||||
|
||||
cr.move_to (0, 0)
|
||||
cr.line_to (0.3, 0.8)
|
||||
cr.line_to (-0.3, 0.8)
|
||||
cr.close_path ()
|
||||
cr:move_to (0, 0)
|
||||
cr:line_to (0.3, 0.8)
|
||||
cr:line_to (-0.3, 0.8)
|
||||
cr:close_path ()
|
||||
|
||||
cr.fill ()
|
||||
cr.restore ()
|
||||
cr:fill ()
|
||||
cr:restore ()
|
||||
end
|
||||
|
||||
local render_pot = function (cr)
|
||||
render (cr)
|
||||
|
||||
-- The contact
|
||||
cr.move_to (0, -2)
|
||||
cr.line_to (2, -2)
|
||||
cr:move_to (0, -2)
|
||||
cr:line_to (2, -2)
|
||||
|
||||
-- The arrow
|
||||
cr.move_to (0, -2)
|
||||
cr.line_to (0, -1)
|
||||
cr:move_to (0, -2)
|
||||
cr:line_to (0, -1)
|
||||
|
||||
cr.stroke ()
|
||||
cr:stroke ()
|
||||
|
||||
cr.move_to (0, -0.5)
|
||||
cr.line_to (0.3, -1.3)
|
||||
cr.line_to (-0.3, -1.3)
|
||||
cr.close_path ()
|
||||
cr:move_to (0, -0.5)
|
||||
cr:line_to (0.3, -1.3)
|
||||
cr:line_to (-0.3, -1.3)
|
||||
cr:close_path ()
|
||||
|
||||
cr.fill ()
|
||||
cr:fill ()
|
||||
end
|
||||
|
||||
-- Register the symbol
|
||||
|
||||
Reference in New Issue
Block a user