Exemplo n.º 1
0
        public override void paint(Canvas canvas, Offset offset, ImageConfiguration configuration)
        {
            LinearGradient gradient = _decoration.edgeGradient;

            if (gradient == null)
            {
                return;
            }
            TextDirection textDirection = configuration.textDirection;
            float         deltaX        = 0.0f;

            switch (textDirection)
            {
            case TextDirection.rtl:
                deltaX = configuration.size.width;
                break;

            case TextDirection.ltr:
                deltaX = -configuration.size.width;
                break;
            }
            Rect  rect  = (offset & configuration.size).translate(deltaX, 0.0f);
            Paint paint = new Paint()
            {
                shader = gradient.createShader(rect, textDirection: textDirection)
            };

            canvas.drawRect(rect, paint);
        }
Exemplo n.º 2
0
        public override void paint(Canvas canvas, Size size)
        {
            Rect rect = Offset.zero & size;

            var gradientH = new LinearGradient(
                colors: new List <Color> {
                new Color(0xff808080),
                HSLColor.fromAHSL(1f, hslColor.hue, 1f, 0.5f).toColor()
            }
                );
            var gradientV = new LinearGradient(
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
                stops: new List <float> {
                0.0f, 0.5f, 0.5f, 1f
            },
                colors: new List <Color> {
                Colors.white,
                new Color(0x00ffffff),
                Colors.transparent,
                Colors.black
            }
                );
            var paint = new Paint()
            {
                strokeWidth = 1.5f, style = PaintingStyle.stroke
            };

            if (pointerColor != null)
            {
                paint.color = pointerColor;
            }
            else if (Utils.useWhiteForeground(hslColor.toColor()))
            {
                paint.color = Colors.white;
            }
            else
            {
                paint.color = Colors.black;
            }


            canvas.drawRect(rect, new Paint()
            {
                shader = gradientV.createShader(rect)
            });
            canvas.drawRect(rect, new Paint()
            {
                shader = gradientH.createShader(rect)
            });
            canvas.drawCircle(
                new Offset(size.width * hslColor.saturation, size.height * (1 - hslColor.lightness)),
                size.height * 0.04f,
                paint
                );
        }
Exemplo n.º 3
0
        public override void paint(Canvas canvas, Size size)
        {
            Rect rect      = Offset.zero & size;
            var  gradientV = new LinearGradient(
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
                colors: new List <Color> {
                Colors.white, Colors.black
            }
                );
            var gradientH = new LinearGradient(
                colors: new List <Color> {
                Colors.white,
                HSVColor.fromAHSV(1f, hsvColor.hue, 1f, 1f).toColor()
            }
                );

            var paint = new Paint()
            {
                strokeWidth = 1.5f, style = PaintingStyle.stroke
            };

            if (pointerColor != null)
            {
                paint.color = pointerColor;
            }
            else if (Utils.useWhiteForeground(hsvColor.toColor()))
            {
                paint.color = Colors.white;
            }
            else
            {
                paint.color = Colors.black;
            }


            canvas.drawRect(rect, new Paint()
            {
                shader = gradientV.createShader(rect)
            });
            canvas.drawRect(rect, new Paint()
            {
                blendMode = BlendMode.multiply, shader = gradientH.createShader(rect)
            });
            canvas.drawCircle(
                new Offset(size.width * hsvColor.saturation, size.height * (1 - hsvColor.value)),
                size.height * 0.04f,
                paint
                );
        }
Exemplo n.º 4
0
        public override void paint(Canvas canvas, Offset offset, ImageConfiguration configuration)
        {
            LinearGradient gradient = this._decoration.edgeGradient;

            if (gradient == null)
            {
                return;
            }

            float deltaX = -configuration.size.width;
            Rect  rect   = (offset & configuration.size).translate(deltaX, 0.0f);
            Paint paint  = new Paint();

            paint.shader = gradient.createShader(rect);
            canvas.drawRect(rect, paint);
        }
