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, &block) ⇒ 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, &block) ⇒ 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, &block) ⇒ 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", &block) ⇒ 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, &block) ⇒ Sevgi::Graphics::Element
Renders a callable module inside a group.
31 32 33 34 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 31 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, &block) ⇒ Sevgi::Graphics::Element
Renders a callable module inside an Inkscape layer.
42 43 44 45 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 42 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
62 63 64 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 62 def layer(**, &block) g("inkscape:groupmode": "layer", **, &block) end |
#Layer!(mod, *args, **kwargs, &block) ⇒ Sevgi::Graphics::Element
Renders a callable module inside an insensitive Inkscape layer.
53 54 55 56 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 53 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) layer("sodipodi:insensitive": "true", **, &block) end |
#Pages(*pages, id: "namedview", &block) ⇒ Sevgi::Graphics::Element
Builds an Inkscape namedview containing page elements.
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 78 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.
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 97 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
115 116 117 118 119 120 121 |
# File 'lib/sevgi/graphics/mixtures/inkscape.rb', line 115 def symbol!(**, &block) if Is?(:defs) g(role: "inkscape:symbol", **, &block) else defs { g(role: "inkscape:symbol", **, &block) } end end |