-
Notifications
You must be signed in to change notification settings - Fork 26
Add more details to roundRect proposal #12
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,39 @@ Proposal | |
-------- | ||
|
||
```webidl | ||
|
||
|
||
interface mixin CanvasPath { | ||
// all doubles are unrestricted. | ||
void roundRect(double x, double y, double w, double h, sequence<double> radius); | ||
void roundRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h, sequence<(unrestricted double or DOMPoint)> radii); | ||
}; | ||
``` | ||
|
||
`radius` specifies the radius of corners. Each corner is represented by a single radius. | ||
|
||
If `radius.length == 1` then all 4 corners have the same length. | ||
If `radii.length == 1` then all 4 corners have the same length. | ||
|
||
If `radii.length == 2` then the first value applies to the top-left and bottom-right corners, and the second value applies to the top-right and bottom-left corners. | ||
|
||
If `radii.length == 3` then the first value applies to the top-left corner, the second value applies to the top-right and bottom-left corners, and the third value applies to the bottom-right corner. | ||
|
||
If `radii.length == 4` then each corner is specified, in order: top-left, top-right, bottom-right, bottom-left. | ||
|
||
If `w` and `h` are both greater than or equal to 0, or if both are smaller than 0, then the primitive is drawn clockwise. Otherwise, it is drawn conterclockwise. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: double space in "greater.than..or". Also this [counter]clockwise thing sounds a bit open to interpretation and confusing. Wouldn't reusing a similar prose to the one for rect() be clearer? (defining which points are to be drawn in which order no matter the input's values). |
||
|
||
When `w` is negative, the rounded rectangle is flipped horizontally, which means that the radius values that apply to the left corners, are actual used on the right and vice versa. Similarly, when `h` is negative, the rounded rect is flipped vertically. | ||
|
||
When a value `r` in `radii` is a `DOMPoint`, the corresponding corner(s) are drawn as elliptical arcs whose x and y radii are equal to `r.x` and `r.y`, respecively. | ||
|
||
When a value `r` in `radii` is a `double`, the corresponding corner(s) are drawn as circular arcs of radius `r`. | ||
|
||
When the sum of the radii of two corners of the same edge is greater than the length of the edge, the all the radii of the rounded rectangle are scaled by a factor of len/(r1+r2). If multiple edges have this property, the scale factor of the edge with the smallest scale factor is used. This is consistent with CSS behaviour. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "the all the radii" -> "then all the radii" |
||
|
||
If a value in `radii` is a negative number, then roudRect() throws an `IndexSizeError` DOM Exception. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's not in CSS nor even in Skia yet, but what about allowing concave angles? Would that be too much overhead? |
||
|
||
If a value in `radii` is a `DOMPoint` whose `x` or `y` attributes are negative numbers, then roundRect() throws an `IndexSizeError` DOM Exception. | ||
|
||
If `radius.length == 4` then each corner is specified, in order: top left, top right, bottom right, bottom left. | ||
If any of `x`, `y`, `width` or `height` ar non-finite numbers, or if a value in radii is a non-finite number, or if a value of `radii` is a DOMPoint who `x` or `y` attributes are non-finite numbers, the roundRect aborts without throwing an exception and without adding anything to the current path. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typos: And while we're at typos, l13 also has one "Even thought" -> "Even though" |
||
|
||
|
||
### Open issues and questions | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
radius
has been renamedradii
.