コード例 #1
0
        private void InitBrush()
        {
            if (_lbrsv == null)
            {
                _lbrsv = new LinearGradientBrush
                             (new Point(0, 0), new Point(1, 0), Color.Black, Color.White);
                float   dy = 0f, incy = 360f / (float)(num - 1);
                float[] pos = new float[num];
                Color[] col = new Color[num];
                HSL     hue = new HSL(0, 50, 100);
                for (int i = 0; i < num; i++, dy += incy)
                {
                    hue.h  = (int)dy;
                    pos[i] = dy / 360f;
                    col[i] = HSL.Hue2RGB(hue);
                }
                ColorBlend ret = new ColorBlend();
                //pos[pos.Length-1]=1f;
                ret.Colors    = col;
                ret.Positions = pos;
                _lbrsv.InterpolationColors = ret;
            }
            if (_lbrsh == null)
            {
                _lbrsh = new LinearGradientBrush
                             (new Point(0, 0), new Point(1, 0), Color.Black, Color.White);
                ColorBlend ret = new ColorBlend();
                ret.Positions = new float[] { 0f, 0.5f, 1f };
                ret.Colors    = new Color[] { Color.White, Color.FromArgb(0, 128, 128, 128), Color.Black };
                _lbrsh.InterpolationColors = ret;
            }
            float w = Math.Max(this.Width, 3),
                  h = Math.Max(this.Height, 3);

            _lbrsv.Transform = new Matrix(0f, h, w, 0f, 0f, 0f);
            _lbrsh.Transform = new Matrix(w, 0f, 0f, h, 0f, 0f);
            _transfrm        = new Matrix(w - 1f, 0f, 0f, h - 1f, 0f, 0f);
        }
コード例 #2
0
        private void InitBrush()
        {
            if (_pthbrs == null)
            {
                double   num2 = (double)num;
                PointF[] pts  = new PointF[num];
                Color[]  cols = new Color[num];
                for (int i = 0; i < num; i++)
                {
                    cols[i] = HSL.Hue2RGB(new HSL((int)((double)i * (360 / num2)), 50, 100));
                    pts[i]  = new PointF((float)Math.Sin((double)i * (2.0 / num2) * Math.PI),
                                         (float)Math.Cos((double)i * (2.0 / num2) * Math.PI));
                }
                _pthbrs = new PathGradientBrush(pts);
                _pthbrs.SurroundColors = cols;
                _pthbrs.FocusScales    = new PointF(0f, 0f);
                _pthbrs.CenterColor    = Color.White;
            }
            float w = Math.Max(this.Width / 2, 3), h = Math.Max(this.Height / 2, 3);

            _pthbrs.Transform = new Matrix(w, 0f, 0f, h, w, h);
            _transfrm         = new Matrix(w - 2f, 0f, 0f, h - 2f, w, h);
        }
コード例 #3
0
 private Color FindPoint2(PointF val)
 {
     return(HSL.Hue2RGB(FindPoint(val)));
 }