Drawing a rectangle on a diagonal angle

Hey guys, I’m slowing compling away at creating this interactive program in which a bear will animate to show 3 different emotions when the user brings foods to it’s face.

Using circle collision detection, noise, and and push pop matrixes I was able to create a sad face emotion…

Now I’m tackling the angry emotion and I’d like to draw very thin rectangles on the bears face as eyebrows diagonally to reflect that it’s upset.

Can anyone share any code on drawing a shape or line diagonally? Would be really helpful.

you could draw your rectangle using ofPolyline and then rotate it on the z axis.

ofPolyline poly;
// add the vertices that compose the rectangle with poly.addVertex();
poly.rotate(90, glm::vec3(0, 0, 1));
poly.translate(glm::vec2(ofGetWidth()/2, ofGetHeight()/2));

You can even draw the shape directly rotated, just positioning the vertices in the way you want. This would avoid using rotate and translate. With ofPolyline you can draw any shape and line you want, have a look at the tutorial in the ofBook.
http://openframeworks.cc/ofBook/chapters/lines.html

Maybe ofRotateZDeg(angle) is simpler (to avoid getting into glm and ofPolyline)?

    ofTranslate(200, 100); // where on the screen
    ofRotateZDeg(45); // rotate 45 degrees
    ofDrawRectangle(0, 0, 200, 20); // draw the shape