summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-03-21 13:13:15 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2023-03-21 15:53:06 +0000
commit808c5bf66370f78f36e98887db0848ee7e55bb3a (patch)
tree11ddcb034efd1d32663a774a85797fff390762e8 /svx
parent5ccbdcf182851375486386c0df8bb3f04cf2f9cd (diff)
MCGR: Model data changes for ColorSteps (II)
The biggest change here is to allow multiple ColorStops with the same Offset. That allows to define gradients with 'hard' color changes at any place using two ColorStops with the same Offset and different Colors. This required quite some adaptions, but works well. Also removed in this context checking for all Colors being the same to not mix up things. Also works well. Also changed the need for having Start/EndColors AKA ColorStops for 0.0 and 1.0 in place, instead 'imply' the 1st ColorStop to also define the StartColor and the last one the EndColor. This allows e.g. Gradient definitions with two GradientStops at the same Offset e.g. 0.5 with different colors to already define a full Gradient. Also added a tooling method to reverse ColorSteps, which changes the order and mirrors the Offsets (what even keeps an existing sort valid). This is useful e.g. for GradientAxial which is the only one where for decomposition the Gradient had to be interpreted 'reverse' since it's defined from center to edge, but for creating correct filled polygons to represent this the inverse order had to be used, creating polygons from edge to center. This led to 'wild' code for this one of six cases and prevented unifications with the other cases (also made your brain flip). Thus I adapted this now to use the reversed ColorSteps consequently, and the same principle loops than the other implementations to make things easier for the future and to use common tooling. Change-Id: If2943348d17d5b9cd165f4d78f22638a1dff5237 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149208 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/sdr/primitive2d/sdrattributecreator.cxx75
1 files changed, 67 insertions, 8 deletions
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
index 7409c4017202..475a0916f444 100644
--- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx
+++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
@@ -494,28 +494,39 @@ namespace drawinglayer::primitive2d
case 2:
{
// single added in-between, no change of start/end
+ aColorStops.clear();
+ aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 0.0, 0.0)); // red
aColorStops.emplace_back(0.5, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
+ aColorStops.emplace_back(1.0, basegfx::BColor(0.0, 0.0, 1.0)); // blue
break;
}
case 3:
{
- // check additional StartColor, the one given directly has to win
+ // check additional StartColor, the second one has to win
+ aColorStops.clear();
+ aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 0.0, 0.0)); // red
aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
+ aColorStops.emplace_back(1.0, basegfx::BColor(0.0, 0.0, 1.0)); // blue
break;
}
case 4:
{
- // check additional EndColor, the one given directly has to win
- // due this one being added *after* the original one
+ // check additional EndColor, the first one has to win
+ aColorStops.clear();
+ aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 0.0, 0.0)); // red
aColorStops.emplace_back(1.0, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
+ aColorStops.emplace_back(1.0, basegfx::BColor(0.0, 0.0, 1.0)); // blue
break;
}
case 5:
{
// check invalid color (too low index), has to be ignored
+ aColorStops.clear();
+ aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ aColorStops.emplace_back(1.0, basegfx::BColor(0.0, 0.0, 1.0)); // blue
aColorStops.emplace_back(-1.0, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
break;
}
@@ -523,6 +534,9 @@ namespace drawinglayer::primitive2d
case 6:
{
// check invalid color (too high index), has to be ignored
+ aColorStops.clear();
+ aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ aColorStops.emplace_back(1.0, basegfx::BColor(0.0, 0.0, 1.0)); // blue
aColorStops.emplace_back(2.0, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
break;
}
@@ -530,33 +544,45 @@ namespace drawinglayer::primitive2d
case 7:
{
// check in-between single-color section
+ aColorStops.clear();
+ aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 0.0, 0.0)); // red
aColorStops.emplace_back(0.3, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
aColorStops.emplace_back(0.7, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
+ aColorStops.emplace_back(1.0, basegfx::BColor(0.0, 0.0, 1.0)); // blue
break;
}
case 8:
{
// check in-between single-color sections
+ aColorStops.clear();
+ aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 0.0, 0.0)); // red
aColorStops.emplace_back(0.2, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
aColorStops.emplace_back(0.4, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
- aColorStops.emplace_back(0.5, aXGradient.GetColorStops().front().getStopColor());
+ aColorStops.emplace_back(0.5, basegfx::BColor(1.0, 0.0, 0.0)); // red
aColorStops.emplace_back(0.6, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
aColorStops.emplace_back(0.8, basegfx::BColor(1.0, 1.0, 0.0)); // yellow@50%
+ aColorStops.emplace_back(1.0, basegfx::BColor(0.0, 0.0, 1.0)); // blue
break;
}
case 9:
{
// check single-color start area
- aColorStops.emplace_back(0.6, aXGradient.GetColorStops().front().getStopColor());
+ aColorStops.clear();
+ aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ aColorStops.emplace_back(0.6, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ aColorStops.emplace_back(1.0, basegfx::BColor(0.0, 0.0, 1.0)); // blue
break;
}
case 10:
{
// check single-color end area
- aColorStops.emplace_back(0.4, aXGradient.GetColorStops().back().getStopColor());
+ aColorStops.clear();
+ aColorStops.emplace_back(0.0, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ aColorStops.emplace_back(0.4, basegfx::BColor(0.0, 0.0, 1.0)); // blue
+ aColorStops.emplace_back(1.0, basegfx::BColor(0.0, 0.0, 1.0)); // blue
break;
}
@@ -564,8 +590,41 @@ namespace drawinglayer::primitive2d
{
// check case without direct Start/EndColor
aColorStops.clear();
- aColorStops.emplace_back(0.4, aXGradient.GetColorStops().back().getStopColor());
- aColorStops.emplace_back(0.6, aXGradient.GetColorStops().front().getStopColor());
+ aColorStops.emplace_back(0.4, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ aColorStops.emplace_back(0.6, basegfx::BColor(0.0, 0.0, 1.0)); // blue
+ break;
+ }
+
+ case 12:
+ {
+ // check case without colors at all
+ aColorStops.clear();
+ break;
+ }
+
+ case 13:
+ {
+ // check case with single stop
+ aColorStops.clear();
+ aColorStops.emplace_back(0.5, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ break;
+ }
+
+ case 14:
+ {
+ // check case with single-double stop
+ aColorStops.clear();
+ aColorStops.emplace_back(0.5, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ aColorStops.emplace_back(0.5, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ break;
+ }
+
+ case 15:
+ {
+ // check case with single stop diff colors
+ aColorStops.clear();
+ aColorStops.emplace_back(0.5, basegfx::BColor(1.0, 0.0, 0.0)); // red
+ aColorStops.emplace_back(0.5, basegfx::BColor(0.0, 0.0, 1.0)); // blue
break;
}