ea 0.6.38 → 0.6.39
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/lib/ea/svg/ea_emitter/bounds_calculator.rb +6 -3
- data/lib/ea/svg/ea_emitter/canvas.rb +14 -8
- data/lib/ea/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a248fe1db576d5cb2060f82b4cc791cf2b5b08f0088cd07528e26ba8129f7ad
|
|
4
|
+
data.tar.gz: 6a05254e2e2ccb1c2a350ef6d4a55371dd8bf1b51c2ccdd30b5a9d9b6e41c1d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 845cf690c2d47b741f2fcfc5912cb1bd2ffdd5ca0ba602db894572dcccbe8104e32f0614b88e340cc686ce608180558d8e9210d9ba93fcafec0e01e59ab9a022
|
|
7
|
+
data.tar.gz: 24dc485cf1ca1c3ce721039e37bc8fae958e7f6f2b057efff453d3375db6f86ef8435dc03aea515b69afe2626ff097c43ca148a3412ea47a53e2941c1cfe1369
|
|
@@ -38,6 +38,8 @@ module Ea
|
|
|
38
38
|
@model_index = model_index
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
attr_reader :effective_inset_left
|
|
42
|
+
|
|
41
43
|
def compute
|
|
42
44
|
points = element_points
|
|
43
45
|
return [0, 0, 1, 1] if points.empty?
|
|
@@ -48,12 +50,13 @@ module Ea
|
|
|
48
50
|
min_y = ys.min || 0
|
|
49
51
|
# When the leftmost element touches stored x=0 the left
|
|
50
52
|
# inset is 30, not 35 (all five such sample diagrams are
|
|
51
|
-
# exactly 5px narrower; min_x>0 diagrams keep 35).
|
|
52
|
-
|
|
53
|
+
# exactly 5px narrower; min_x>0 diagrams keep 35). Canvas
|
|
54
|
+
# translation must use the same value.
|
|
55
|
+
@effective_inset_left = min_x.zero? ? INSET_LEFT - 5 : INSET_LEFT
|
|
53
56
|
[
|
|
54
57
|
min_x,
|
|
55
58
|
min_y,
|
|
56
|
-
(xs.max - min_x) +
|
|
59
|
+
(xs.max - min_x) + @effective_inset_left + INSET_RIGHT,
|
|
57
60
|
(ys.max - min_y) + INSET_TOP + INSET_BOTTOM
|
|
58
61
|
]
|
|
59
62
|
end
|
|
@@ -21,15 +21,17 @@ module Ea
|
|
|
21
21
|
# against the maintenance diagram.
|
|
22
22
|
PX_PER_CM = 37.795275591
|
|
23
23
|
FRAME_INSET_LEFT = 35
|
|
24
|
+
INSET_TOUCHING_ORIGIN = 30
|
|
24
25
|
FRAME_INSET_TOP = 40
|
|
25
26
|
|
|
26
|
-
attr_reader :min_x, :min_y, :width, :height
|
|
27
|
+
attr_reader :min_x, :min_y, :width, :height, :inset_left
|
|
27
28
|
|
|
28
|
-
def initialize(min_x:, min_y:, width:, height:)
|
|
29
|
+
def initialize(min_x:, min_y:, width:, height:, inset_left: FRAME_INSET_LEFT)
|
|
29
30
|
@min_x = min_x
|
|
30
31
|
@min_y = min_y
|
|
31
32
|
@width = width
|
|
32
33
|
@height = height
|
|
34
|
+
@inset_left = inset_left
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
# Build a Canvas for a diagram by running the bound
|
|
@@ -37,9 +39,10 @@ module Ea
|
|
|
37
39
|
# element bounds needed) for callers that only need a
|
|
38
40
|
# frame-size estimate.
|
|
39
41
|
def self.from(diagram, model_index: nil)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
new(min_x: min_x, min_y: min_y, width: width, height: height
|
|
42
|
+
bc = BoundsCalculator.new(diagram, model_index: model_index)
|
|
43
|
+
min_x, min_y, width, height = bc.compute
|
|
44
|
+
new(min_x: min_x, min_y: min_y, width: width, height: height,
|
|
45
|
+
inset_left: bc.effective_inset_left || FRAME_INSET_LEFT)
|
|
43
46
|
end
|
|
44
47
|
|
|
45
48
|
# Second-pass canvas over the DRAWN extents captured by the
|
|
@@ -62,11 +65,14 @@ module Ea
|
|
|
62
65
|
max_y = (pts + extra).map(&:last).max || 0
|
|
63
66
|
return from(diagram, model_index: model_index) if pts.empty?
|
|
64
67
|
|
|
68
|
+
inset_left = min_x.zero? ? INSET_TOUCHING_ORIGIN
|
|
69
|
+
: BoundsCalculator::INSET_LEFT
|
|
65
70
|
new(min_x: min_x, min_y: min_y,
|
|
66
|
-
width: (max_x - min_x) +
|
|
71
|
+
width: (max_x - min_x) + inset_left +
|
|
67
72
|
BoundsCalculator::INSET_RIGHT,
|
|
68
73
|
height: (max_y - min_y) + BoundsCalculator::INSET_TOP +
|
|
69
|
-
BoundsCalculator::INSET_BOTTOM
|
|
74
|
+
BoundsCalculator::INSET_BOTTOM,
|
|
75
|
+
inset_left: inset_left)
|
|
70
76
|
end
|
|
71
77
|
|
|
72
78
|
def view_box
|
|
@@ -85,7 +91,7 @@ module Ea
|
|
|
85
91
|
# the content area from the canvas top-left by
|
|
86
92
|
# FRAME_INSET_LEFT/TOP.
|
|
87
93
|
def translate_x(x)
|
|
88
|
-
x - min_x +
|
|
94
|
+
x - min_x + inset_left
|
|
89
95
|
end
|
|
90
96
|
|
|
91
97
|
def translate_y(y)
|
data/lib/ea/version.rb
CHANGED