Module: Sevgi::Graphics::Mixtures::Inkscape
- Defined in:
- lib/sevgi/graphics/mixtures/inkscape.rb
Overview
Inkscape-specific SVG DSL helpers.
Instance Method Summary collapse
-
#Group(mod, *args, **kwargs) { ... } ⇒ Sevgi::Graphics::Element
Renders a callable module inside a group.
-
#InkscapeTemplateInfo(name:, desc: nil, author: nil, date: nil, keywords: nil) ⇒ Sevgi::Graphics::Element
Adds Inkscape template metadata.
-
#Layer(mod, *args, **kwargs) { ... } ⇒ Sevgi::Graphics::Element
Renders a callable module inside an Inkscape layer.
-
#layer(**attributes) { ... } ⇒ Sevgi::Graphics::Element
Builds an Inkscape layer group.
-
#Layer!(mod, *args, **kwargs) { ... } ⇒ Sevgi::Graphics::Element
Renders a callable module inside an insensitive Inkscape layer.
-
#layer!(**attributes) { ... } ⇒ Sevgi::Graphics::Element
Builds an insensitive Inkscape layer group.
-
#Pages(*pages, id: "namedview") {|page| ... } ⇒ Sevgi::Graphics::Element
Builds an Inkscape namedview containing page elements.
-
#PagesTabular(rows:, cols:, width:, height:, gap:, id: "namedview") ⇒ Array<Array>
Builds a tabular set of Inkscape pages.
-
#symbol!(**attributes) { ... } ⇒ Sevgi::Graphics::Element
Internal symbol which does not show up Symbols Menu.
Instance Method Details
#Group(mod, *args, **kwargs) { ... } ⇒ Sevgi::Graphics::Element
Renders a callable module inside a group.
33 34 35 36 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 33 def Group(mod, *args, **kwargs, &block) kwargs = kwargs.merge(id: F.demodulize(mod).to_sym) unless kwargs.key?(:id) g(**kwargs) { Call(mod, *args, &block) } end |
#InkscapeTemplateInfo(name:, desc: nil, author: nil, date: nil, keywords: nil) ⇒ Sevgi::Graphics::Element
Adds Inkscape template metadata.
15 16 17 18 19 20 21 22 23 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 15 def InkscapeTemplateInfo(name:, desc: nil, author: nil, date: nil, keywords: nil) Element(:"inkscape:_templateinfo") do Element(:"inkscape:_name", name) Element(:"inkscape:_shortdesc", desc) if desc Element(:"inkscape:date", date) if date Element(:"inkscape:author", ) if Element(:"inkscape:_keywords", [*keywords].join(" ")) if keywords end end |
#Layer(mod, *args, **kwargs) { ... } ⇒ Sevgi::Graphics::Element
Renders a callable module inside an Inkscape layer.
46 47 48 49 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 46 def Layer(mod, *args, **kwargs, &block) kwargs = kwargs.merge(id: F.demodulize(mod).to_sym) unless kwargs.key?(:id) layer(**kwargs) { Call(mod, *args, &block) } end |
#layer(**attributes) { ... } ⇒ Sevgi::Graphics::Element
70 71 72 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 70 def layer(**, &block) g("inkscape:groupmode": "layer", **, &block) end |
#Layer!(mod, *args, **kwargs) { ... } ⇒ Sevgi::Graphics::Element
Renders a callable module inside an insensitive Inkscape layer.
59 60 61 62 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 59 def Layer!(mod, *args, **kwargs, &block) kwargs = kwargs.merge(id: F.demodulize(mod).to_sym) unless kwargs.key?(:id) layer!(**kwargs) { Call(mod, *args, &block) } end |
#layer!(**attributes) { ... } ⇒ Sevgi::Graphics::Element
80 81 82 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 80 def layer!(**, &block) layer("sodipodi:insensitive": "true", **, &block) end |
#Pages(*pages, id: "namedview") {|page| ... } ⇒ Sevgi::Graphics::Element
Builds an Inkscape namedview containing page elements.
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 91 def Pages(*pages, id: "namedview", **, &block) Element(:"sodipodi:namedview", id:, **) do pages.each_with_index do |page, i| id = page[:id] || "page-#{i + 1}" x, y, width, height = page.values_at(*%i[x y width height]) element = Element(:"inkscape:page", id:, x:, y:, width:, height:) yield(element) if block end end end |
#PagesTabular(rows:, cols:, width:, height:, gap:, id: "namedview") ⇒ Array<Array>
Builds a tabular set of Inkscape pages.
110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 110 def PagesTabular(rows:, cols:, width:, height:, gap:, id: "namedview", **) [].tap do |matrix| Element(:"sodipodi:namedview", id:) do rows.times do |row| cols.times do |col| matrix << (x, y, label = col * (width + gap), row * (height + gap), "#{row + 1}x#{col + 1}") Element(:"inkscape:page", id: "pageview-#{label}", x:, y:, width:, height:, **) end end end end end |
#symbol!(**attributes) { ... } ⇒ Sevgi::Graphics::Element
Internal symbol which does not show up Symbols Menu
130 131 132 133 134 135 136 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 130 def symbol!(**, &block) if Is?(:defs) g(role: "inkscape:symbol", **, &block) else defs { g(role: "inkscape:symbol", **, &block) } end end |