aboutsummaryrefslogtreecommitdiffstats
path: root/Software
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-08-04 15:24:54 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-08-04 15:24:54 +0300
commitec3adc8b26a07784ab342aa3f616b40aebda0a2e (patch)
treef0b51743938bf5275058e2f66a8784594305f92d /Software
parentc2471c200471e62b80133542183eb14af7c79bc7 (diff)
downloadTango-ec3adc8b26a07784ab342aa3f616b40aebda0a2e.tar.gz
Tango-ec3adc8b26a07784ab342aa3f616b40aebda0a2e.zip
Improved gradient generation!
Enabled cross color space gradient generation.
Diffstat (limited to 'Software')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs74
1 files changed, 29 insertions, 45 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs b/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs
index 9f716846b..f4db7a6b3 100644
--- a/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs
+++ b/Software/Visual_Studio/Tango.Integration/Operation/DefaultGradientGenerationConfiguration.cs
@@ -68,76 +68,60 @@ namespace Tango.Integration.Operation
{
aborted = false;
- //var stops = TangoColorConverter.CreateSegmentLinearGradient(segment, processParameters, ResolutionCM);
-
List<BrushStop> stops = new List<BrushStop>();
var previousSegmentsLength = segment.GetPreviousSegments().Sum(x => x.Length);
int stopIndex = 1;
- var colorSpace = segment.BrushStops.First().BrushColorSpace;
-
- //validate all brush stops in the segment are the same color space!
- if (segment.BrushStops.ToList().Exists(x => x.BrushColorSpace != colorSpace))
- {
- throw new ArgumentException("Cannot generate gradient using multiple color spaces on the same segment.");
- }
-
if (ResolutionCM > segment.Length * 100d)
{
return segment.BrushStops.ToList();
}
- var refStop = segment.BrushStops.First().Clone(segment);
-
IColorConverter converter = new DefaultColorConverter();
- for (double cm = 0; cm <= segment.Length; cm += (ResolutionCM / 100d))
+ var clonedStops = segment.BrushStops.ToList().Select(x => x.Clone(segment)).ToList();
+
+ foreach (var stop in clonedStops)
{
if (aborted) return stops;
- double offset = (double)cm / segment.Length;
+ if (stop.LiquidVolumes == null)
+ {
+ stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters);
+ }
- if (colorSpace == ColorSpaces.RGB || colorSpace == ColorSpaces.LAB || colorSpace == ColorSpaces.CMYK)
+ if (stop.BrushColorSpace == ColorSpaces.RGB || stop.BrushColorSpace == ColorSpaces.LAB)
{
- var color = GetRelativeRGB(segment.BrushStops.ToList(), offset);
- var output = converter.Convert(segment.Job, color);
+ var output = converter.Convert(segment.Job, stop.Color);
+ output.ApplyOnBrushStop(stop, processParameters);
+ }
+ }
- BrushStop s = new BrushStop();
- s.Segment = segment;
- s.ColorSpace = new ColorSpace();
- s.ColorSpace.Code = ColorSpaces.RGB.ToInt32();
- s.Corrected = true;
- s.OffsetPercent = offset * 100d;
- s.OffsetMeters = segment.Length * offset;
- s.Red = color.R;
- s.Green = color.G;
- s.Blue = color.B;
- s.StopIndex = stopIndex++;
+ var refStop = clonedStops.First().Clone(segment);
- output.ApplyOnBrushStop(s, processParameters);
+ for (double cm = 0; cm <= segment.Length; cm += (ResolutionCM / 100d))
+ {
+ if (aborted) return stops;
- stops.Add(s);
- }
- else if (colorSpace == ColorSpaces.Volume || colorSpace == ColorSpaces.Catalog)
- {
- var cmyk = GetRelativeCMYK(segment.BrushStops.ToList(), offset);
- var stop = refStop.Clone(segment);
+ double offset = (double)cm / segment.Length;
- stop.OffsetPercent = offset * 100d;
- stop.OffsetMeters = segment.Length * offset;
- stop.StopIndex = stopIndex++;
+ var cmyk = GetRelativeCMYK(clonedStops.ToList(), offset);
+ var stop = refStop.Clone(segment);
- stop.SetVolume(LiquidTypes.Cyan, cmyk.C);
- stop.SetVolume(LiquidTypes.Magenta, cmyk.M);
- stop.SetVolume(LiquidTypes.Yellow, cmyk.Y);
- stop.SetVolume(LiquidTypes.Black, cmyk.K);
+ stop.OffsetPercent = offset * 100d;
+ stop.OffsetMeters = segment.Length * offset;
+ stop.StopIndex = stopIndex++;
- stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters);
+ stop.SetVolume(LiquidTypes.Cyan, cmyk.C);
+ stop.SetVolume(LiquidTypes.Magenta, cmyk.M);
+ stop.SetVolume(LiquidTypes.Yellow, cmyk.Y);
+ stop.SetVolume(LiquidTypes.Black, cmyk.K);
- stops.Add(stop);
- }
+ stop.SetLiquidVolumes(job.Machine.Configuration, job.Rml, processParameters);
+
+ stops.Add(stop);
progress?.Invoke(new PreparingJobProgressEventArgs()
{