idml 0.2.3 → 0.2.5
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/Gemfile.lock +5 -12
- data/TODO.pdf/66-gradient-shadings-pdfrb.md +24 -0
- data/idml.gemspec +1 -1
- data/lib/idml/render/renderers/rectangle_renderer.rb +43 -0
- data/lib/idml/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d870be70e870df44bf1b0fcd658e5d5cc04b877e00d195f40666027c4a64b12
|
|
4
|
+
data.tar.gz: f3b5e9f8ea4e3eb181f66795746a090d4994c5ce7ea32cbf210b8366c9d801fa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2bbbd17c0ef7958732c45ffc848f4e0ad89ac27406f79f42af769d49ce9f5dc88584b5e7b45e462a77d85c663b383113c11b8cd824942320de7baa57bf3ec77d
|
|
7
|
+
data.tar.gz: b6e86c5e3d233aa80ea12302db92781dac9d08e6cc55c28aa83858bc73b18875f78f7bebdf67e077c9c7fa462d617e8401763b421cf45a9c7e21d0663516eb8a
|
data/Gemfile.lock
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
idml (0.2.
|
|
4
|
+
idml (0.2.5)
|
|
5
5
|
bigdecimal
|
|
6
6
|
fontisan
|
|
7
7
|
lutaml-model (~> 0.8.18)
|
|
8
|
-
pdfrb
|
|
8
|
+
pdfrb
|
|
9
9
|
rubyzip
|
|
10
10
|
thor
|
|
11
11
|
|
|
12
12
|
PATH
|
|
13
13
|
remote: /Users/mulgogi/src/claricle/pdfrb
|
|
14
14
|
specs:
|
|
15
|
-
pdfrb (0.
|
|
16
|
-
lutaml-model (>= 0.7.0)
|
|
15
|
+
pdfrb (0.4.0)
|
|
17
16
|
thor
|
|
18
17
|
|
|
19
18
|
GEM
|
|
@@ -42,7 +41,6 @@ GEM
|
|
|
42
41
|
ffi (1.17.4-arm-linux-gnu)
|
|
43
42
|
ffi (1.17.4-arm-linux-musl)
|
|
44
43
|
ffi (1.17.4-arm64-darwin)
|
|
45
|
-
ffi (1.17.4-x64-mingw-ucrt)
|
|
46
44
|
ffi (1.17.4-x86_64-darwin)
|
|
47
45
|
ffi (1.17.4-x86_64-linux-gnu)
|
|
48
46
|
ffi (1.17.4-x86_64-linux-musl)
|
|
@@ -83,8 +81,6 @@ GEM
|
|
|
83
81
|
racc (~> 1.4)
|
|
84
82
|
nokogiri (1.19.4-arm64-darwin)
|
|
85
83
|
racc (~> 1.4)
|
|
86
|
-
nokogiri (1.19.4-x64-mingw-ucrt)
|
|
87
|
-
racc (~> 1.4)
|
|
88
84
|
nokogiri (1.19.4-x86_64-darwin)
|
|
89
85
|
racc (~> 1.4)
|
|
90
86
|
nokogiri (1.19.4-x86_64-linux-gnu)
|
|
@@ -165,7 +161,6 @@ PLATFORMS
|
|
|
165
161
|
arm-linux-gnu
|
|
166
162
|
arm-linux-musl
|
|
167
163
|
arm64-darwin
|
|
168
|
-
x64-mingw-ucrt
|
|
169
164
|
x86_64-darwin
|
|
170
165
|
x86_64-linux-gnu
|
|
171
166
|
x86_64-linux-musl
|
|
@@ -199,12 +194,11 @@ CHECKSUMS
|
|
|
199
194
|
ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564
|
|
200
195
|
ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95
|
|
201
196
|
ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b
|
|
202
|
-
ffi (1.17.4-x64-mingw-ucrt) sha256=f6ff9618cfccc494138bddade27aa06c74c6c7bc367a1ea1103d80c2fcb9ed35
|
|
203
197
|
ffi (1.17.4-x86_64-darwin) sha256=aa70390523cf3235096cf64962b709b4cfbd5c082a2cb2ae714eb0fe2ccda496
|
|
204
198
|
ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
|
|
205
199
|
ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e
|
|
206
200
|
fontisan (0.4.45) sha256=2337ca0205f806647b24b8cac57aa34f3769473026ae6f52dc36bde0feed6c62
|
|
207
|
-
idml (0.2.
|
|
201
|
+
idml (0.2.5)
|
|
208
202
|
json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a
|
|
209
203
|
language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
|
|
210
204
|
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
@@ -218,7 +212,6 @@ CHECKSUMS
|
|
|
218
212
|
nokogiri (1.19.4-arm-linux-gnu) sha256=a301313e38bb065d68239e79734bcd6f56fb6efaacebde29e9abf2a4735340ca
|
|
219
213
|
nokogiri (1.19.4-arm-linux-musl) sha256=588923c101bcfa78869734d247d25b598674323e7f22474fc468f6e5647311eb
|
|
220
214
|
nokogiri (1.19.4-arm64-darwin) sha256=a46db9853286e6597b36ebc6953817d15acf3a299583eb3f89fdc6f91dd63527
|
|
221
|
-
nokogiri (1.19.4-x64-mingw-ucrt) sha256=051da97b8eccfdb5444fed40246a35e10d7298b9efe759b4cd25455ea04c587e
|
|
222
215
|
nokogiri (1.19.4-x86_64-darwin) sha256=7fd17057d3e1f00e9954a74b3cd76595d3d4a5ef233b7ed9599047c204f70551
|
|
223
216
|
nokogiri (1.19.4-x86_64-linux-gnu) sha256=379fae440b28915e3f19d752ce2dcf8465ed2b2fbefd2a7ca0dd497bc981a06a
|
|
224
217
|
nokogiri (1.19.4-x86_64-linux-musl) sha256=17dfb7c1fa194ae02fbf7c51a7afc8d278045ab3fdacfd86f91d02d7b274470b
|
|
@@ -226,7 +219,7 @@ CHECKSUMS
|
|
|
226
219
|
paint (2.3.0) sha256=327d623e4038619d5bd99ae5db07973859cd78400c7f0329eea283cef8e83be5
|
|
227
220
|
parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356
|
|
228
221
|
parser (3.3.12.0) sha256=21a6d7f755d5a24dfbdc6e6b772e4e879a52e7631a88bc5a3a134606052c9828
|
|
229
|
-
pdfrb (0.
|
|
222
|
+
pdfrb (0.4.0)
|
|
230
223
|
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
|
|
231
224
|
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
232
225
|
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# TODO PDF 66: Real PDF gradient shadings via pdfrb 0.4.0
|
|
2
|
+
|
|
3
|
+
## Status: DONE
|
|
4
|
+
|
|
5
|
+
## What was implemented
|
|
6
|
+
|
|
7
|
+
RectangleRenderer now uses pdfrb's `Shadings#add_axial` +
|
|
8
|
+
`Canvas#fill_shading` for gradient fills instead of the discrete
|
|
9
|
+
32-rectangle approximation. Produces mathematically smooth gradients
|
|
10
|
+
with zero banding.
|
|
11
|
+
|
|
12
|
+
When FillColor is a Gradient reference:
|
|
13
|
+
1. Look up the Gradient element from Resources/Graphic.xml
|
|
14
|
+
2. Resolve each GradientStop's color via ColorResolver
|
|
15
|
+
3. Create a pdfrb axial shading: `add_axial(from:, to:, stops:)`
|
|
16
|
+
4. Draw the rectangle path and fill with the shading
|
|
17
|
+
|
|
18
|
+
## Acceptance criteria
|
|
19
|
+
|
|
20
|
+
- [x] RectangleRenderer detects Gradient/* fill colors
|
|
21
|
+
- [x] Creates pdfrb axial shading with resolved color stops
|
|
22
|
+
- [x] Uses canvas.fill_shading instead of discrete rectangles
|
|
23
|
+
- [x] Falls back to solid color for non-gradient fills
|
|
24
|
+
- [x] All tests pass
|
data/idml.gemspec
CHANGED
|
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.add_dependency "bigdecimal"
|
|
32
32
|
spec.add_dependency "fontisan"
|
|
33
33
|
spec.add_dependency "lutaml-model", "~> 0.8.18"
|
|
34
|
-
spec.add_dependency "pdfrb"
|
|
34
|
+
spec.add_dependency "pdfrb"
|
|
35
35
|
spec.add_dependency "rubyzip"
|
|
36
36
|
spec.add_dependency "thor"
|
|
37
37
|
|
|
@@ -29,6 +29,11 @@ module Idml
|
|
|
29
29
|
return unless rect.fill_color
|
|
30
30
|
return if rect.fill_color == "Color/None"
|
|
31
31
|
|
|
32
|
+
if GradientResolver.gradient?(rect.fill_color)
|
|
33
|
+
render_gradient_fill(canvas, rect, context, box)
|
|
34
|
+
return
|
|
35
|
+
end
|
|
36
|
+
|
|
32
37
|
color = context.color_resolver&.resolve(rect.fill_color)
|
|
33
38
|
return unless color
|
|
34
39
|
|
|
@@ -38,6 +43,44 @@ module Idml
|
|
|
38
43
|
end
|
|
39
44
|
private_class_method :render_fill
|
|
40
45
|
|
|
46
|
+
def self.render_gradient_fill(canvas, rect, context, box)
|
|
47
|
+
stops = gradient_stops_for(rect, context)
|
|
48
|
+
return unless stops&.length&.>=(2)
|
|
49
|
+
|
|
50
|
+
shading = canvas.document.shadings.add_axial(
|
|
51
|
+
from: [box[:x], box[:y] + box[:height]],
|
|
52
|
+
to: [box[:x] + box[:width], box[:y]],
|
|
53
|
+
stops: stops,
|
|
54
|
+
)
|
|
55
|
+
canvas.rectangle(box[:x], box[:y], box[:width], box[:height])
|
|
56
|
+
canvas.fill_shading(shading)
|
|
57
|
+
end
|
|
58
|
+
private_class_method :render_gradient_fill
|
|
59
|
+
|
|
60
|
+
def self.gradient_stops_for(rect, context)
|
|
61
|
+
graphic = context.package&.graphic
|
|
62
|
+
return nil unless graphic
|
|
63
|
+
|
|
64
|
+
gradient = graphic.gradient.find do |g|
|
|
65
|
+
g.self_attr == rect.fill_color
|
|
66
|
+
end
|
|
67
|
+
return nil unless gradient
|
|
68
|
+
return nil unless gradient.gradient_stop.length >= 2
|
|
69
|
+
|
|
70
|
+
gradient_stops(gradient, context)
|
|
71
|
+
end
|
|
72
|
+
private_class_method :gradient_stops_for
|
|
73
|
+
|
|
74
|
+
def self.gradient_stops(gradient, context)
|
|
75
|
+
gradient.gradient_stop.filter_map do |stop|
|
|
76
|
+
color = context.color_resolver&.resolve(stop.stop_color)
|
|
77
|
+
next unless color
|
|
78
|
+
|
|
79
|
+
[stop.location || 0.0, ColorHelper.to_canvas(color)]
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
private_class_method :gradient_stops
|
|
83
|
+
|
|
41
84
|
def self.render_stroke(canvas, rect, context, box)
|
|
42
85
|
return unless strokeable?(rect)
|
|
43
86
|
|
data/lib/idml/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: idml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose
|
|
@@ -57,14 +57,14 @@ dependencies:
|
|
|
57
57
|
requirements:
|
|
58
58
|
- - ">="
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 0
|
|
60
|
+
version: '0'
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 0
|
|
67
|
+
version: '0'
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: rubyzip
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -206,6 +206,7 @@ files:
|
|
|
206
206
|
- TODO.pdf/63-replace-fontmetrics-with-pdfrb.md
|
|
207
207
|
- TODO.pdf/64-pipeline-cli-optimizations.md
|
|
208
208
|
- TODO.pdf/65-pdfrb-019-integration.md
|
|
209
|
+
- TODO.pdf/66-gradient-shadings-pdfrb.md
|
|
209
210
|
- TODO.pdf/README.md
|
|
210
211
|
- exe/idml
|
|
211
212
|
- idml.gemspec
|