Skip to content

add roundRect#828

Open
buntec wants to merge 1 commit into
scala-js:mainfrom
buntec:feature/canvas-round-rect
Open

add roundRect#828
buntec wants to merge 1 commit into
scala-js:mainfrom
buntec:feature/canvas-round-rect

Conversation

@buntec

@buntec buntec commented Jan 5, 2024

Copy link
Copy Markdown
Contributor

Hi there!

Before submitting a PR containing any Scala changes, please make sure you...

  • run sbt prePR
  • commit changes to api-reports

Thanks for contributing!

@buntec

buntec commented Jan 5, 2024

Copy link
Copy Markdown
Contributor Author

Alas, that radii param is a mess to encode (probably why this method was missing in the first place).

@zetashift

Copy link
Copy Markdown
Contributor

Alas, that radii param is a mess to encode (probably why this method was missing in the first place).

Oh yup, from https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-roundrect

If radii is an unrestricted double or [DOMPointInit] (https://drafts.fxtf.org/geometry/#dictdef-dompointinit), then set radii to « radii ».

If radii is not a list of size one, two, three, or four, then throw a RangeError.

I wonder if we should create a new enum type that encodes this or just stick with Any. What do you think @armanbilge?

Comment on lines +172 to +173
/** Creates a path for a rounded rectangle with a specified position, width, height, and corner radii. */
def roundRect(x: Double, y: Double, w: Double, h: Double, radii: js.Any): Unit = js.native

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Instead of js.Any can we add several overloads of this method for the various types of radii?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants