-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Description
Feature Suggestion
Feature description:
I want to use Grid's LineStyle.Pattern.
Code example:
DefaultGrid has LineStyle elements,
and Use LineStyle for RenderGridLines.
ScottPlot/src/ScottPlot5/ScottPlot5/Grids/DefaultGrid.cs
Lines 51 to 64 in 42987b6
| 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
};
// ...
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels