-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Webgl / add styling options for lines: joins, caps, offset, dash #15058
Conversation
72ca788
to
e6a7b64
Compare
📦 Preview the website for this branch here: https://deploy-preview-15058--ol-site.netlify.app/. |
Wow. Nice work. Will review more thoroughly later. Looks like line-cap may only apply to the end of the line. Is that intentional? |
Yes it does, did I miss something? Line cap is used when the segment is not connected to another one basically, otherwise it's line join. |
Also support closed lines when generating the webgl buffers Join angles for each segment are now stored with a better precision, which makes the visual glitches/seams disappear at the joins
also support miter limit for joins
e6a7b64
to
d2acb95
Compare
Just noticed a huge glitch on the edit: fixed, the issue was caused by applying an offset on a line where some segments were colinear and going in opposite direction; the join angle was then 2π which meant that the point was offset to infinity. In this commit I made it so that the offset would be applied similar to a line cap if the join angle was too high, see last commit. |
9053008
to
4284c7f
Compare
I should have clarified. I meant "end" as opposed to the "start" of a line. I would expect the line-cap to apply to both ends of a line. Instead, I'm seeing the line-cap applied somewhat inconsistently to only one end of the lines (it looks partially transparent at the end of one line and absent from the start of all lines). |
@jahow - I see that dashes may have been a distraction. I didn't try with a dash-free line to see that the cap style applies to both ends of the line. It does seem like it would be nice if it worked with dashed lines as well. |
The visual result for round caps isn't great and will have to be improved.
f6046f9
to
0aefbd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @jahow.
Separately, maybe we should discuss the |
Indeed, that feels a little too verbose currently! |
This PR adds support for the following styling options:
stroke-line-cap
: this can be eithersquare
,butt
orround
stroke-line-join
: this can be eitherbevel
,miter
orround
stroke-offset
: this property works like theline-offset
property from the MapLibre specstroke-miter-limit
: miter ratio limitstroke-line-dash
: this can be an array of expressions; currently the size of the array cannot be the result of an expressionstroke-line-dash-offset
: dash array offset in pxMost of these properties work exactly like their counterpart from the Canvas renderer. The offset property is not available in canvas yet though.
I've also added an example to try out different combinations:
https://deploy-preview-15058--ol-site.netlify.app/en/latest/examples/webgl-draw-line.html
Note: this PR also fixes a bug where the width of the stroke on screen used to be multiplied by 2 by mistake.
To do: