Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to draw different colors along the normal direction of the line using an offset value? #2480

Open
The2S opened this issue Jan 30, 2024 · 2 comments
Labels

Comments

@The2S
Copy link

The2S commented Jan 30, 2024

I try to draw some more colorful line on the map but failed,it looks like it's not even supported in SKPath with SKPaint.
Like this, use to show administrative boundaries
2_SY`KB07LWI_03KPOU Y}U
0L}XHEH$K0T0 D){4ZFV8R5

or this,use to show transportation information in big resolution with different direction,I think using an offset value may be able to achieve that, but I can't find a simple way to do it.
2@0H3DG6U8XI121N`TDNA(1

Many thanks!

@The2S The2S changed the title Any way to draw different color in normal direction of the line? Any way to draw different colors along the normal direction of the line using an offset value? Jan 30, 2024
@charlenni
Copy link
Member

I think, that should possible with a shader in the SKPaint of the path. I would start with research in SkiaSharp or Skia. Perhaps you find there a solution.

@pauldendulk
Copy link
Member

pauldendulk commented Feb 3, 2024

This is mostly a SkiaSharp question so you could also ask it there (after you searched for previous questions on this topic of course). https://github.com/mono/SkiaSharp

Dash Patterns

It is possible to use dash patterns in SkiaSharp. We use this in our sample "Tests" | "Line", like this:

feature = new GeometryFeature(wktReader.Read("LINESTRING (7000000 12000000, 13000000 12000000)"));
feature.Styles.Add(new VectorStyle { Line = new Pen(Color.Blue) { PenStyle = PenStyle.DashDot } });

A screenshot of the sample copied from the blazor samples (https://mapsui.com/samples/):

image

Combining colors

As far as I know you can use only one color in such a draw operation. My way to go about this would be to have two draw operations. The first color could be a solid line, and on top of that draw the dashed line, so the solid line fill the gaps in the dashed line.

Note, that for a good solution where the line looks the same while panning and zooming you need to take into account the offset (of the origin of the path is not visible in the image you need to correct for that) and the scale (the dash pattern is different for different scales to make it appear the same to the user).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants