sevgi-graphics 0.73.2 → 0.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE +5 -0
- data/README.md +37 -0
- data/lib/sevgi/graphics/attribute.rb +82 -10
- data/lib/sevgi/graphics/auxiliary/canvas.rb +153 -0
- data/lib/sevgi/graphics/auxiliary/content.rb +157 -0
- data/lib/sevgi/graphics/auxiliary/margin.rb +93 -0
- data/lib/sevgi/graphics/auxiliary/paper.rb +163 -0
- data/lib/sevgi/graphics/auxiliary.rb +7 -0
- data/lib/sevgi/graphics/document/base.rb +6 -0
- data/lib/sevgi/graphics/document/default.rb +1 -0
- data/lib/sevgi/graphics/document/html.rb +1 -0
- data/lib/sevgi/graphics/document/inkscape.rb +1 -0
- data/lib/sevgi/graphics/document/minimal.rb +1 -0
- data/lib/sevgi/graphics/document.rb +205 -13
- data/lib/sevgi/graphics/element.rb +69 -9
- data/lib/sevgi/graphics/mixtures/call.rb +62 -4
- data/lib/sevgi/graphics/mixtures/core.rb +146 -25
- data/lib/sevgi/graphics/mixtures/duplicate.rb +47 -3
- data/lib/sevgi/graphics/mixtures/export.rb +31 -6
- data/lib/sevgi/graphics/mixtures/hatch.rb +24 -3
- data/lib/sevgi/graphics/mixtures/identify.rb +26 -2
- data/lib/sevgi/graphics/mixtures/include.rb +40 -4
- data/lib/sevgi/graphics/mixtures/inkscape.rb +51 -5
- data/lib/sevgi/graphics/mixtures/lint.rb +12 -0
- data/lib/sevgi/graphics/mixtures/polyfills.rb +11 -0
- data/lib/sevgi/graphics/mixtures/rdf.rb +40 -1
- data/lib/sevgi/graphics/mixtures/render.rb +136 -14
- data/lib/sevgi/graphics/mixtures/save.rb +21 -3
- data/lib/sevgi/graphics/mixtures/symbols.rb +7 -0
- data/lib/sevgi/graphics/mixtures/tile.rb +52 -9
- data/lib/sevgi/graphics/mixtures/transform.rb +54 -16
- data/lib/sevgi/graphics/mixtures/underscore.rb +21 -1
- data/lib/sevgi/graphics/mixtures/validate.rb +15 -1
- data/lib/sevgi/graphics/mixtures/wrappers.rb +54 -17
- data/lib/sevgi/graphics/mixtures.rb +35 -3
- data/lib/sevgi/graphics/version.rb +2 -1
- data/lib/sevgi/graphics.rb +71 -5
- metadata +12 -9
- data/lib/sevgi/graphics/auxilary/canvas.rb +0 -72
- data/lib/sevgi/graphics/auxilary/content.rb +0 -81
- data/lib/sevgi/graphics/auxilary/margin.rb +0 -49
- data/lib/sevgi/graphics/auxilary/paper.rb +0 -95
- data/lib/sevgi/graphics/auxilary.rb +0 -7
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Sevgi
|
|
4
|
-
module Graphics
|
|
5
|
-
class Content
|
|
6
|
-
attr_reader :content
|
|
7
|
-
|
|
8
|
-
def initialize(content) = @content = content
|
|
9
|
-
|
|
10
|
-
def render(_renderer, _depth) = raise NoMethodError, "#{self.class}#render must be implemented"
|
|
11
|
-
|
|
12
|
-
def to_s = content.to_s
|
|
13
|
-
|
|
14
|
-
def self.cdata(...) = CData.new(...)
|
|
15
|
-
|
|
16
|
-
def self.contents(*args) = args.map { it.is_a?(Content) ? it : encoded(it) }
|
|
17
|
-
|
|
18
|
-
def self.css(...) = CSS.new(...)
|
|
19
|
-
|
|
20
|
-
def self.encoded(...) = Encoded.new(...)
|
|
21
|
-
|
|
22
|
-
def self.text(contents) = Array(contents).join("\n")
|
|
23
|
-
|
|
24
|
-
def self.verbatim(...) = Verbatim.new(...)
|
|
25
|
-
|
|
26
|
-
class CData < Content
|
|
27
|
-
def render(renderer, depth)
|
|
28
|
-
depth += 1
|
|
29
|
-
|
|
30
|
-
renderer.append(depth, "<![CDATA[")
|
|
31
|
-
renderer.append(depth + 1, *Array(content))
|
|
32
|
-
renderer.append(depth, "]]>")
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
class CSS < Content
|
|
37
|
-
def initialize(content)
|
|
38
|
-
ArgumentError.("CSS content must be a hash: #{content}") unless content.is_a?(::Hash)
|
|
39
|
-
|
|
40
|
-
super
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# rubocop:disable Metrics/MethodLength
|
|
44
|
-
def render(renderer, depth)
|
|
45
|
-
depth += 1
|
|
46
|
-
|
|
47
|
-
renderer.append(depth, "<![CDATA[")
|
|
48
|
-
|
|
49
|
-
depth += 1
|
|
50
|
-
content.each do |rule, styles|
|
|
51
|
-
case styles
|
|
52
|
-
when ::Hash
|
|
53
|
-
renderer.append(depth, "#{rule} {")
|
|
54
|
-
renderer.append(depth + 1, *styles.map { |key, value| "#{key}: #{value};" })
|
|
55
|
-
renderer.append(depth, "}")
|
|
56
|
-
when ::String, ::Symbol, ::Numeric
|
|
57
|
-
renderer.append(depth, "#{rule}: #{styles};")
|
|
58
|
-
else
|
|
59
|
-
ArgumentError.("Malformed style: #{styles}")
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
depth -= 1
|
|
64
|
-
|
|
65
|
-
renderer.append(depth, "]]>")
|
|
66
|
-
end
|
|
67
|
-
# rubocop:enable Metrics/MethodLength
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
class Encoded < Content
|
|
71
|
-
def to_s = content.encode(xml: :text)
|
|
72
|
-
|
|
73
|
-
def render(renderer, depth) = renderer.append(depth + 1, to_s)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
class Verbatim < Content
|
|
77
|
-
def render(renderer, depth) = renderer.append(depth + 1, to_s)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Sevgi
|
|
4
|
-
module Graphics
|
|
5
|
-
Margin = Data.define(:top, :right, :bottom, :left) do
|
|
6
|
-
include Comparable
|
|
7
|
-
|
|
8
|
-
def initialize(top: nil, right: nil, bottom: nil, left: nil)
|
|
9
|
-
case [top, right, bottom, left]
|
|
10
|
-
in [Numeric, Numeric, Numeric, Numeric]
|
|
11
|
-
nil
|
|
12
|
-
in [Numeric, Numeric, Numeric, NilClass]
|
|
13
|
-
left = right
|
|
14
|
-
in [Numeric, Numeric, NilClass, NilClass]
|
|
15
|
-
bottom, left = top, right
|
|
16
|
-
in [Numeric, NilClass, NilClass, NilClass]
|
|
17
|
-
bottom, left, right = top, top, top
|
|
18
|
-
in [NilClass, NilClass, NilClass, NilClass]
|
|
19
|
-
top, bottom, left, right = 0, 0, 0, 0
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
super(top: Float(top), right: Float(right), bottom: Float(bottom), left: Float(left))
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def <=>(other) = deconstruct <=> other.deconstruct
|
|
26
|
-
|
|
27
|
-
def change(h, v) = self.class[top + v, right + h, bottom + v, left + h]
|
|
28
|
-
|
|
29
|
-
def eql?(other) = self.class == other.class && deconstruct == other.deconstruct
|
|
30
|
-
|
|
31
|
-
def hash = [self.class, *deconstruct].hash
|
|
32
|
-
|
|
33
|
-
def htotal = left + right
|
|
34
|
-
|
|
35
|
-
def vtotal = top + bottom
|
|
36
|
-
|
|
37
|
-
alias_method :==, :eql?
|
|
38
|
-
alias_method :to_a, :deconstruct
|
|
39
|
-
|
|
40
|
-
def self.margin(array)
|
|
41
|
-
self[
|
|
42
|
-
*(array = Array(array)[0...(size = Margin.members.size)]).fill(nil, array.size, size - array.size)
|
|
43
|
-
]
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def self.zero = (@zero ||= self[0.0, 0.0, 0.0, 0.0])
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Sevgi
|
|
4
|
-
module Graphics
|
|
5
|
-
Paper = Data.define(:width, :height, :unit, :name) do
|
|
6
|
-
include Comparable
|
|
7
|
-
|
|
8
|
-
def initialize(width:, height:, unit: "mm", name: :custom)
|
|
9
|
-
super(width: Float(width), height: Float(height), unit: unit.to_sym, name: name.to_sym)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def <=>(other) = deconstruct <=> other.deconstruct
|
|
13
|
-
|
|
14
|
-
def eql?(other) = self.class == other.class && deconstruct == other.deconstruct
|
|
15
|
-
|
|
16
|
-
def hash = [self.class, *deconstruct].hash
|
|
17
|
-
|
|
18
|
-
def longest = [width, height].max
|
|
19
|
-
|
|
20
|
-
def shortest = [width, height].min
|
|
21
|
-
|
|
22
|
-
alias_method :==, :eql?
|
|
23
|
-
|
|
24
|
-
def self.define!(name, ...)
|
|
25
|
-
raise ArgumentError, "Paper already defined: #{name}" if exist?(name)
|
|
26
|
-
|
|
27
|
-
define(name, ...)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def self.exist?(name) = respond_to?(name)
|
|
31
|
-
|
|
32
|
-
def self.define(name, **spec)
|
|
33
|
-
singleton_class.attr_reader(name)
|
|
34
|
-
instance_variable_set("@#{name}", new(name:, **spec))
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
a0: [841, 1189, "mm"],
|
|
39
|
-
a1: [594, 841, "mm"],
|
|
40
|
-
a2: [420, 594, "mm"],
|
|
41
|
-
a3: [297, 420, "mm"],
|
|
42
|
-
a4: [210, 297, "mm"],
|
|
43
|
-
a5: [148, 210, "mm"],
|
|
44
|
-
a6: [105, 148, "mm"],
|
|
45
|
-
a7: [740, 105, "mm"],
|
|
46
|
-
a8: [520, 74, "mm"],
|
|
47
|
-
a9: [370, 52, "mm"],
|
|
48
|
-
a10: [260, 37, "mm"],
|
|
49
|
-
|
|
50
|
-
b0: [1000, 1414, "mm"],
|
|
51
|
-
b1: [707, 1000, "mm"],
|
|
52
|
-
b2: [500, 707, "mm"],
|
|
53
|
-
b3: [353, 500, "mm"],
|
|
54
|
-
b4: [250, 353, "mm"],
|
|
55
|
-
b5: [176, 250, "mm"],
|
|
56
|
-
b6: [125, 176, "mm"],
|
|
57
|
-
b7: [88, 125, "mm"],
|
|
58
|
-
b8: [62, 88, "mm"],
|
|
59
|
-
b9: [44, 62, "mm"],
|
|
60
|
-
b10: [31, 44, "mm"],
|
|
61
|
-
|
|
62
|
-
c0: [917, 1297, "mm"],
|
|
63
|
-
c1: [648, 917, "mm"],
|
|
64
|
-
c2: [458, 648, "mm"],
|
|
65
|
-
c3: [324, 458, "mm"],
|
|
66
|
-
c4: [229, 324, "mm"],
|
|
67
|
-
c5: [162, 229, "mm"],
|
|
68
|
-
c6: [114, 162, "mm"],
|
|
69
|
-
c7: [81, 114, "mm"],
|
|
70
|
-
c8: [57, 81, "mm"],
|
|
71
|
-
c9: [40, 57, "mm"],
|
|
72
|
-
c10: [28, 40, "mm"],
|
|
73
|
-
|
|
74
|
-
business: [85, 55, "mm"],
|
|
75
|
-
large: [130, 210, "mm"],
|
|
76
|
-
passport: [88, 125, "mm"],
|
|
77
|
-
pocket: [90, 140, "mm"],
|
|
78
|
-
travelers: [110, 210, "mm"],
|
|
79
|
-
us: [216, 279, "mm"],
|
|
80
|
-
xlarge: [190, 250, "mm"],
|
|
81
|
-
|
|
82
|
-
icon16: [16, 16, "px"],
|
|
83
|
-
icon32: [32, 32, "px"],
|
|
84
|
-
icon64: [64, 64, "px"],
|
|
85
|
-
icon128: [128, 128, "px"],
|
|
86
|
-
icon256: [256, 256, "px"],
|
|
87
|
-
icon512: [512, 512, "px"]
|
|
88
|
-
}.each { |name, (width, height, unit)| define(name, width:, height:, unit:) }
|
|
89
|
-
|
|
90
|
-
class << self
|
|
91
|
-
alias_method :default, :a4
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|