diff --git a/graphics/lib/sevgi/graphics/internal/file.rb b/graphics/lib/sevgi/graphics/internal/file.rb index 90d3e47..a6f6f59 100644 --- a/graphics/lib/sevgi/graphics/internal/file.rb +++ b/graphics/lib/sevgi/graphics/internal/file.rb @@ -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 diff --git a/graphics/lib/sevgi/graphics/mixtures/inkscape.rb b/graphics/lib/sevgi/graphics/mixtures/inkscape.rb index 4721eef..c54cddc 100644 --- a/graphics/lib/sevgi/graphics/mixtures/inkscape.rb +++ b/graphics/lib/sevgi/graphics/mixtures/inkscape.rb @@ -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) @@ -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