-
Notifications
You must be signed in to change notification settings - Fork 331
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
Dashed or dotted stroke #146
Comments
An excellent idea! Unfortunately it's not native to HTML5 http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas |
Great! |
The problem with any solution that uses a point to point, straight line drawing algorithm is that the line segments joining coordinates (on a poly, for example) are generally too short to provide space for dashes - single pixel dots perhaps - but not dashes. On a complex area outline, it might be possible (necessary even) to draw curves joining some number of coordinates. This would require drawing the curves for a specific linear distance (defined by the actual distance between sequential coords) and skipping some predefined distance to provide the spaces between dashes. For larger distances between coords, a separate computation would be required to break up a distance > a single dash + space. Egads - the complexity grows. Integrating the solution provided in Jamie's link is not that difficult - but the result would not be a dashed line if simply drawing a dashed line between the "area" coordinates. The newer html5 spec for canvas provides context.setLineDash([d,s]); which works well for circles and rectangles. It also works well for irregular polygons with sufficient space between coords to allow drawing space for the dashes (and spaces). However, again for complex polygons with coords close together, the problem remains of "not enough space on the line segment to draw a dash". Note that context.setLineDash([d,s]); still is not implemented across all major bowsers. (Chrome, IE, Opera - YES: FF, Safari - NO). This will likely change - soonish, of course. Update: Good News It seems that dashes are displayed with all the problems of coordinates VERY close together TAKEN CARE OF FOR US :-)) A very complex area with coords almost next to each other STILL displays the dashes at the requested length and spacing. If you are interested, I have a change to ImageMapster Version: 1.2.10 (2/25/2013) - (the IM js file), which provides the ability to specify dashed or solid strokes, and to provide the dash length and space between dashes. Tested OK in Chrome, IE, and Opera. Not supported in FF or Safari (yet). Two new config options control the stroke: "strokeType : 'dashed | solid'", (default = solid) and "strokeDashes : [l,s]", (default = [5,3]). Let me know if you would like more info. |
Hi,
Would it be possible to have dashed or dotted strokes as a complement to solid line?
Thank you, Bo
The text was updated successfully, but these errors were encountered: