protected int GetARGB32Color(
     ColorWheelBase wl,
     double degree,
     double currentRadius,
     double gradRadius
     )
 {
     return(GetDoubleColor(wl, degree, currentRadius, gradRadius).ToARGB32());
 }
        private int GetColorFromPoint(
            int radius,
            double x,
            double y,
            ColorWheelBase wl,
            out int offset,
            out double degree
            )
        {
            double step;

            double curRadius  = Math.Sqrt(x * x + y * y);
            double radians    = Math.Atan2(y, x);
            double gradRadius = radius - (SectorWidth * 3.0);

            int sector = (int)((radius - curRadius) / SectorWidth);

            degree = wl.FixAngle((360.0 - radians * (180 / Math.PI)) + m_angleShift);

            offset = (int)(((int)(y + radius)) * (radius * 2) + (int)(x + radius));
            int val = 0;

            switch (sector)
            {
            case 0:
                step   = 360 / 6;
                degree = ((int)((degree + step / 2) / step)) * step;
                break;

            case 1:
                step   = 360 / 12;
                degree = ((int)((degree + step / 2) / step)) * step;
                break;

            case 2:
                step   = 360 / 24;
                degree = ((int)((degree + step / 2) / step)) * step;
                break;
            }

            if (sector <= 2)
            {
                val = wl.GetColor(degree).ToARGB32();
            }
            else
            {
                val = GetARGB32Color(wl, degree, curRadius, gradRadius);
            }

            return(val);
        }
Пример #3
0
        void InstantiateWheel()
        {
            //Leaving this here in case I create more color wheel types...

            if (wheel != null)
            {
                this._grid.Children.Remove(wheel);
            }

            if (wheelClass != null)
            {
                wheel                 = (ColorWheelBase)Activator.CreateInstance(WheelClass);
                wheel.Name            = "wheel";
                wheel.PointerPressed += Wheel_PointerPressed;;
                wheel.ZIndex          = -2;
                _grid.Children.Add(wheel);

                wheel.PointerPressed += Wheel_PointerPressed;
            }
        }
        protected DoubleColor GetDoubleColor(
            ColorWheelBase wl,
            double degree,
            double currentRadius,
            double gradRadius
            )
        {
            DoubleColor val;
            AHSL        hsl;
            DoubleColor dc = wl.GetColor(degree);

            switch (PaintMethod)
            {
            case WheelPaintMethod.Brightness:
                val = dc.ToAHSB().Alter(null, 1.0, currentRadius / gradRadius).Double();
                break;

            case WheelPaintMethod.InverseLuminance:
                hsl           = dc.ToAHSL();
                hsl.Luminance = currentRadius / gradRadius;
                val           = hsl.Double();
                break;

            case WheelPaintMethod.Luminance:
                hsl           = dc.ToAHSL();
                hsl.Luminance = 1.0 - currentRadius / gradRadius;
                val           = hsl.Double();
                break;

            case WheelPaintMethod.Saturation:
                val = dc.ToAHSB().Alter(null, currentRadius / gradRadius).Double();
                break;

            default:
                throw new NotImplementedException();
            }

            return(val);
        }