Created
March 8, 2013 18:06
-
-
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.
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 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