Skip to content

Instantly share code, notes, and snippets.

@eightlines
Created March 8, 2013 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eightlines/5118487 to your computer and use it in GitHub Desktop.
Save eightlines/5118487 to your computer and use it in GitHub Desktop.
openFrameworks: When ofSetLineWidth is greater than 0 the corners don't line up. This script lines up the corner of the rectangle based on the Line Width.
void ofFrameRect(ofRectangle r, float lw, bool innerStroke = true) {
ofNoFill();
ofSetLineWidth(lw);
lw = ((innerStroke) ? -1 : 1) * lw / 2;
ofLine(r.x, r.y, r.x + r.width, r.y);
ofLine(r.x + r.width + lw, r.y, r.x + r.width + lw, r.y + r.height);
ofLine(r.x + r.width + lw, r.y + r.height + lw, r.x, r.y + r.height + lw);
ofLine(r.x + lw, r.y + r.height, r.x + lw, r.y + lw);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment