Reputation: 21082
I would like to draw a polygon for example, or draw a text in such way that the color of the outline is different than the color of the fill ("content"). I found out the property ColorF
inside SKPaint
and I guessed all it takes is to change style to StrokeAndFill
-- well, I wrong guess, I got single color. In the following example the single color is ColorF
(with DrawText
it is Color
).
Visually I can achieve the desired effect using two passes, but I wonder if this is possible with one step.
Example of drawing and filling polygon:
using (var sk_paint = new SKPaint
{
Style = SKPaintStyle.StrokeAndFill,
Color = outline_color,
ColorF = fill_color,
IsAntialias = true,
StrokeWidth = (float)thickness
})
{
using (var path = new SKPath { FillType = SKPathFillType.EvenOdd })
{
path.MoveTo(points.First().x, points.First().y);
foreach (var p in points.Skip(1))
path.LineTo(p.x, p.y);
path.Close();
canvas.DrawPath(path, sk_paint);
}
}
As for lines I found it (RTFM ;-)) https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/curves/effects#path-outlining I wonder if ColorF
is not some sort of leftover. Anyway, I am still interested in drawing text with outline.
Upvotes: 0
Views: 712
Reputation: 1558
The answer is: you can't. Both color properties (Color
and ColorF
) of SKPaint
set the same SKColorF
value internally (Color
being converted into ColorF
). The 'F' in ColorF
indicates the RGBA values are stored as floats instead of bytes.
Upvotes: 3