From a1b79a55d2d70660aa156da460ee2e55ebc99183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Sun, 12 Aug 2012 06:10:27 +0200 Subject: Change how Cairo is presented to Lua scripts. Makes the whole thing a bit more stable and less weird. --- share/library/Active/bipolar.lua | 50 +++++++++++++------------- share/library/Active/igfet.lua | 54 ++++++++++++++-------------- share/library/Active/jfet.lua | 38 ++++++++++---------- share/library/Logical/and.lua | 24 ++++++------- share/library/Logical/not.lua | 22 ++++++------ share/library/Logical/or.lua | 46 ++++++++++++------------ share/library/Misc/cell.lua | 18 +++++----- share/library/Misc/ground.lua | 18 +++++----- share/library/Misc/junction.lua | 4 +-- share/library/Misc/lamp.lua | 30 ++++++++-------- share/library/Misc/meters.lua | 44 +++++++++++------------ share/library/Misc/signs.lua | 16 ++++----- share/library/Misc/switch.lua | 14 ++++---- share/library/Misc/terminal.lua | 8 ++--- share/library/Misc/voltage-source.lua | 24 ++++++------- share/library/Passive/capacitor.lua | 18 +++++----- share/library/Passive/diode.lua | 68 +++++++++++++++++------------------ share/library/Passive/inductor.lua | 16 ++++----- share/library/Passive/resistor.lua | 64 ++++++++++++++++----------------- 19 files changed, 288 insertions(+), 288 deletions(-) (limited to 'share/library') diff --git a/share/library/Active/bipolar.lua b/share/library/Active/bipolar.lua index 921772c..bac8786 100644 --- a/share/library/Active/bipolar.lua +++ b/share/library/Active/bipolar.lua @@ -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 diff --git a/share/library/Active/igfet.lua b/share/library/Active/igfet.lua index 8b5796d..3e17183 100644 --- a/share/library/Active/igfet.lua +++ b/share/library/Active/igfet.lua @@ -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 diff --git a/share/library/Active/jfet.lua b/share/library/Active/jfet.lua index ebe917a..5fb9d47 100644 --- a/share/library/Active/jfet.lua +++ b/share/library/Active/jfet.lua @@ -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 diff --git a/share/library/Logical/and.lua b/share/library/Logical/and.lua index da09cfe..8c4477f 100644 --- a/share/library/Logical/and.lua +++ b/share/library/Logical/and.lua @@ -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 diff --git a/share/library/Logical/not.lua b/share/library/Logical/not.lua index 8153e4a..44e4cc3 100644 --- a/share/library/Logical/not.lua +++ b/share/library/Logical/not.lua @@ -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 diff --git a/share/library/Logical/or.lua b/share/library/Logical/or.lua index a7ff4bf..18aabab 100644 --- a/share/library/Logical/or.lua +++ b/share/library/Logical/or.lua @@ -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 diff --git a/share/library/Misc/cell.lua b/share/library/Misc/cell.lua index 8a6a575..541e44c 100644 --- a/share/library/Misc/cell.lua +++ b/share/library/Misc/cell.lua @@ -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 diff --git a/share/library/Misc/ground.lua b/share/library/Misc/ground.lua index 6d20b57..2209718 100644 --- a/share/library/Misc/ground.lua +++ b/share/library/Misc/ground.lua @@ -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 diff --git a/share/library/Misc/junction.lua b/share/library/Misc/junction.lua index 75fbafb..c7c399b 100644 --- a/share/library/Misc/junction.lua +++ b/share/library/Misc/junction.lua @@ -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 diff --git a/share/library/Misc/lamp.lua b/share/library/Misc/lamp.lua index f543bde..d6dd411 100644 --- a/share/library/Misc/lamp.lua +++ b/share/library/Misc/lamp.lua @@ -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 diff --git a/share/library/Misc/meters.lua b/share/library/Misc/meters.lua index 55b6e28..1fb0394 100644 --- a/share/library/Misc/meters.lua +++ b/share/library/Misc/meters.lua @@ -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.stroke () + 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 () end -- Register the symbols diff --git a/share/library/Misc/signs.lua b/share/library/Misc/signs.lua index d2efe45..158d9b2 100644 --- a/share/library/Misc/signs.lua +++ b/share/library/Misc/signs.lua @@ -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 diff --git a/share/library/Misc/switch.lua b/share/library/Misc/switch.lua index 2cae086..2d95b6b 100644 --- a/share/library/Misc/switch.lua +++ b/share/library/Misc/switch.lua @@ -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 diff --git a/share/library/Misc/terminal.lua b/share/library/Misc/terminal.lua index 3d31537..4bc2f2f 100644 --- a/share/library/Misc/terminal.lua +++ b/share/library/Misc/terminal.lua @@ -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 diff --git a/share/library/Misc/voltage-source.lua b/share/library/Misc/voltage-source.lua index 456310b..9003364 100644 --- a/share/library/Misc/voltage-source.lua +++ b/share/library/Misc/voltage-source.lua @@ -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 diff --git a/share/library/Passive/capacitor.lua b/share/library/Passive/capacitor.lua index 121b01d..bd8c408 100644 --- a/share/library/Passive/capacitor.lua +++ b/share/library/Passive/capacitor.lua @@ -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 diff --git a/share/library/Passive/diode.lua b/share/library/Passive/diode.lua index d480b46..46bfa99 100644 --- a/share/library/Passive/diode.lua +++ b/share/library/Passive/diode.lua @@ -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 diff --git a/share/library/Passive/inductor.lua b/share/library/Passive/inductor.lua index b63a8f5..34a1cda 100644 --- a/share/library/Passive/inductor.lua +++ b/share/library/Passive/inductor.lua @@ -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 diff --git a/share/library/Passive/resistor.lua b/share/library/Passive/resistor.lua index fdb1642..7c0b222 100644 --- a/share/library/Passive/resistor.lua +++ b/share/library/Passive/resistor.lua @@ -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 -- cgit v1.2.3