private void UpdateHexTextBox() { int caretIndex = tbHexValue.CaretIndex; tbHexValue.Text = ColorHsv.ToString(); tbHexValue.CaretIndex = Math.Min(caretIndex, tbHexValue.Text.Length); }
public ColorHsv(ColorHsv hc) { this._alpha = hc._alpha; this._h = hc._h; this._s = hc._s; this._v = hc._v; }
protected override void CreateImage() { Bitmap = new FastBitmap(Width, Height); Bitmap.Lock(); for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { ColorHsv colourHsv = CalculateFractalColour(x, y); Color colour = (Color)colourHsv; Bitmap[x, y] = colour; } } Bitmap.Unlock(); }
protected override void CreateImage(ImageGenerationContext context) { Bitmap = new FastBitmap(Width, Height); Bitmap.Lock(); for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { ColorHsv colorHsv = CalculateFractalColor(x, y); var color = (Color)colorHsv; Bitmap[x, y] = color.ToWpfColor(); } } Bitmap.Unlock(); }
public ColorRgb(ColorHsv hsv) { double XR = double.NaN; double XG = double.NaN; double XB = double.NaN; if (double.IsNaN(hsv.H) || hsv.S == 0.0) { // Make it some kind of gray this._alpha = hsv.Alpha; this._r = hsv.V; this._g = hsv.V; this._b = hsv.V; return; } double H = hsv.H; if (hsv.H > 1.0) { throw new System.ArgumentOutOfRangeException("H"); } else if (hsv.H == 1.0) { H = 0.0; } double step = 1.0 / 6.0; double vh = H / step; int i = (int)System.Math.Floor(vh); double f = vh - i; double p = hsv.V * (1.0 - hsv.S); double q = hsv.V * (1.0 - (hsv.S * f)); double t = hsv.V * (1.0 - (hsv.S * (1.0 - f))); switch (i) { case 0: { XR = hsv.V; XG = t; XB = p; break; } case 1: { XR = q; XG = hsv.V; XB = p; break; } case 2: { XR = p; XG = hsv.V; XB = t; break; } case 3: { XR = p; XG = q; XB = hsv.V; break; } case 4: { XR = t; XG = p; XB = hsv.V; break; } case 5: { XR = hsv.V; XG = p; XB = q; break; } default: { // not possible - if we get here it is an internal error throw new System.ArgumentException(); } } this._alpha = hsv.Alpha; this._r = XR; this._g = XG; this._b = XB; }
internal ColorDistribution AddPixel(ColorHsv hsv) { var indexH = GetHueIndex(hsv.H); var indexS = GetSaturationIndex(hsv.S); var indexV = GetValueIndex(hsv.V); this.cube[indexH, indexS, indexV]++; return this; }
public int GetColorWeight(ColorHsv hsv) { var indexH = GetHueIndex(hsv.H); var indexS = GetSaturationIndex(hsv.S); var indexV = GetValueIndex(hsv.V); return this.cube[indexH, indexS, indexV]; }