コード例 #1
0
ファイル: SkRenderer.cs プロジェクト: Winster332/Marble
        public void DrawString(string text, RFont font, RBrush brush, int x, int y, StringFormat format, bool useStack = true)
        {
            if (useStack)
            {
                Bus.Publish(new DrawTextCommand(text, font, (RBrush)brush.Clone(), x, y, format));
            }
            else
            {
                var b = ((BrushAdapter)brush).Brush;
                // var color = default(SKColor);

                // if (b is SolidBrush)
                // {
                // var solid = b as SolidBrush;
                // color = new SKColor(solid.Color.R, solid.Color.G, solid.Color.B, solid.Color.A);
                // }

                var f     = ((FontAdapter)font).Font;
                var paint = PaintFromFont(f);
                paint.Color = b.Color;

                _c.DrawText(text, x, y, paint);

                if (GloablRenderSettings.IsDebug)
                {
                    var textSize = GetTextBound(text, paint);
                    _c.DrawRect(x, y - textSize.Height, textSize.Width, textSize.Height, new SKPaint
                    {
                        Style = SKPaintStyle.Stroke,
                        Color = SKColors.Coral
                    });
                }
            }
        }
コード例 #2
0
ファイル: SkRenderer.cs プロジェクト: Winster332/Marble
        public void FillRectangle(RBrush brush, float x, float y, float w, float h, bool useStack = true)
        {
            if (useStack)
            {
                Bus.Publish(new FillRectCommand((RBrush)brush.Clone(), x, y, w, h));
            }
            else
            {
                var b = ((BrushAdapter)brush).Brush;
                // var color = default(SKColor);
                // var skPaint = new SKPaint
                // {
                // Style = SKPaintStyle.Fill,
                // };

                // if (b is SolidBrush)
                // {
                // var solid = b as SolidBrush;
                // skPaint.Color = new SKColor(solid.Color.R, solid.Color.G, solid.Color.B, solid.Color.A);
                // } else if (b is LinearGradientBrush)
                // {
                // var gradient = b as LinearGradientBrush;
                // var colors = gradient.LinearColors.Select(c => new SKColor(c.R, c.G, c.B, c.A)).ToArray();
                // var skRectStart = new SKPoint(gradient.Rectangle.Left, gradient.Rectangle.Top);
                // var skRectEnd = new SKPoint(gradient.Rectangle.Right, gradient.Rectangle.Bottom);
                // skPaint.Shader = SKShader.CreateLinearGradient(skRectStart, skRectEnd, colors,
                // new[] {0.0f, 1.0f}, SKShaderTileMode.Repeat);
                // }

                // TODO: Тут не только Solid
                _c.DrawRect(x, y, w, h, b);
            }
        }
コード例 #3
0
ファイル: SkRenderer.cs プロジェクト: Winster332/Marble
        public void FillPolygon(RBrush brush, SKPoint[] points, bool useStack)
        {
            if (useStack)
            {
                Bus.Publish(new FillPolygonCommand((RBrush)brush.Clone(), points));
            }
            else
            {
                var b = ((BrushAdapter)brush).Brush;
                b.IsAntialias = true;
                var skPath = new SKPath();
                skPath.AddPoly(points, true);

                // var color = default(SKColor);
                //
                // if (b is SolidBrush)
                // {
                //  var solid = b as SolidBrush;
                //  color = new SKColor(solid.Color.R, solid.Color.G, solid.Color.B, solid.Color.A);
                // }

                _c.DrawPath(skPath, b);
            }
        }
コード例 #4
0
ファイル: SkRenderer.cs プロジェクト: Winster332/Marble
        public void FillPath(RBrush brush, SKPath path, bool useStack = true)
        {
            if (useStack)
            {
                Bus.Publish(new FillPathCommand((RBrush)brush.Clone(), new SKPath(path)));
            }
            else
            {
                var b = ((BrushAdapter)brush).Brush;
                b.IsAntialias = true;
                // var skPath = new SKPath();
                // skPath.AddPoly(path.PathPoints.Select(p => new SKPoint(p.X, p.Y)).ToArray(), true);

                // var color = default(SKColor);
                //
                // if (b is SolidBrush)
                // {
                //  var solid = b as SolidBrush;
                //  color = new SKColor(solid.Color.R, solid.Color.G, solid.Color.B, solid.Color.A);
                // }

                _c.DrawPath(path, b);
            }
        }