Skip to content

Commit

Permalink
Fix color rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Jan 27, 2024
1 parent e40c357 commit b794cb8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Avalonia.Svg/AvaloniaModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ public static AVMI.BitmapInterpolationMode ToBitmapInterpolationMode(this SKFilt
}
}

private static AM.IImmutableBrush ToSolidColorBrush(this SKColor color)
{
return new AMII.ImmutableSolidColorBrush(color.ToColor());
}

private static AM.IImmutableBrush ToSolidColorBrush(this ColorShader colorShader)
{
var color = colorShader.Color.ToColor();
Expand Down Expand Up @@ -473,7 +478,11 @@ public static AM.GradientSpreadMethod ToGradientSpreadMethod(this SKShaderTileMo

private static AM.IPen ToPen(this SKPaint paint, SKRect bounds)
{
var brush = ToBrush(paint.Shader, bounds);
var brush = paint.Shader is not null
? ToBrush(paint.Shader, bounds)
: paint.Color is not null
? ToSolidColorBrush(paint.Color.Value)
: null;
var lineCap = paint.StrokeCap.ToPenLineCap();
var lineJoin = paint.StrokeJoin.ToPenLineJoin();

Expand Down Expand Up @@ -506,7 +515,11 @@ public static (AM.IBrush? brush, AM.IPen? pen) ToBrushAndPen(this SKPaint paint,

if (paint.Style == SKPaintStyle.Fill || paint.Style == SKPaintStyle.StrokeAndFill)
{
brush = ToBrush(paint.Shader, bounds);
brush = paint.Shader is not null
? ToBrush(paint.Shader, bounds)
: paint.Color is not null
? ToSolidColorBrush(paint.Color.Value)
: null;
}

if (paint.Style == SKPaintStyle.Stroke || paint.Style == SKPaintStyle.StrokeAndFill)
Expand Down

0 comments on commit b794cb8

Please sign in to comment.