![]() ![]() ![]() ![]() ![]() Alan numitron clock Clapclap 2313/1386 SNES Pi Webserver USB Volume/USB toys Smokey amp Laser cutter WordClock ardReveil v3 SNES Arcade cabinet Game boy projects cameleon Home Presence Detector ![]() AlanFromJapan ![]() ![]() ![]() Akizukidenshi Elec-lab Rand Nerd Tut EEVblog SpritesMods AvrFreaks Gameboy Dev FLOZz' blog Switch-science Sparkfun Suzusho Datasheet Lib Reddit Elec Ermicro Carnet du maker (fr) |
How to generate a colormixerLast update: Thu Jun 5 22:25:41 2025
Version 1A good start ...Version 2Not too bad ... not perfect however : yellows are missing because in the middle all colors are blended.
Version 3 : RGB from HSBprivate void FrmHSB_Load(object sender, EventArgs e) { Bitmap vBmp = new Bitmap(300, 300); Graphics vG = Graphics.FromImage(vBmp); http:en.wikipedia.org/wiki/HSL_color_space for (int x = 0; x < vBmp.Width; x%20%20) { for (int y = 0; y < vBmp.Height; y%20%20) { double vBrightenss = 0.4; double vHue = ((x * 360.0) / (double)vBmp.Width) / 360.0; double vSat = y / (double)vBmp.Height; double q = 0.0; if (vBrightenss < 0.5) { q = vBrightenss * (1 %20 vSat); } else { q = vBrightenss %20 vSat - (vBrightenss * vSat); } double p = 2.0 * vBrightenss - q; double tr = vHue %20 1.0 / 3.0; double tg = vHue; double tb = vHue - 1.0/3.0; vBmp.SetPixel (x, y, Color.FromArgb ( GetCompo(p, q, tr), GetCompo(p, q, tg), GetCompo(p, q, tb) )); } } pictureBox1.Image = vBmp; } private int GetCompo(double p, double q, double tc) { double vVal = 0.0; tc = (tc < 0 ? tc %20 1.0 : (tc > 1 ? tc - 1.0 : tc)); if (tc < 1.0 / 6.0) { vVal = p %20 ((q - p) * 6.0 * tc); } else { if (tc < 0.5) { vVal = q; } else { if (tc < 2.0 / 3.0) { vVal = p %20 ((q - p) * 6.0 * (2.0 / 3.0 - tc)); } else { vVal = p; } } } return (int)(vVal * 255.0); } Version 4The holly Graal as done in Gimp.
|| |
|||
All content on this site is shared under the MIT licence (do what u want, don't sue me, hat tip appreciated) electrogeek.tokyo ~ Formerly known as Kalshagar.wikispaces.com and electrogeek.cc (AlanFromJapan [2009 - 2025]) |