public RoundColorPickerView(Context c, Color color)
            : base(c)
        {
            _colors = new[] {
                new Color(255,0,0,255).ToArgb(), new Color(255,0,255,255).ToArgb(), new Color(0,0,255,255).ToArgb(),
                new Color(0,255,255,255).ToArgb(), new Color(0,255,0,255).ToArgb(), new Color(255,255,0,255).ToArgb(),
                new Color(255,0,0,255).ToArgb()
            };
            using (Shader s = new SweepGradient(0, 0, _colors, null))
            {
                _paint = new Paint(PaintFlags.AntiAlias);
                _paint.SetShader(s);
                _paint.SetStyle(Paint.Style.Stroke);
                _paint.StrokeWidth = 32;
            }

            _centerPaint = new Paint(PaintFlags.AntiAlias)
                            {
                                Color = color,
                                StrokeWidth = 5
                            };
        }
Ejemplo n.º 2
0
        private void DrawRing(Canvas c)
        {
            var sc = c.Save();

            c.Rotate(-this.Degree, c.Width / 2, c.Height / 2);

            //���ĵ�
            var cx = c.Width / 2;
            var cy = c.Height / 2;

            //������Բ Path ����һ�� Բ����ʾ����, ���ڿ���Բ
            var pInner = new Path();
            pInner.AddCircle(cx, cy, this.BitmapRadius + SPACE / 2, Path.Direction.Cw);
            var pOut = new Path();
            pOut.AddCircle(cx, cy, this.Radius, Path.Direction.Cw);

            c.ClipPath(pOut);
            c.ClipPath(pInner, Region.Op.Difference);

            //var color = new Color((int)(DateTime.Now.Ticks % 0xFFFFFFFF));
            //c.DrawColor(color);

            //�ýǶȽ��������Բ�ķ�Χ
            var g = new SweepGradient(cx, cy, Color.Green, Color.Transparent);
            var paint = new Paint();
            paint.SetShader(g);
            c.DrawCircle(cx, cy, this.Radius, paint);

            c.RestoreToCount(sc);
        }
        public ColorPickerView(Context c, int color)
            : base(c)
        {
            colors = new[] {
                new Color(255, 0, 0, 255).ToArgb(), new Color(255, 0, 255, 255).ToArgb(), new Color(0, 0, 255, 255).ToArgb(),
                new Color(0, 255, 255, 255).ToArgb(), new Color(0, 255, 0, 255).ToArgb(), new Color(255, 255, 0, 255).ToArgb(),
                new Color(255, 0, 0, 255).ToArgb()
            };

            bwcolors = new [] {
                new Color(255, 255, 255, 255).ToArgb(),
                new Color(127, 127, 127, 255).ToArgb(),
                new Color(0, 0, 0, 255).ToArgb()
            };

            strokeWidth = 100;

            if (wowZapp.LaffOutOut.Singleton.resizeFonts)
            {
                strokeWidth = ImageHelper.convertDpToPixel((25 * (float)wowZapp.LaffOutOut.Singleton.ScreenXWidth) / 100, c);
                width = height = Convert.ToInt32(strokeWidth * 2) - 20;
            } else
            {
                width = 180;
                height = 190;
            }

            Shader s = new SweepGradient(0, 0, colors, null);
            myPaint = new Paint(PaintFlags.AntiAlias);
            myPaint.SetShader(s);
            myPaint.SetStyle(Paint.Style.Stroke);
            myPaint.StrokeWidth = strokeWidth;

            myCenterPaint = new Paint(PaintFlags.AntiAlias);
            myCenterPaint.Color = colorFromInt(color);
            myCenterPaint.StrokeWidth = 0;
        }
