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

Add warning when drawing with invalid shape constant. #4108

Closed

Conversation

sansumbrella
Copy link
Member

Previously, Java2D renderer silently fails to render LINE_LOOP and LINE_STRIP shapes. This adds a runtime warning when an invalid shape type is specified for the renderer.

Closes #4107

Previously, Java2D renderer silently fails to render LINE_LOOP and
LINE_STRIP shapes.
@sansumbrella
Copy link
Member Author

Things that would improve this:

  • a compile-time check warning of the line number (hard).
  • More details in the run-time error message (unknown difficulty; don't see an int => string conversion for PConstants).

@JakubValtar
Copy link
Contributor

Hi David, thanks for looking into this. To answer your improvement points:

  • If you throw IllegalArgumentException(String message) instead of warning, sketch will crash and PDE will highlight the line and display the message. We do both at different places, any preference @benfry?
  • You can switch on LINE_STRIP and LINE_LOOP to give customized message for these two and handle unknown constant in the default with a general error message.

Also, we might just want to implement these two instead of printing errors. It's fairly easy on the user side, should be easy on our side too. @benfry?

// LINE_STRIP
noFill();
beginShape();
vertex(...);
endShape();

// LINE_LOOP
noFill();
beginShape();
vertex(...);
endShape(CLOSE);

@benfry
Copy link
Contributor

benfry commented Feb 13, 2016

Both LINE_STRIP and LINE_LOOP should work with the default renderer. Are they not working?

@JakubValtar
Copy link
Contributor

They are not.

@benfry
Copy link
Contributor

benfry commented Feb 13, 2016

Scratch that; they were removed. They're not even in the reference and should probably be taken out of PConstants. They were taken out because LINE_STRIP is handled by using noFill() and endShape(), LINE_LOOP is done with noFill() and endShape(CLOSE).

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions GitHub Actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove unused PConstants
3 participants