Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
roktas committed Sep 5, 2024
1 parent 783bc5c commit fb0fb0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions graphics/lib/sevgi/graphics/internal/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def out(content, *paths, update: false, &filter)
output = "#{content.chomp}\n"

::File.write(file, output) if !update || changed?(file, output, &filter)
file
end
end

Expand Down
18 changes: 18 additions & 0 deletions graphics/lib/sevgi/graphics/mixtures/inkscape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ def layer(**, &block)
g("inkscape:groupmode": "layer", "sodipodi:insensitive": "true", **, &block)
end

def Pages(rows:, cols:, width:, height:, gap:, id: "namedview", **) # rubocop:disable Metrics/MethodLength
[].tap do |matrix|
Element(:"sodipodi:namedview", id:) do
rows.times do |row|
cols.times do |col|
matrix << (x, y, label = col * (height + gap), row * (width + gap), "#{row + 1}x#{col + 1}")
Element(:"inkscape:page", id: "pageview-#{label}", x:, y:, width:, height:, **)
end
end
end
end
end

# Internal symbol which does not show up Symbols Menu
def symbol!(**, &block)
if Is?(:defs)
Expand All @@ -36,6 +49,11 @@ def symbol!(**, &block)
defs { g(role: "inkscape:symbol", **, &block) }
end
end

def Symbol!(mod, *args, **kwargs, &block)
kwargs = kwargs.merge(id: F.demodulize(mod).to_sym) unless kwargs.key?(:id)
symbol!(**kwargs) { Call(mod, *args, &block) }
end
end
end
end
Expand Down

0 comments on commit fb0fb0a

Please sign in to comment.