Want to draw text with a background color and foreground color

264 views
Skip to first unread message

Shuchi

unread,
Dec 23, 2022, 11:25:16 AM12/23/22
to skia-discuss
Hi,
I drew text on canvas using following code.
SKPath path = new SKPath();
                    //GetDiagonalCross
                    path.AddRect(new SKRect(1, 1, 6, 6));
                    path.Transform(SKMatrix.CreateRotationDegrees(45, 3.5f, 3.5f));
                    SKPath backgroundPath = new SKPath();     
                    SKPaint paint = new SKPaint()
                    {
                        Color = SKColors.Black,
                        Style = SKPaintStyle.Stroke,
                        StrokeWidth = 1,
                        PathEffect = SKPathEffect.Create2DPath(SKMatrix.CreateScale(width, height), path),
                        TextSize = 200,
                    };
 canvas.DrawText(text, 100, 200, paint);

Above code displays a Diagonal cross pattern as text style.
I want to use Black color for pattern drawing (which I am using in above code), and white color for background of pattern.
SKIA paint is not supporting two colors at a time. What is alternative to have both foreground color and background color with method canvas.DrawText
Reply all
Reply to author
Forward
0 new messages