public static DoubleColor AlterHue( this DoubleColor c, ColorWheelBase wheel, double hue ) { AHSB src = c.ToAHSB(); AHSB dest = wheel.GetColor(hue).ToAHSB(); dest.Saturation = src.Saturation; dest.Brightness = src.Brightness; dest.Alpha = src.Alpha; return(dest.Double()); }
public void UpdateBaseAngle( double value ) { double hue = value; double comp = 0.0; double hue1 = 0.0; double hue2 = 0.0; double hue3 = 0.0; if (m_wheel != null) { value = m_wheel.FixAngle(value); hue = m_wheel.GetColor(value).ToAHSB().HueDegree; } switch (m_schema) { case PaletteSchemaType.Monochromatic: for (int i = 0; i < m_colors.Count; ++i) { AHSB hsb = m_colors[i].Color; hsb.HueDegree = hue; m_colors[i].Color = hsb; } break; case PaletteSchemaType.Complementary: case PaletteSchemaType.Analogous: for (int i = 0; i < m_colors.Count; ++i) { AHSB hsb = m_colors[i].Color; hsb.HueDegree = m_colors[i].VectorIndex == 0 ? hue : m_wheel.GetColor(value + m_angle).ToAHSB().HueDegree; m_colors[i].Color = hsb; } break; case PaletteSchemaType.SplitComplementary: comp = 180; goto case PaletteSchemaType.SplitAnalogous; case PaletteSchemaType.Triad: case PaletteSchemaType.SplitAnalogous: if (m_wheel != null) { hue1 = m_wheel.GetColor(value + comp + m_angle).ToAHSB().HueDegree; hue2 = m_wheel.GetColor(value + comp - m_angle).ToAHSB().HueDegree; } for (int i = 0; i < m_colors.Count; ++i) { AHSB hsb = m_colors[i].Color; int idx = m_colors[i].VectorIndex; hsb.HueDegree = idx % 3 == 0 ? hue : (idx % 3 == 1 ? hue1 : hue2); m_colors[i].Color = hsb; } break; case PaletteSchemaType.Quadrants: hue1 = m_wheel.GetColor(value + 90).ToAHSB().HueDegree; hue2 = m_wheel.GetColor(value + 180).ToAHSB().HueDegree; hue3 = m_wheel.GetColor(value + 270).ToAHSB().HueDegree; for (int i = 0; i < m_colors.Count; ++i) { AHSB hsb = m_colors[i].Color; int idx = m_colors[i].VectorIndex; hsb.HueDegree = idx % 4 == 0 ? hue : (idx % 4 == 1 ? hue1 : (idx % 4 == 2 ? hue2 : hue3)); m_colors[i].Color = hsb; } break; case PaletteSchemaType.Tetrads: hue1 = m_wheel.GetColor(value + m_angle).ToAHSB().HueDegree; hue2 = m_wheel.GetColor(value + 180).ToAHSB().HueDegree; hue3 = m_wheel.GetColor(value + 180.0 + m_angle).ToAHSB().HueDegree; for (int i = 0; i < m_colors.Count; ++i) { AHSB hsb = m_colors[i].Color; int idx = m_colors[i].VectorIndex; hsb.HueDegree = idx % 4 == 0 ? hue : (idx % 4 == 1 ? hue1 : (idx % 4 == 2 ? hue2 : hue3)); m_colors[i].Color = hsb; } break; } }