Skip to content
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

error when ellipse has negative width and height #413

Closed
shiffman opened this issue Nov 7, 2014 · 6 comments
Closed

error when ellipse has negative width and height #413

shiffman opened this issue Nov 7, 2014 · 6 comments

Comments

@shiffman
Copy link
Member

shiffman commented Nov 7, 2014

The following:

ellipse(width/2,height/2,-1,-1);

produces:

Uncaught IndexSizeError: Failed to execute 'arc' on 'CanvasRenderingContext2D': The radius provided (-0.5) is negative.

I'm not sure what the proper behavior should be since this isn't really valid code, but Processing I believe draws the ellipse with the absolute value of the negative values (inverted?).

The behavior for rect(100,100,-50,-50) for example draws the rectangle, but inverted (i.e. pointing up and to the left).

@crhallberg
Copy link

Processing behavior confirmed.
confirm

@GoToLoop
Copy link
Contributor

GoToLoop commented Nov 7, 2014

I've already more or less reported about that in:
http://forum.processing.org/two/discussion/7147/some-simple-pulse-equations-using-trig-#Item_11
https://github.com/lmccart/p5.js/issues/383

Function ellipse() can't have negative dimensions.

I had to use abs() before passing the argument. That is true for both P5.JS & Processing.JS!

triss added a commit to triss/p5.js that referenced this issue Nov 12, 2014
… now no longer throws an error when negative sizes are specified. processing#413
@lmccart
Copy link
Member

lmccart commented Nov 23, 2014

@lmccart lmccart closed this as completed Nov 23, 2014
@GoToLoop
Copy link
Contributor

Unfortunately, that https://github.com/lmccart/p5.js/pull/416 fix doesn't extend the same principle to rect() & arc()! 😔

@lmccart
Copy link
Member

lmccart commented Nov 23, 2014

@GoToLoop rect already supports this

@GoToLoop
Copy link
Contributor

I fail to spot any Math.abs() upon "width" & "height" parameters before calling canvas.modeAdjust() in rect()! And from the P5.JS's reference page, rect() w/ negative dimensions is still bugged!
Perhaps it's not updated to latest merged version... 😳

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

No branches or pull requests

4 participants