Example #1
0
        private void drawRectangle(SSShape rectangle, SKCanvas canvas)
        {
            using (var paint = new SKPaint()) {
                paint.IsAntialias = true;

                SKRect rect = new SKRect();
                rect.Size = new SKSize(rectangle.size.width, rectangle.size.height);
                var position = PositionHelper.getPosition(rectangle.alignX, rectangle.alignY, rect.Width, rect.Height, canvasSize);
                rect.Location = new SKPoint(position.x, position.y);

                if (rectangle.fillStyle == FillStyle.Solid)
                {
                    SKColor.TryParse(rectangle.fillColor, out SKColor color);
                    color       = color.WithAlpha(rectangle.alpha);
                    paint.Color = color;
                }
                else if (rectangle.fillStyle == FillStyle.Gradient)
                {
                    var startPoint = GradientHelper.getRectPoint(rect, (SSGradientDirection)rectangle.gradient?.startPoint);
                    var endPoint   = GradientHelper.getRectPoint(rect, (SSGradientDirection)rectangle.gradient?.endPoint);
                    paint.Shader = GradientHelper.createGradient((SSGradient)rectangle.gradient, startPoint, endPoint);
                }
                canvas.DrawRect(rect, paint);
            }
        }
Example #2
0
        private void drawShape(SSShape shape, SKCanvas canvas)
        {
            switch (shape.type)
            {
            case ShapeType.Rectangle:
                drawRectangle(shape, canvas);
                break;

            case ShapeType.Circle:
                drawCircle(shape, canvas);
                break;
            }
        }
        private void drawGradientBackground(SKCanvas canvas)
        {
            SSShape gradientBg = new SSShape {
                size      = canvasSize,
                fillX     = true,
                fillY     = true,
                type      = ShapeType.Rectangle,
                fillStyle = FillStyle.Gradient,
                gradient  = background.gradient
            };

            gradientBg.setSize(canvasSize);
            SSShapeGenerator shapeGenerator = new SSShapeGenerator(new SSShape[] { gradientBg }, canvasSize);

            shapeGenerator.drawShapes(canvas);
        }
Example #4
0
 private void drawCircle(SSShape circle, SKCanvas canvas)
 {
 }