gl-vis / regl-line2d

:part_alternation_mark: Draw 2d polyline with regl
https://gl-vis.github.io/regl-line2d
MIT License
59 stars 15 forks source link

Dash section #38

Open dy opened 6 years ago

dy commented 6 years ago

This PR resolves https://github.com/plotly/plotly.js/issues/2946 and https://github.com/a-vis/regl-line2d/issues/13. The technique is straight: a segment direction is snapped to one of possible dash pattern directions, by default 8. That gives the following solutions:

3 patterns: image

4 patterns: image

5 patterns: image

6 patterns: image

7 patterns: image

8 patterns (default): image

9 patterns: image

10 patterns: image

12 patterns: image

16 patterns: image

20 patterns: image

40 patterns: image

No snapping: image

That is still imperfect - pattern is broken at some joins, but that number of broken joins is reduced from every segment to sufficiently different segments.

dy commented 6 years ago

Possible corrections:

etpinard commented 6 years ago

Thanks @dy !

Looks like line coloring is broken though off this branch:

image

see all image diffs:

https://github.com/plotly/plotly.js/compare/dima-dash-lines

etpinard commented 6 years ago

Great @dy Much better now: https://github.com/plotly/plotly.js/compare/dima-dash-lines

etpinard commented 6 years ago

cc @alexcjohnson any thoughts on Dima's fix here?

alexcjohnson commented 6 years ago

Very interesting strategy @dy, I like it! I think 8 patterns is a good compromise between join mismatches and dash pattern misalignment. But I'd make sure we have exact horizontal & vertical patterns, since those are very common cases and we don't want to bias viewers into thinking a horizontal line is slightly tilted tilted lines

mitja-p commented 4 years ago

@dy is there any reason why the conflict has not been solved? This is a good idea and would fix plotly problems with dashed/dotted lines.

dy commented 4 years ago

@etpinard @archmoj is that still of any interest? Should me or @archmoj spend some time merging that? Not sure I'll be able to test against all plotly cases.