Exemplo n.º 5
0
        public override void paint(Canvas canvas, Size size)
        {
            Rect rect = Offset.zero & size;

            if (trackType == TrackType.alpha)
            {
                Size  chessSize   = new Size(size.height / 2, size.height / 2);
                Paint chessPaintB = new Paint()
                {
                    color = new Color(0xffcccccc)
                };
                Paint chessPaintW = new Paint()
                {
                    color = Colors.white
                };

                int height = (size.height / chessSize.height).round();
                int width  = (size.width / chessSize.width).round();
                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        canvas.drawRect(
                            new Offset(chessSize.width * x, chessSize.width * y) & chessSize,
                            (x + y) % 2 != 0 ? chessPaintW : chessPaintB
                            );
                    }
                }
            }

            List <Color>   colors;
            LinearGradient gradient;

            switch (trackType)
            {
            case TrackType.hue:
                colors = new List <Color>
                {
                    HSVColor.fromAHSV(1f, 0f, 1f, 1f).toColor(),
                    HSVColor.fromAHSV(1f, 60f, 1f, 1f).toColor(),
                    HSVColor.fromAHSV(1f, 120f, 1f, 1f).toColor(),
                    HSVColor.fromAHSV(1f, 180f, 1f, 1f).toColor(),
                    HSVColor.fromAHSV(1f, 240f, 1f, 1f).toColor(),
                    HSVColor.fromAHSV(1f, 240f, 1f, 1f).toColor(),
                    HSVColor.fromAHSV(1f, 300f, 1f, 1f).toColor(),
                    HSVColor.fromAHSV(1f, 360f, 1f, 1f).toColor()
                };
                gradient = new LinearGradient(colors: colors);
                canvas.drawRect(rect, new Paint()
                {
                    shader = gradient.createShader(rect)
                });
                break;

            case TrackType.saturation:
                colors = new List <Color> {
                    HSVColor.fromAHSV(1f, hsvColor.hue, 0f, 1f).toColor(),
                    HSVColor.fromAHSV(1f, hsvColor.hue, 1f, 1f).toColor()
                };
                gradient = new LinearGradient(colors: colors);
                canvas.drawRect(rect, new Paint()
                {
                    shader = gradient.createShader(rect)
                });
                break;

            case TrackType.saturationForHSL:
                colors = new List <Color> {
                    HSVColor.fromAHSV(1f, hsvColor.hue, 0f, .5f).toColor(),
                    HSVColor.fromAHSV(1f, hsvColor.hue, 1f, .5f).toColor()
                };
                gradient = new LinearGradient(colors: colors);
                canvas.drawRect(rect, new Paint()
                {
                    shader = gradient.createShader(rect)
                });
                break;

            case TrackType.value:
                colors = new List <Color> {
                    HSVColor.fromAHSV(1f, hsvColor.hue, 1f, 0f).toColor(),
                    HSVColor.fromAHSV(1f, hsvColor.hue, 1f, 1f).toColor()
                };
                gradient = new LinearGradient(colors: colors);
                canvas.drawRect(rect, new Paint()
                {
                    shader = gradient.createShader(rect)
                });
                break;

            case TrackType.lightness:
                colors = new List <Color> {
                    HSVColor.fromAHSV(1f, hsvColor.hue, 1f, 0f).toColor(),
                    HSVColor.fromAHSV(1f, hsvColor.hue, 1f, 0.5f).toColor(),
                    HSVColor.fromAHSV(1f, hsvColor.hue, 1f, 1f).toColor()
                };
                gradient = new LinearGradient(colors: colors);
                canvas.drawRect(rect, new Paint()
                {
                    shader = gradient.createShader(rect)
                });
                break;

            case TrackType.red:
                colors = new List <Color> {
                    hsvColor.toColor().withRed(0).withOpacity(1f),
                    hsvColor.toColor().withRed(255).withOpacity(1f)
                };
                gradient = new LinearGradient(colors: colors);
                canvas.drawRect(rect, new Paint()
                {
                    shader = gradient.createShader(rect)
                });
                break;

            case TrackType.green:
                colors = new List <Color> {
                    hsvColor.toColor().withGreen(0).withOpacity(1f),
                    hsvColor.toColor().withGreen(255).withOpacity(1f)
                };
                gradient = new LinearGradient(colors: colors);
                canvas.drawRect(rect, new Paint()
                {
                    shader = gradient.createShader(rect)
                });
                break;

            case TrackType.blue:
                colors = new List <Color> {
                    hsvColor.toColor().withBlue(0).withOpacity(1f),
                    hsvColor.toColor().withBlue(255).withOpacity(1f)
                };
                gradient = new LinearGradient(colors: colors);
                canvas.drawRect(rect, new Paint()
                {
                    shader = gradient.createShader(rect)
                });
                break;

            case TrackType.alpha:
                colors = new List <Color> {
                    Colors.black.withOpacity(0f),
                    Colors.black.withOpacity(1f)
                };
                gradient = new LinearGradient(colors: colors);
                canvas.drawRect(rect, new Paint()
                {
                    shader = gradient.createShader(rect)
                });
                break;
            }
        }