diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-05-14 19:22:43 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-05-14 19:22:43 +0300 |
| commit | 87c98495edfd1acc4c155b37990d72c37ea28e2b (patch) | |
| tree | 87eeda8df1b09b9edb6142eab4da5dda7d9215a2 /Software/Visual_Studio/Tango.UnitTesting | |
| parent | a870370b6034c62c6aeb15c1b29c55b22d935364 (diff) | |
| parent | fe668f0caa6111c69e6b214b346d75059bf581f7 (diff) | |
| download | Tango-87c98495edfd1acc4c155b37990d72c37ea28e2b.tar.gz Tango-87c98495edfd1acc4c155b37990d72c37ea28e2b.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs index 65bb31208..9951d8d10 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Pulse/Pulse_TST.cs @@ -124,5 +124,99 @@ namespace Tango.UnitTesting.Pulse twnFilePath.Display(); } + + [TestMethod] + public void Compose_Artificial_Twn_File() + { + String dstFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "TCap", "T-CAP.dst"); + String imgSolidFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "TCap", "T_Cap_Solid.png"); + String imgGradientFile = Path.Combine(Helper.GetResourcePath(), "Pulse", "TCap", "T_Cap.png"); + + TwnFile twnFile = new TwnFile(); + twnFile.Version = 1f; + twnFile.Name = "T Cap Solid"; + twnFile.NumberOfCopies = 1; + twnFile.MediaID = 0; + twnFile.SpoolingMethod = SpoolingMethods.SingleSpool; + + twnFile.EmbroideryFile = File.ReadAllBytes(dstFile); + twnFile.EmbroideryFileFormat = "dst"; + + + //Generate solid. + Bitmap thumbnail = new Bitmap(imgSolidFile); + twnFile.Thumbnail = thumbnail; + + twnFile.Segments.Add(CreateSolidSegment(10, 252, 224, 87)); + twnFile.Segments.Add(CreateSolidSegment(10, 251, 168, 45)); + twnFile.Segments.Add(CreateSolidSegment(10, 237, 19, 117)); + twnFile.Segments.Add(CreateSolidSegment(10, 234, 89, 56)); + + var tempFolder = TemporaryManager.Default.CreateFolder(); + twnFile.ToFile(Path.Combine(tempFolder, "t-cap solid.twn")); + + twnFile.Segments.Clear(); + + //Generate gradient. + twnFile.Name = "T Cap Gradient"; + + thumbnail = new Bitmap(imgGradientFile); + twnFile.Thumbnail = thumbnail; + + twnFile.Segments.Add(CreateGradientSegment(10, 237, 19, 117, 251, 168, 45)); + twnFile.Segments.Add(CreateGradientSegment(10, 237, 19, 117, 251, 168, 45)); + twnFile.Segments.Add(CreateGradientSegment(10, 139, 48, 145, 251, 168, 45)); + twnFile.Segments.Add(CreateGradientSegment(10, 139, 48, 145, 242, 141, 172)); + + twnFile.ToFile(Path.Combine(tempFolder, "t-cap gradient.twn")); + + tempFolder.Display(); + } + + private TwnSegment CreateSolidSegment(float meter, byte r, byte g, byte b) + { + var segment = new TwnSegment() + { + Length = meter * 100, + BrushStops = new List<TwnStop>() + { + new TwnStop() + { + R = r, + G = g, + B = b + }, + } + }; + + return segment; + } + + private TwnSegment CreateGradientSegment(float meter, byte r1, byte g1, byte b1, byte r2, byte g2, byte b2) + { + var segment = new TwnSegment() + { + Length = meter * 100, + BrushStops = new List<TwnStop>() + { + new TwnStop() + { + R = r1, + G = g1, + B = b1, + Offset = 0 + }, + new TwnStop() + { + R = r2, + G = g2, + B = b2, + Offset = 1 + }, + } + }; + + return segment; + } } } |
