Re: [svgwg] Add circular arc path command 'R'. (#767)

Note that the commands "R"/"r" are already reserved for another cubic spline in the current draft (though this new cubic spline is still ill defined as it starts by a coordinate pair that is not joined to the current point as it is an off-curve control-point, with an implicit "pen-up" moveto to the second pair where the drawing starts, and the last pair is also not drawn as it is a bearing control-point.

I made a proposal (see "Path data: Catmull-Rom Command parameters" #797) to change the syntax of the proposed "R"/"r", allowing such arcs to be joined with the previous arc or segment and the next arc or segment, but also defining the behavior for the junction with the previous and next arcs)


Note that for *circular* arcs, you don't need three on-curve points, only two points are sufficient (but then the rendering would be sensitive to the current matrix which may not be orthonormal, it would still result in an ellipse even with two points beause of the matric transform): using matrix transforms if probably the easiest wazy to draw elliptic arcs: specificy a circle arc instead.

So I agree that we should have a "O"/"o" (circular arcto) or "E"/"e" (elliptic arcto) defined just by two or three on-point curves (with the first one being the last position of the current point). Both being subject to the matrix transform, so both can produce circles or ellipses:

* for "O"/"o" if the specified "medial" point is at the same position as the current point, this implies a circle with null radius, and it draws nothing (except the marker at the samle position?), and preservbes the current bearing; otherwise this is circle whose center is at the center between the current point and the specified "medial" point, so the circle is fully specified by one of its diameters.

* for "E"/"e", if the first specified point is equal to the last position of the current point, this is the same as dropping this point and drawing a circle passing with the second specified point; if the two specified points are equal, this is the same as dropping the first point and drawing a circle to the last point. Here also, and there's no change of value for the current point in any case.

However the bearing is modified: for a circle, it is orthogonal to the diameter, so we need to specify the clockwise or anticlockwise direction: this can be specified by adding one or two angles (for drawing a circular arc: consider a positive orientation of angles for comparing them according to the coordinates in the local transform matrix and not the final coordinates after transform), or by a sweep flag (from which the orientation can also be determined); we don't need a "small arc vs. large arc" flag for when specfiying angles; we can specfiy one or two angles: with one angle we just indicate the angle to rotate the bearing from an implicit start angle 0 (angle 0 is orthogonal to the x-axis bearing and downward on the y-axis, so the center would be positioned above the current point, so that the radius would sweep the angles in the direction of the second angle)

The "O"/"o" is then a shorthand for ellipse, but with two additional parameters (opposite-point [start-angle [end-angle]]). If you specify more than one coordinate pair for "O", you'll draw multiple circles passing by the same initial point (but not necessarily tangeant to each other, unless all specified points are aligned with the current point).

As well, if there are no angles at all for "O"/"o", a full circle is drawn and is implicitly closed and no markers are drawn; with angles, markers will be drawn at the start and end position of the arc, even if these angles span a 360° angle (in which case two markers will be drawn, unless they are suppressed by "K" flags as described below).

The "E"/e" ellipse takes no other angle or sweep flag, just 2 additional points by which the elliptical arc will pass through, plus a flag to indicate if it should be closed to join with the starting current point (this optional close-flag would be 0 by default, i.e. the elliptical arc is not closed and terminated at the last specified point and you get a single large or small sweep unclosed arc; with 1 you the second part of the ellipse is drawn and you get the full ellipse).

* "O/o" [start-angle [end-angle]] x y: circle or arc of circle, where the circle is specified by its diameter (current point and specified point)
* "E/e" close-flag x1 y1 x2 y2 : ellipse or elliptical arc, where the ellipse is specified by 3 points (current point and two specified poitns)

So "O x y" is shorthand for "E 1 x y x y"...

----

We should have a way to indicate that the next path fragment will draw a marker or not at the initial or final position of the fragment: "K initial-marker-flag [final-marker-flag]" would change the behavior (if the final-marker-flag is not set, it takes the same value as the initial-marker-flag, both flags being just 0 for removing the marker or non-zero for adding it; the initial-marker-flag is used only after a "pen down" command, the final-marker-flag being only used for the termination of every fragment, which won't add any marker, including if the fragment has a zero-length, but excluding "Z" closepath, ; I don't think we need any falg for intermediate flag, e.x. for a polygon drawn with a single "lineto"): contextually the other path fragments would reuse these flags, without having to define new "duplicate" commands for markerless strokes. These two flags would be 1 by default (unless there's another default specified in attributes of SVG elements using such path).


-- 
GitHub Notification of comment by verdy-p
Please view or discuss this issue at https://github.com/w3c/svgwg/issues/767#issuecomment-625966176 using your GitHub account

Received on Friday, 8 May 2020 18:57:17 UTC