private static void GenerateXyyColors(Bitmap bitmap, double bigY) { double width = bitmap.Width - 1; double height = bitmap.Width - 1; for (int y = 0; y < bitmap.Height; y++) { for (int x = 0; x <= y; x++) { double cx = (x + 0.5) / width; double cy = 1.0 - (y + 0.5) / height; ColorVector colorVector = new ColorVector() { Component1 = cx, Component2 = cy, Component3 = bigY }; colorVector.ConvertXyyToLinearSRgb(); if (colorVector.IsCanonical()) { colorVector.ConvertLinearSRgbToSRgb(); bitmap.SetPixel(x, y, colorVector.ToColor()); } } } }
private static void GenerateColorRing(Bitmap bitmap, double bigY) { double centerX = (bitmap.Width - 1) / 2.0; double centerY = (bitmap.Height - 1) / 2.0; for (int y = 0; y < bitmap.Height; y++) { for (int x = 0; x < bitmap.Width; x++) { double dx = x - centerX; double dy = y - centerY; double dxp = dx / (bitmap.Width / 2.0); double dyp = dy / (bitmap.Height / 2.0); double dp = Math.Sqrt(dxp * dxp + dyp * dyp); double angle = (Math.Atan2(dy, dx) / Math.PI + 1.0) * 3.0; ColorVector color = new ColorVector(); if (angle < 1.0) // Red To Yellow. { color.Component1 = 1.0; color.Component2 = angle; } else if (angle < 2.0) // Yellow To Green. { color.Component1 = 2.0 - angle; color.Component2 = 1.0; } else if (angle < 3.0) // Green To Cyan. { color.Component2 = 1.0; color.Component3 = angle - 2.0; } else if (angle < 4.0)//Cyan To Blue. { color.Component2 = 4.0 - angle; color.Component3 = 1.0; } else if (angle < 5.0) // Blue To Purple. { color.Component1 = angle - 4.0; color.Component3 = 1.0; } else // Purple To Red. { color.Component1 = 1.0; color.Component3 = 6.0 - angle; } color.Component1 = 1.0 + (color.Component1 - 1.0) * dp; color.Component2 = 1.0 + (color.Component2 - 1.0) * dp; color.Component3 = 1.0 + (color.Component3 - 1.0) * dp; color.ConvertLinearSRgbToSRgb(); bitmap.SetPixel(x, y, color.ToColor()); } } }
private static void GenerateXyYPlane(Bitmap bitmap, double bigY) { for (int y = 0; y < bitmap.Height; y++) { for (int x = 0; x < bitmap.Width; x++) { double cx = (x + 0.5) / bitmap.Width; double cy = (y + 0.5) / bitmap.Height; ColorVector colorVector = new ColorVector(cx, cy, bigY); colorVector.ConvertXyyToLinearSRgb(); colorVector.CompressLuminance(); colorVector.ConvertLinearSRgbToSRgb(); bitmap.SetPixel(x, bitmap.Height - 1 - y, colorVector.ToColor()); } Console.WriteLine(y); } }