Module: Sevgi::Toplevel
- Included in:
- Sevgi
- Defined in:
- lib/sevgi/toplevel.rb,
lib/sevgi/toplevel/derender.rb,
lib/sevgi/toplevel/executor.rb,
lib/sevgi/toplevel/function.rb,
lib/sevgi/toplevel/geometry.rb,
lib/sevgi/toplevel/graphics.rb,
lib/sevgi/toplevel/sundries.rb
Overview
Shared implementation for the full Sevgi top-level DSL.
This module is installed by include Sevgi or extend Sevgi; it should not
normally be included directly.
Instance Method Summary collapse
- #Canvas ⇒ Object
-
#Decompile(content, id: nil, omit: nil) ⇒ Sevgi::Derender::Node
Converts inline SVG/XML content into a derender node.
-
#DecompileFile(file, id: nil, omit: nil) ⇒ Sevgi::Derender::Node
Converts an SVG/XML file into a derender node.
-
#Derender(content, id: nil, omit: nil) ⇒ String
Converts inline SVG/XML content into Sevgi DSL Ruby source.
-
#DerenderFile(file, id: nil, omit: nil) ⇒ String
Converts an SVG/XML file into Sevgi DSL Ruby source.
-
#Document ⇒ Class
Document class.
-
#Document!(name, preambles: [], attributes: {}) ⇒ Class
Defines or replaces a document profile.
-
#Evaluate(content, element, id: nil, omit: nil) ⇒ Sevgi::Graphics::Element?
Evaluates inline SVG/XML content under a graphics element, including the selected node.
-
#EvaluateChildren(content, element, id: nil, omit: nil) ⇒ Array<Sevgi::Graphics::Element>
Evaluates only the selected node's children from inline SVG/XML content under a graphics element.
-
#EvaluateChildrenFile(file, element, id: nil, omit: nil) ⇒ Array<Sevgi::Graphics::Element>
Evaluates only the selected node's children from an SVG/XML file under a graphics element.
-
#EvaluateFile(file, element, id: nil, omit: nil) ⇒ Sevgi::Graphics::Element?
Evaluates an SVG/XML file under a graphics element, including the selected node.
-
#Grid(canvas, unit:, multiple:) ⇒ Sevgi::Sundries::Grid
Builds a drawable grid fitted inside a graphics canvas.
-
#Load(*files) ⇒ Array<String>
Loads one or more Sevgi files relative to the caller's source file.
- #Mixin ⇒ Object
-
#Paper(width, height, name = :custom, unit: "mm") ⇒ Symbol, String
Defines or validates a named paper profile for DSL use.
-
#Paper!(width, height, name = :custom, unit: "mm") ⇒ Symbol, String
Defines or overwrites a named paper profile for DSL use.
-
#SVG(document = :default, canvas = Undefined, **attributes) { ... } ⇒ Sevgi::Graphics::Document::Proto
Builds an SVG document through the full Sevgi top-level DSL.
Instance Method Details
#Canvas(paper, **overrides) ⇒ Sevgi::Graphics::Canvas #Canvas(width:, height:, unit: "mm", name: :custom, margins: []) ⇒ Sevgi::Graphics::Canvas
26 |
# File 'lib/sevgi/toplevel/graphics.rb', line 26 def Canvas(...) = Graphics.canvas(...) |
#Decompile(content, id: nil, omit: nil) ⇒ Sevgi::Derender::Node
Converts inline SVG/XML content into a derender node.
16 |
# File 'lib/sevgi/toplevel/derender.rb', line 16 def Decompile(content, id: nil, omit: nil) = Derender.decompile(content, id:, omit:) |
#DecompileFile(file, id: nil, omit: nil) ⇒ Sevgi::Derender::Node
Converts an SVG/XML file into a derender node.
28 |
# File 'lib/sevgi/toplevel/derender.rb', line 28 def DecompileFile(file, id: nil, omit: nil) = Derender.decompile_file(file, id:, omit:) |
#Derender(content, id: nil, omit: nil) ⇒ String
Converts inline SVG/XML content into Sevgi DSL Ruby source.
40 |
# File 'lib/sevgi/toplevel/derender.rb', line 40 def Derender(content, id: nil, omit: nil) = Derender.derender(content, id:, omit:) |
#DerenderFile(file, id: nil, omit: nil) ⇒ String
Converts an SVG/XML file into Sevgi DSL Ruby source.
53 |
# File 'lib/sevgi/toplevel/derender.rb', line 53 def DerenderFile(file, id: nil, omit: nil) = Derender.derender_file(file, id:, omit:) |
#Document(name) ⇒ Class #Document(name, preambles: Undefined, attributes: Undefined) ⇒ Class #Document(preambles: Undefined, attributes: Undefined) ⇒ Class
Returns document class.
52 |
# File 'lib/sevgi/toplevel/graphics.rb', line 52 def Document(...) = Graphics.document(...) |
#Document!(name, preambles: [], attributes: {}) ⇒ Class
Defines or replaces a document profile.
62 63 64 |
# File 'lib/sevgi/toplevel/graphics.rb', line 62 def Document!(name, preambles: [], attributes: {}) Graphics.document!(name, preambles:, attributes:) end |
#Evaluate(content, element, id: nil, omit: nil) ⇒ Sevgi::Graphics::Element?
Evaluates inline SVG/XML content under a graphics element, including the selected node.
65 |
# File 'lib/sevgi/toplevel/derender.rb', line 65 def Evaluate(content, element, id: nil, omit: nil) = Derender.evaluate(content, element, id:, omit:) |
#EvaluateChildren(content, element, id: nil, omit: nil) ⇒ Array<Sevgi::Graphics::Element>
Evaluates only the selected node's children from inline SVG/XML content under a graphics element.
77 78 79 |
# File 'lib/sevgi/toplevel/derender.rb', line 77 def EvaluateChildren(content, element, id: nil, omit: nil) Derender.evaluate_children(content, element, id:, omit:) end |
#EvaluateChildrenFile(file, element, id: nil, omit: nil) ⇒ Array<Sevgi::Graphics::Element>
Evaluates only the selected node's children from an SVG/XML file under a graphics element.
92 93 94 |
# File 'lib/sevgi/toplevel/derender.rb', line 92 def EvaluateChildrenFile(file, element, id: nil, omit: nil) Derender.evaluate_children_file(file, element, id:, omit:) end |
#EvaluateFile(file, element, id: nil, omit: nil) ⇒ Sevgi::Graphics::Element?
Evaluates an SVG/XML file under a graphics element, including the selected node.
107 |
# File 'lib/sevgi/toplevel/derender.rb', line 107 def EvaluateFile(file, element, id: nil, omit: nil) = Derender.evaluate_file(file, element, id:, omit:) |
#Grid(canvas, unit:, multiple:) ⇒ Sevgi::Sundries::Grid
Builds a drawable grid fitted inside a graphics canvas.
The canvas margins are minimum clearances. Any span left after fitting
whole major intervals is shared equally between the opposite margins, so
their requested difference is preserved. The returned grid starts at
(0, 0); Sundries::Grid#canvas exposes the fitted page margins.
23 24 25 26 27 28 29 30 31 |
# File 'lib/sevgi/toplevel/sundries.rb', line 23 def Grid(canvas, unit:, multiple:) ArgumentError.("Must be a Canvas: #{canvas}") unless canvas.is_a?(Graphics::Canvas) Sundries::Grid.new( x: Sundries::Ruler.new(brut: canvas.width, unit:, multiple:, margins: [canvas.left, canvas.right]), y: Sundries::Ruler.new(brut: canvas.height, unit:, multiple:, margins: [canvas.top, canvas.bottom]), canvas: ) end |
#Load(*files) ⇒ Array<String>
Load resolves against the active executor scope in the current fiber.
Ordinary library code should use Ruby require; Load is available only during Sevgi script execution.
Loads one or more Sevgi files relative to the caller's source file.
77 78 79 80 81 82 83 84 85 |
# File 'lib/sevgi/toplevel/executor.rb', line 77 def Load(*files) start = ::File.dirname(caller_locations(1..1).first.path) files.each do |file| location = F.locate(file, start) ::Sevgi::Executor.__send__(:load, location.file) end end |
#Mixin(mod, document = Sevgi::Graphics::Document::Base) ⇒ nil #Mixin(mod, document = Sevgi::Graphics::Document::Base) { ... } ⇒ Module #Mixin(document = Sevgi::Graphics::Document::Base) { ... } ⇒ Module
108 |
# File 'lib/sevgi/toplevel/graphics.rb', line 108 def Mixin(...) = Graphics::Mixtures.mixin(...) |
#Paper(width, height, name = :custom, unit: "mm") ⇒ Symbol, String
120 |
# File 'lib/sevgi/toplevel/graphics.rb', line 120 def Paper(...) = Graphics.paper(...) |
#Paper!(width, height, name = :custom, unit: "mm") ⇒ Symbol, String
132 |
# File 'lib/sevgi/toplevel/graphics.rb', line 132 def Paper!(...) = Graphics.paper!(...) |
#SVG(document = :default, canvas = Undefined, **attributes) { ... } ⇒ Sevgi::Graphics::Document::Proto
Builds an SVG document through the full Sevgi top-level DSL.
77 78 79 |
# File 'lib/sevgi/toplevel/graphics.rb', line 77 def SVG(document = :default, canvas = Undefined, **attributes, &block) Graphics.SVG(document, canvas, **attributes, &block) end |