From 74935682df6a32031d410f7fedb0ded3ed4b2497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20S=CC=8Colte=CC=81s?= Date: Sun, 24 Nov 2024 14:27:17 +0100 Subject: [PATCH] Fix color generation --- src/Svg.CodeGen.Skia/SkiaCSharpModelExtensions.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Svg.CodeGen.Skia/SkiaCSharpModelExtensions.cs b/src/Svg.CodeGen.Skia/SkiaCSharpModelExtensions.cs index bc0e9c3f..de935bc6 100644 --- a/src/Svg.CodeGen.Skia/SkiaCSharpModelExtensions.cs +++ b/src/Svg.CodeGen.Skia/SkiaCSharpModelExtensions.cs @@ -1421,9 +1421,13 @@ public static void ToSKPaint(this SKPaint paint, SkiaCSharpCodeGenCounter counte sb.AppendLine($"{indent}{counter.PaintVarName}{counterPaint}.TextEncoding = {paint.TextEncoding.ToSKTextEncoding()};"); } - if (paint.Color is { } && paint.Color.Value.Alpha != 255 && paint.Color.Value.Red != 0 && paint.Color.Value.Green != 0 && paint.Color.Value.Blue != 0) + if (paint.Color is { }) { - sb.AppendLine($"{indent}{counter.PaintVarName}{counterPaint}.Color = {(paint.Color is null ? "SKColor.Empty" : ToSKColor(paint.Color.Value))};"); + // Skip default color + if (paint.Color.Value is not { Alpha: 255, Red: 0, Green: 0, Blue: 0 }) + { + sb.AppendLine($"{indent}{counter.PaintVarName}{counterPaint}.Color = {(paint.Color is null ? "SKColor.Empty" : ToSKColor(paint.Color.Value))};"); + } } if (paint.Shader is { })