-
Notifications
You must be signed in to change notification settings - Fork 133
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
Allow stroke-dasharray/dashoffset % to be specified relative to path length #177
Comments
Possible alternatives:
|
New units are much better than context switches, yes. |
I like that. Could we add pl to CSS Units? Then the already specified length would just work. |
It just occurred to me that it might be better as:
Ie. as a percent value. The numbers are easier to read and it has a precedent in vw/vh. |
Yeah, standard approach for "percent-like" units is to make 100 of them equal the desired length; that's what the viewport units do already. I'll open an issue on CSS for a |
Adding a new unit does not allow extension to segment-based dashing, as part of a more complex SVG Strokes proposal. (The segment vs path switch doesn't seem to be in the current draft, but I know we'd discussed it. Or maybe we'd only discussed it for markers, but I'd like to have it for both.) I also just find new acronyms horribly obscure, while |
I don't understand. What part of a new unit doesn't allow that, that a % with a switch does? |
@tabatkins It doesn't prohibit it. We'd just need another new unit, which seems a lot more complicated than a new keyword. More generally: units are defined globally. What would |
@AmeliaBR Do you actually mean segment-based, or subpath-based? |
@nikosandronikos I mean segment-based (e.g., sides of a polygon). But sub-path is another use case that it would be nice to include. Again, easier to add that in with a keyword than another unit. |
Since there wasn't a clear consensus on syntax, I'm removing the milestone & leaving this as a new feature for the SVG Strokes module. Don't want to lock in to a sub-optimal syntax without thinking it through. |
I still believe the best solution is to redefine % as relative to path length. This is consistent with how the attribute 'startOffset' is defined. The amount of content this would break must be insignificant compared (next to zero as the current definition is essentially useless) to what we are breaking with other changes. Introducing a new keyword or unit seems to be overkill. |
I'm not sure how insignificant it would be. There are some cases where you do want to set stroke-width as a percentage length. In that case, you would need to set stroke-dashes using percentage lengths in order to have the dash length scale proportionally to its width. E.g., Kevin Mark's sparklines library uses percentages in stroke width to keep a reasonable stroke width for the size of the chart even though the viewBox & coordinates are scaled to the data. The use case may be small compared to the path-drawing-dashes effect, but it's realistic enough not to want to break it. |
From a test by Ana Tudor I am reminded that the default behavior in all major browsers is to re-start stroke dash patterns for each sub-path, not to continue them for the entire path. So that would be another aspect that it would be nice to control with extra keywords. |
This is a frequent author request, and is much simpler than the full set of stroke-dashing options proposed in the SVG Strokes module. I'd like to get it into SVG 2.
Simple backwards & forewards compatible syntax is to add an optional
path
keyword at the beginning or end of either property's value grammar. In future, we can still add segment-relative dashing or space/round keywords to adjust dash length to fit. I was going to suggest segment-relative percentages as well, but that gets into the messy issue of how to restart the dash pattern for each segment, which was a problem for implementations that use underlying libraries without that feature.Path-length relative percentages are a simple implementation, in contrast: just need to calculate total path length and use that to resolve the author-specified values into absolute used lengths.
The text was updated successfully, but these errors were encountered: