コード例 #1
0
ファイル: ColorHsb.cs プロジェクト: timdetering/Endogine
        public void Interpolate(ColorHsb hsbTo, float position)
        {
            this.A = (int)(position * (hsbTo.A - this.A) + this.A);
            if (Math.Abs(hsbTo.H - this.H) > 180)
            {
                if (this.H < hsbTo.H)
                {
                    this.H += 360;
                }
                else
                {
                    this.H -= 360;
                }
                this.H = position * (hsbTo.H - this.H) + this.H;
                if (this.H < 0)
                {
                    this.H += 360;
                }
                else if (this.H > 360)
                {
                    this.H -= 360;
                }
            }
            else
            {
                this.H = position * (hsbTo.H - this.H) + this.H;
            }

            this.S = position * (hsbTo.S - this.S) + this.S;
            this.B = position * (hsbTo.B - this.B) + this.B;
        }
コード例 #2
0
ファイル: ColorHsb.cs プロジェクト: timdetering/Endogine
        public static Color InterpolateRgbInHsbSpace(Color c1, Color c2, float position)
        {
            ColorHsb hsb1 = new ColorHsb(c1);

            hsb1.Interpolate(new ColorHsb(c2), position);
            return(hsb1.ColorRGBA);
        }
コード例 #3
0
 public static Color HsbToRgb(ColorHsb hsb)
 {
     return hsb.ColorRGBA;
 }
コード例 #4
0
ファイル: ColorHsb.cs プロジェクト: timdetering/Endogine
        public void Interpolate(ColorHsb hsbTo, float position)
        {
            this.A = (int)(position*(hsbTo.A - this.A)+this.A);
            if (Math.Abs(hsbTo.H - this.H) > 180)
            {
                if (this.H < hsbTo.H)
                    this.H+=360;
                else
                    this.H-=360;
                this.H = position*(hsbTo.H - this.H)+this.H;
                if (this.H < 0)
                    this.H+=360;
                else if (this.H > 360)
                    this.H-=360;
            }
            else
                this.H = position*(hsbTo.H - this.H)+this.H;

            this.S = position*(hsbTo.S - this.S)+this.S;
            this.B = position*(hsbTo.B - this.B)+this.B;
        }
コード例 #5
0
ファイル: ColorHsb.cs プロジェクト: timdetering/Endogine
 public static Color InterpolateRgbInHsbSpace(Color c1, Color c2, float position)
 {
     ColorHsb hsb1 = new ColorHsb(c1);
     hsb1.Interpolate(new ColorHsb(c2), position);
     return hsb1.ColorRGBA;
 }
コード例 #6
0
        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;
        }
コード例 #7
0
        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());
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 public static Color HsbToRgb(ColorHsb hsb)
 {
     return(hsb.ColorRGBA);
 }
コード例 #10
0
ファイル: SwatchesPanel.cs プロジェクト: timdetering/Endogine
 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;
 }