Last active
September 24, 2015 05:47
-
-
Save mimetaur/700848 to your computer and use it in GitHub Desktop.
Rounded rectangle in Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void roundedRect(float x, float y, float w, float h, float rx, float ry) { | |
beginShape(); | |
vertex(x,y+ry); //top of left side | |
bezierVertex(x,y,x,y,x+rx,y); //top left corner | |
vertex(x+w-rx,y); //right of top side | |
bezierVertex(x+w,y,x+w,y,x+w,y+ry); //top right corner | |
vertex(x+w,y+h-ry); //bottom of right side | |
bezierVertex(x+w,y+h,x+w,y+h,x+w-rx,y+h); //bottom right corner | |
vertex(x+rx,y+h); //left of bottom side | |
bezierVertex(x,y+h,x,y+h,x,y+h-ry); //bottom left corner | |
endShape(CLOSE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment