aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHatem ElKharashy <hatem.elkharashy@qt.io>2024-03-28 15:58:50 +0200
committerHatem ElKharashy <hatem.elkharashy@qt.io>2024-04-18 15:42:40 +0300
commit5ce8fd73430c86cc0b52f8eaf5dbfc000605b6a0 (patch)
tree3c96e65750bbbdba59faa9bfad112fbc4133401a /tests
parentf1051cb48243ab27a44ec4f30259fa38116c2783 (diff)
VectorImage: tweak the default pen and fix opacity behavior
There are many changes done in this commit, which either prepare the generator for features implemented in the future or fix the current behavior. The default QPen in the style resolver class is changed to match the default QPen used by Qt Svg module, because this default pen sets the CapStyle and JoinStyle. This is going to be important when implementing those features in VectorImage. There were also some issues with the opacity for several reasons. The first one was because "transparent" color was not taken into account. This is not part of the SVG standard, but the browsers, as well as Qt Svg, implements it anyway. Although we get the correct color from style resolver, the currentFillColor function overrides the opacity with the fillOpacity from the extra states. Finally, this takes us to the other issue with opacity. The fill and stroke attributes define an RGB color or a paint server like gradients. The opacity can be controlled on those using fill-opacity and stroke-opacity. Those opacities can be applied on gradient as well and not only on normal colors. This change adds new member variables in the NodeInfo structs to handle the fillOpacity and strokeOpacity. Change-Id: I267126aecbab488700f6f7490634341893b21a1c Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/svg/data/painting/fill_color.svg7
-rw-r--r--tests/manual/svg/data/painting/fill_gradient.svg15
-rw-r--r--tests/manual/svg/data/painting/fill_stroke.svg3
-rw-r--r--tests/manual/svg/data/painting/stroke_color.svg7
4 files changed, 32 insertions, 0 deletions
diff --git a/tests/manual/svg/data/painting/fill_color.svg b/tests/manual/svg/data/painting/fill_color.svg
new file mode 100644
index 0000000000..7772839369
--- /dev/null
+++ b/tests/manual/svg/data/painting/fill_color.svg
@@ -0,0 +1,7 @@
+<svg viewBox="0 0 400 1000" xmlns="http://www.w3.org/2000/svg">
+ <g fill-opacity="0.3">
+ <rect width="300" height="300" fill="red"/>
+ </g>
+ <rect transform="translate(0, 350)" width="300" height="300" fill="red"/>
+ <rect transform="translate(0, 700)" width="300" height="300" fill="transparent" stroke="yellow" stroke-width="5"/>
+</svg>
diff --git a/tests/manual/svg/data/painting/fill_gradient.svg b/tests/manual/svg/data/painting/fill_gradient.svg
new file mode 100644
index 0000000000..5fefb40442
--- /dev/null
+++ b/tests/manual/svg/data/painting/fill_gradient.svg
@@ -0,0 +1,15 @@
+<svg viewBox="0 0 200 400" xmlns="http://www.w3.org/2000/svg">
+ <defs>
+ <linearGradient id="grad1" x1="0%" x2="100%" y1="0%" y2="0%">
+ <stop offset="0%" stop-color="green" stop-opacity="0.8"/>
+ <stop offset="100%" stop-color="red" stop-opacity="0.8"/>
+ </linearGradient>
+ <linearGradient id="grad2" x1="0%" x2="100%" y1="0%" y2="0%">
+ <stop offset="0%" stop-color="green"/>
+ <stop offset="100%" stop-color="red"/>
+ </linearGradient>
+ </defs>
+ <ellipse cx="100" cy="70" rx="85" ry="55" fill="url(#grad1)"/>
+ <ellipse cx="100" cy="200" rx="85" ry="55" fill="url(#grad2)" fill-opacity="0.8"/>
+ <ellipse cx="100" cy="330" rx="85" ry="55" fill="url(#grad1)" fill-opacity="0.5"/>
+</svg>
diff --git a/tests/manual/svg/data/painting/fill_stroke.svg b/tests/manual/svg/data/painting/fill_stroke.svg
new file mode 100644
index 0000000000..8069faf516
--- /dev/null
+++ b/tests/manual/svg/data/painting/fill_stroke.svg
@@ -0,0 +1,3 @@
+<svg viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg">
+ <rect transform="translate(50, 50)" width="400" height="400" fill="green" stroke="black" fill-opacity="0.5" stroke-opacity="0.2" stroke-width="20"/>
+</svg> \ No newline at end of file
diff --git a/tests/manual/svg/data/painting/stroke_color.svg b/tests/manual/svg/data/painting/stroke_color.svg
new file mode 100644
index 0000000000..d77755e1fd
--- /dev/null
+++ b/tests/manual/svg/data/painting/stroke_color.svg
@@ -0,0 +1,7 @@
+<svg viewBox="0 0 400 1000" xmlns="http://www.w3.org/2000/svg">
+ <g stroke-opacity="0.3">
+ <rect transform="translate(25, 25)" width="300" height="300" stroke="red" stroke-width="10"/>
+ </g>
+ <rect transform="translate(25, 350)" width="300" height="300" stroke="red" stroke-width="10"/>
+ <rect transform="translate(25, 700)" width="300" height="300" fill="yellow" stroke="transparent"/>
+</svg>