Skip to content

SP5: RenderGridLines does not use lineStyle.Pattern #2904

@minjjKang

Description

@minjjKang

Feature Suggestion

Feature description:

I want to use Grid's LineStyle.Pattern.

Code example:

DefaultGrid has LineStyle elements,
and Use LineStyle for RenderGridLines.

private void RenderGridLines(RenderPack rp, float[] positions, Edge edge, LineStyle lineStyle)
{
Pixel[] starts = new Pixel[positions.Length];
Pixel[] ends = new Pixel[positions.Length];
for (int i = 0; i < positions.Length; i++)
{
float px = positions[i];
starts[i] = edge.IsHorizontal() ? new Pixel(px, rp.DataRect.Bottom) : new Pixel(rp.DataRect.Left, px);
ends[i] = edge.IsHorizontal() ? new Pixel(px, rp.DataRect.Top) : new Pixel(rp.DataRect.Right, px);
}
Drawing.DrawLines(rp.Canvas, starts, ends, lineStyle.Color, lineStyle.Width);
}

However, RenderGridLines does not use LineStyle's Pattern element,
It is also not included in the parameters of Drawing.DrawLines used for grid drawing.

public static void DrawLines(SKCanvas canvas, Pixel[] starts, Pixel[] ends, Color color, float width = 1, bool antiAlias = true)


I am using it temporarily modify like below.
I hope to be able to use it formally in a better code. :>

thanks!

// DefaultGrid.RenderGridLines

private void RenderGridLines(SKSurface surface, PixelRect dataRect, float[] positions, Edge edge, LineStyle lineStyle)
{
    // ...

    Drawing.DrawLines(surface, starts, ends, lineStyle.Color, lineStyle.Width, lineStyle.Pattern);
    // Add Pattern parameter
}
// Drawing.DrawLines

public static void DrawLines(SKSurface surface, Pixel[] starts, Pixel[] ends, Color color, float width = 1, LinePattern pattern = LinePattern.Solid, bool antiAlias = true)
// Add LinePattern pattern = LinePattern.Solid
{
    // ...

    using SKPaint paint = new()
    {
        Color = color.ToSKColor(),
        IsStroke = true,
        IsAntialias = antiAlias,
        StrokeWidth = width,
        PathEffect = pattern.GetPathEffect()
        // Add PathEffect
    };
    
    // ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions