From 73bcfc04769404204746d1fa32be8b9995cae5df Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 15 Nov 2024 13:38:48 -0500 Subject: [PATCH] path-stroke.md: add note on dashs --- notes/path-stroke.md | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/notes/path-stroke.md b/notes/path-stroke.md index bd13d42..be9d455 100644 --- a/notes/path-stroke.md +++ b/notes/path-stroke.md @@ -135,3 +135,53 @@ Starts with: > case, the line caps are always painted, since their orientation is determined > by the direction of the underlying path.) A single-point open subpath > (specified by a trailing m operator) produces no output. + +Dashing +------- + +Looks basically the same across all three: + +### Canvas + + + +* `context.setLineDash(segments)` +* `context.lineDashOffset` + +("If the number of elements in segments is odd, then let segments be the +concatenation of two copies of segments.") + +### SVG + + + +* `stroke-dasharray` +* `stroke-dashoffset` + +("If the list has an odd number of values, then it is repeated to yield an even +number of values.") + +("If all of the values in the list are zero, then the stroke is rendered as a +solid line without any dashing.") + +Both relative to . + +### PDF + +[PDF 1.7 spec, p217, 4.3.2 Details of Graphics State Parameters, Line Dash Pattern](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/pdfreference1.7old.pdf#page=217): + +> The line dash pattern controls the pattern of dashes and gaps used to stroke +> paths. +> It is specified by a dash array and a dash phase. The dash array’s elements +> are numbers that specify the lengths of alternating dashes and gaps; the +> numbers must be nonnegative and not all zero. +> [...] +> The ends of each dash are treated with the current line cap style, and +> corners within dashes are treated with the current line join style. +> [...] +> When a path consisting of several subpaths is stroked, each subpath is +> treated independently—that is, the dash pattern is restarted and the dash +> phase is reapplied to it at the beginning of each subpath. + +No word on what to do on odd number of values in array; presumably the same +as in the other two specs.