Ejemplo n.º 4
0
        public ColorPickerView(Context c, int color)
            : base(c)
        {
            colors = new[] {
                new Color (255, 0, 0, 255).ToArgb (), new Color (255, 0, 255, 255).ToArgb (), new Color (0, 0, 255, 255).ToArgb (),
                new Color (0, 255, 255, 255).ToArgb (), new Color (0, 255, 0, 255).ToArgb (), new Color (255, 255, 0, 255).ToArgb (),
                new Color (255, 0, 0, 255).ToArgb ()
            };

            bwcolors = new [] {
                new Color (255, 255, 255, 255).ToArgb (),
                new Color (127, 127, 127, 255).ToArgb (),
                new Color (0, 0, 0, 255).ToArgb ()
            };

            Shader s = new SweepGradient (0, 0, colors, null);
            myPaint = new Paint (PaintFlags.AntiAlias);
            myPaint.SetShader (s);
            myPaint.SetStyle (Paint.Style.Stroke);
            myPaint.StrokeWidth = 100;

            myCenterPaint = new Paint (PaintFlags.AntiAlias);
            myCenterPaint.Color = colorFromInt (color);
            myCenterPaint.StrokeWidth = 20;

            Shader t = new SweepGradient (0, 0, Color.Black, Color.White);
            myOuterPaint = new Paint (PaintFlags.AntiAlias);
            myOuterPaint.StrokeWidth = 25;
            myOuterPaint.SetShader (t);
            myOuterPaint.SetStyle (Paint.Style.Stroke);
            myOuterPaint.Color = Color.Gray;
        }
Ejemplo n.º 5
0
        private Bitmap createColorWheelBitmap(int width, int height)
        {

            Bitmap bitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);

            int colorCount = 12;
            int colorAngleStep = 360 / 12;
            int[] colors = new int[colorCount + 1];
            float[] hsv = new float[] { 0f, 1f, 1f };
            for (int i = 0; i < colors.Length; i++)
            {
                hsv[0] = (i * colorAngleStep + 180) % 360;
                colors[i] = Color.HSVToColor(hsv);
            }
            colors[colorCount] = colors[0];

            SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);

            RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, new Color(0xFFFFFF), new Color(0x00FFFFFF), Shader.TileMode.Clamp);
            ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SrcOver);

            colorWheelPaint.SetShader(composeShader);

            Canvas canvas = new Canvas(bitmap);
            canvas.DrawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);

            return bitmap;

        }
Ejemplo n.º 6
0
        //@SuppressLint("DrawAllocation")
        //@Override
        protected override void OnDraw(Canvas canvas)
        {

            int centerX = Width / 2;
            int centerY = Height / 2;

            // drawing color wheel

            canvas.DrawBitmap(colorWheelBitmap, centerX - colorWheelRadius, centerY - colorWheelRadius, null);

            // drawing color view

            colorViewPaint.Color = Color.HSVToColor(colorHSV);
            canvas.DrawPath(colorViewPath, colorViewPaint);

            // drawing value slider

            float[] hsv = new float[] { colorHSV[0], colorHSV[1], 1f };

            SweepGradient sweepGradient = new SweepGradient(centerX, centerY, new int[] { Color.Black, Color.HSVToColor(hsv), Color.White }, null);
            sweepGradient.SetLocalMatrix(gradientRotationMatrix);
            valueSliderPaint.SetShader(sweepGradient);

            canvas.DrawPath(valueSliderPath, valueSliderPaint);

            // drawing color wheel pointer

            float hueAngle = (float)Math.ToRadians(colorHSV[0]);
            int colorPointX = (int)(-Math.Cos(hueAngle) * colorHSV[1] * colorWheelRadius) + centerX;
            int colorPointY = (int)(-Math.Sin(hueAngle) * colorHSV[1] * colorWheelRadius) + centerY;

            float pointerRadius = 0.075f * colorWheelRadius;
            int pointerX = (int)(colorPointX - pointerRadius / 2);
            int pointerY = (int)(colorPointY - pointerRadius / 2);

            colorPointerCoords.Set(pointerX, pointerY, pointerX + pointerRadius, pointerY + pointerRadius);
            canvas.DrawOval(colorPointerCoords, colorPointerPaint);

            // drawing value pointer

            valuePointerPaint.Color = Color.HSVToColor(new float[] { 0f, 0f, 1f - colorHSV[2] });

            double valueAngle = (colorHSV[2] - 0.5f) * Math.Pi;
            float valueAngleX = (float)Math.Cos(valueAngle);
            float valueAngleY = (float)Math.Sin(valueAngle);

            canvas.DrawLine(valueAngleX * innerWheelRadius + centerX, valueAngleY * innerWheelRadius + centerY, valueAngleX * outerWheelRadius + centerX,
                    valueAngleY * outerWheelRadius + centerY, valuePointerPaint);

            // drawing pointer arrow

            if (arrowPointerSize > 0)
            {
                drawPointerArrow(canvas);
            }

        }