aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2022-12-06 18:21:48 +0200
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2022-12-06 18:21:48 +0200
commitd245f335580c87e15a31a1f743bfc3117c95e732 (patch)
tree2e6f9f7ea897460d0006540e4d1631c70b0a09ad /Software/Visual_Studio/Tango.Integration
parent88416618b921c57d88f08877c3397be6324b8605 (diff)
downloadTango-d245f335580c87e15a31a1f743bfc3117c95e732.tar.gz
Tango-d245f335580c87e15a31a1f743bfc3117c95e732.zip
PPC. Bug in print gradient - set volume to middle offset brush during printing
Related Work Items: #7440
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs56
1 files changed, 52 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs b/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs
index ef275479b..9b4dbb852 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs
@@ -89,7 +89,7 @@ namespace Tango.Integration.Operation
IColorConverter converter = new DefaultColorConverter();
- var clonedStops = segment.BrushStops.ToList().Select(x => x.Clone(segment)).ToList();
+ var clonedStops = segment.BrushStops.ToList().Select(x => x.Clone(segment)).OrderBy(x => x.StopIndex).ToList();
foreach (var stop in clonedStops)
{
@@ -105,8 +105,44 @@ namespace Tango.Integration.Operation
var output = converter.Convert(stop, false);
output.ApplyOnBrushStop(stop, processParameters);
}
- }
+ if ((stop.BrushColorSpace == ColorSpaces.Volume || stop.BrushColorSpace == ColorSpaces.Catalog) && job.Version >= 2 && clonedStops.Count == 5)
+ {
+ var firstStop = clonedStops.FirstOrDefault(x => x.StopIndex == 1);
+ var lastStop = clonedStops.FirstOrDefault(x => x.StopIndex == 5);
+ CMYK cmykfirst = GetCMYK(firstStop);
+ cmykfirst.OffsetPercent /= 100d;
+ CMYK cmyklast = GetCMYK(lastStop);
+ cmyklast.OffsetPercent /= 100d;
+ //set middle offset color
+ var middleOffsetStop = clonedStops.FirstOrDefault(x => x.StopIndex == 3);
+ if (middleOffsetStop != null)
+ {
+ CMYK cmykmiddle = GetRelativeCMYK(cmykfirst, cmyklast, middleOffsetStop.OffsetPercent / 100d);
+ middleOffsetStop.SetVolume(LiquidTypes.Cyan, cmykmiddle.C);
+ middleOffsetStop.SetVolume(LiquidTypes.Magenta, cmykmiddle.M);
+ middleOffsetStop.SetVolume(LiquidTypes.Yellow, cmykmiddle.Y);
+ middleOffsetStop.SetVolume(LiquidTypes.Black, cmykmiddle.K);
+ }
+ var firstOffsetStop = clonedStops.FirstOrDefault(x => x.StopIndex == 2);
+ if (firstOffsetStop != null)
+ {
+ firstOffsetStop.SetVolume(LiquidTypes.Cyan, cmykfirst.C);
+ firstOffsetStop.SetVolume(LiquidTypes.Magenta, cmykfirst.M);
+ firstOffsetStop.SetVolume(LiquidTypes.Yellow, cmykfirst.Y);
+ firstOffsetStop.SetVolume(LiquidTypes.Black, cmykfirst.K);
+ }
+ var secondOffsetStop = clonedStops.FirstOrDefault(x => x.StopIndex == 4);
+ if (secondOffsetStop != null)
+ {
+ secondOffsetStop.SetVolume(LiquidTypes.Cyan, cmyklast.C);
+ secondOffsetStop.SetVolume(LiquidTypes.Magenta, cmyklast.M);
+ secondOffsetStop.SetVolume(LiquidTypes.Yellow, cmyklast.Y);
+ secondOffsetStop.SetVolume(LiquidTypes.Black, cmyklast.K);
+ }
+ }
+ }
+
var refStop = clonedStops.First().Clone(segment);
decimal segment_length = (decimal)segment.Length;
@@ -154,6 +190,18 @@ namespace Tango.Integration.Operation
return stops;
}
+ private CMYK GetRelativeCMYK(CMYK first, CMYK last, double offset)
+ {
+ CMYK cmyk = new CMYK();
+
+ cmyk.C = (float)((offset - first.OffsetPercent) * (last.C - first.C) / (last.OffsetPercent - first.OffsetPercent) + first.C);
+ cmyk.M = (float)((offset - first.OffsetPercent) * (last.M - first.M) / (last.OffsetPercent - first.OffsetPercent) + first.M);
+ cmyk.Y = (float)((offset - first.OffsetPercent) * (last.Y - first.Y) / (last.OffsetPercent - first.OffsetPercent) + first.Y);
+ cmyk.K = (float)((offset - first.OffsetPercent) * (last.K - first.K) / (last.OffsetPercent - first.OffsetPercent) + first.K);
+
+ return cmyk;
+ }
+
private CMYK GetRelativeCMYK(List<BrushStop> brushStopsCollection, double offset)
{
BrushStop refStop = brushStopsCollection.First().Clone();
@@ -167,7 +215,7 @@ namespace Tango.Integration.Operation
if (stop != null) return stop;
CMYK before = cmykCollection.Where(w => w.OffsetPercent == cmykCollection.Min(m => m.OffsetPercent)).First();
- CMYK after = cmykCollection.Where(w => w.OffsetPercent == cmykCollection.Max(m => m.OffsetPercent)).First();
+ CMYK after = cmykCollection.Where(w => w.OffsetPercent == cmykCollection.Max(m => m.OffsetPercent)).Last();
foreach (var gs in cmykCollection)
{
@@ -216,7 +264,7 @@ namespace Tango.Integration.Operation
if (point != null) return point.Color;
BrushStop before = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Min(m => m.OffsetPercent)).First();
- BrushStop after = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Max(m => m.OffsetPercent)).First();
+ BrushStop after = brushStopsCollection.Where(w => w.OffsetPercent == brushStopsCollection.Max(m => m.OffsetPercent)).Last();
foreach (var gs in brushStopsCollection)
{