From 331266b13685e16520ae5baa8a7aff50789c31df Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 13 Nov 2024 05:12:21 +0200 Subject: Inks Extension Support. --- .../Tango.ColorMeasurementsGenerator/App.config | 24 +++++ .../Tango.ColorMeasurementsGenerator/Program.cs | 104 +++++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 +++++++ .../Tango.ColorMeasurementsGenerator.csproj | 83 ++++++++++++++++ .../packages.config | 4 + 5 files changed, 251 insertions(+) create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj create mode 100644 Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config (limited to 'Software/Visual_Studio/Utilities') diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config new file mode 100644 index 000000000..4ef5218a0 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config @@ -0,0 +1,24 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs new file mode 100644 index 000000000..96b5023ec --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.ColorConversion; + +namespace Tango.ColorMeasurementsGenerator +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Generating Colors..."); + Console.WriteLine(); + + var colors = RGBGenerator.GenerateRGBValues(1000); + + List measurements = new List(); + + for (int i = 0; i < colors.Count; i++) + { + var color = colors[i]; + //color = DefaultColorConverter.BlendWithViolet((int)color.R, (int)color.G, (int)color.B, ((float)i) / 100f); + var rgb = new ColorMine.ColorSpaces.Rgb(color.R, color.G, color.B); + var cmyk = rgb.To(); + var lab = rgb.To(); + + ColorMeasurement m = new ColorMeasurement(); + m.C = cmyk.C * 100; + m.M = cmyk.M * 100; + m.Y = cmyk.Y * 100; + m.K = cmyk.K * 100; + m.V = 0; + m.L = lab.L; + m.A = lab.A; + m.B = lab.B; + + measurements.Add(m); + + Console.WriteLine(m.ToString()); + } + + Console.WriteLine(); + + using (var db = ObservablesContext.CreateDefault()) + { + Console.WriteLine("Clearing previous color measurements..."); + db.Database.ExecuteSqlCommand("DELETE FROM COLOR_MEASUREMENTS"); + } + + using (var db = ObservablesContext.CreateDefault()) + { + foreach (var m in measurements) + { + db.ColorMeasurements.Add(m); + } + + Console.WriteLine("Adding new measurements to database..."); + + db.SaveChanges(); + } + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine(); + Console.WriteLine("Done!"); + Console.ReadKey(); + Environment.Exit(0); + } + } + + public class RGBGenerator + { + public static List GenerateRGBValues(int numberOfColors) + { + List colors = new List(); + int colorRange = (int)Math.Ceiling(Math.Pow(numberOfColors, 1.0 / 3.0)); + + for (int r = 0; r < colorRange; r++) + { + for (int g = 0; g < colorRange; g++) + { + for (int b = 0; b < colorRange; b++) + { + int red = (int)(r * 255.0 / (colorRange - 1)); + int green = (int)(g * 255.0 / (colorRange - 1)); + int blue = (int)(b * 255.0 / (colorRange - 1)); + + colors.Add(new RGB(red, green, blue)); + + if (colors.Count >= numberOfColors) + { + return colors; + } + } + } + } + + return colors; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..150cfb8d4 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.ColorMeasurementsGenerator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.ColorMeasurementsGenerator")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("04fca0ba-a64b-4c6a-a011-a94ce335d616")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj new file mode 100644 index 000000000..89062149c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {04FCA0BA-A64B-4C6A-A011-A94CE335D616} + Exe + Tango.ColorMeasurementsGenerator + Tango.ColorMeasurementsGenerator + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + {37e4ceab-b54b-451f-b535-04cf7da9c459} + ColorMine + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {b4fe6485-4161-4b36-bc08-67e0b53d01b7} + Tango.ColorConversion + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {58e8825f-0c96-449c-b320-1e82b0aa876b} + Tango.CSV + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config new file mode 100644 index 000000000..b3daf0d6c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.3.1