Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

ofSetLineWidth maximum value

$
0
0

Just came across this issue so wrote a little function to draw a rectangle representation of a line. I know this topic is 5 years old but was one of the first search results I found, so might be of use to someone.

Possibly it would be more correct to use ofPoint instead of ofVect2f here as the vector parameters do refer to points on the screen.

  drawLineAsRect(ofVec2f startVec, ofVec2f endVec,float thickness) {
    float angle = atan((endVec.y-startVec.y)/(endVec.x-startVec.x));
    ofPushMatrix();
    ofTranslate(startVec.x,startVec.y);
    ofRotate(ofRadToDeg(angle));
    float lineLength = (endVec.x - startVec.x)/cos(angle);
    ofRect(0,-thickness/2,lineLength,thickness);
    ofPopMatrix();
}

Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>