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/Passive/capacitor.lua | 18 +++++----- share/library/Passive/diode.lua | 68 ++++++++++++++++++------------------- share/library/Passive/inductor.lua | 16 ++++----- share/library/Passive/resistor.lua | 64 +++++++++++++++++----------------- 4 files changed, 83 insertions(+), 83 deletions(-) (limited to 'share/library/Passive') 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