Skip to content

Instantly share code, notes, and snippets.

@mimetaur
Last active September 24, 2015 05:47
Show Gist options
  • Save mimetaur/700848 to your computer and use it in GitHub Desktop.
Save mimetaur/700848 to your computer and use it in GitHub Desktop.
Rounded rectangle in Processing
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