private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (this._changingHue) { EPointF diff = new EPointF(e.X, e.Y) - this.Center; float angle = diff.Angle * 180 / (float)Math.PI; angle += 60; if (angle < 0) { angle += 360; } else if (angle > 360) { angle -= 360; } ColorHsb hsb = this.HSB; hsb.H = angle; this.HSB = hsb; //this.Invalidate(); //this.pictureBox1.Invalidate(); } else if (this._changingSB) { this.SetSBFromLoc(new EPointF(e.X, e.Y)); } this.pictureBox1.Invalidate(); if (this.ColorChanged != null) { this.ColorChanged(this, null); } }
private EPointF GetLocFromSB() { ColorHsb hsb = this.HSB; EPointF pnt = this._quad.MapFromRect(new EPointF(hsb.S, 1f - hsb.B), new ERectangleF(0, 0, 1, 1)); return(pnt + this._offset); }
private void SetSBFromLoc(EPointF pMouse) { ColorHsb hsb = this.HSB; pMouse -= this._offset; EPointF vals = this._quad.MapToRect(new EPointF(pMouse.X, pMouse.Y), new ERectangleF(0, 0, 1, 1)); hsb.S = vals.X; hsb.B = 1f - vals.Y; hsb.Validate(); this.HSB = hsb; }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { Bitmap bmp = new Bitmap(this._triangleSize.X, this._triangleSize.Y, System.Drawing.Imaging.PixelFormat.Format24bppRgb); ColorHsb fullColor = new ColorHsb(); fullColor.H = this.HSB.H; fullColor.S = 1; fullColor.B = 1; fullColor.A = 255; e.Graphics.FillPolygon(new SolidBrush(fullColor.ColorRGBA), new Point[] { (this._trianglePoints[0] + this._offset).ToPoint(), (this._trianglePoints[1] + this._offset).ToPoint(), (this._trianglePoints[2] + this._offset).ToPoint() }); e.Graphics.DrawImage(this._overlayTriangle, this._offset.ToPoint()); e.Graphics.DrawImage(this._indicator, (this.GetLocFromHue() - new EPointF(this._indicator.Width, this._indicator.Height) / 2 + new EPointF(1, 1)).ToPoint()); //e.Graphics.DrawString(this._fullHueColor.ToString(), new Font("Arial", 6), new SolidBrush(Color.Blue), new PointF(0, 0)); e.Graphics.DrawImage(this._indicator, (this.GetLocFromSB() - new EPointF(this._indicator.Width, this._indicator.Height) / 2 + new EPointF(1, 1)).ToPoint()); }
public void Test() { Endogine.ColorEx.Palette pal = new Palette(); ColorHsb hsb = new ColorHsb(); hsb.A = 255; hsb.S = 0.5f; Point p = new Point(15, 15); for (int i = 0; i < p.X; i++) { hsb.B = 1f - (float)i / p.X; for (int j = 0; j < p.Y; j++) { hsb.H = 359f * (float)j / p.Y; pal.Add("Red", new ColorRgb(hsb.ColorRGBA)); } } this.Palette = pal; }