Skip to content

path.arc(…anticlockwise) must be true or 1, not truthy #21

@Fil

Description

@Fil

We have cw = 1 ^ ccw

  • 0, "0"(edited), undefined, false => draws a clockwise arc
  • 1, "1", true => draws an anticlockwise arc

So far so good, but trying with anticlockwise = "anticlockwise" or anticlockwise = 3 (or most other truthy values) will give a very weird path with an inverted curvature, because it will have both ccw truthy, and cw = 1.

I don't think the code should be fixed as this is probably the fastest approach, but maybe the documentation?

Currently we say

If anticlockwise is true, the arc is drawn in the anticlockwise direction; otherwise, it is drawn in the clockwise direction

"otherwise" could be changed to "if false or undefined", or "if false"…

Another possibility:

If anticlockwise, a boolean, is true, the arc is drawn in the anticlockwise direction; otherwise, it is drawn in the clockwise direction.

(I got bitten by using a checkbox’s value, which gave me anticlockwise="On".)

See interactive test at https://observablehq.com/d/d8c04cb491a6c444

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions