O'Reilly logo

Mastering openFrameworks: Creative Coding Demystified by Denis Perevalov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Rotating images

The image.draw() method does not have parameters to rotate images on arbitrary angles. To achieve this effect, we need to work with coordinate system transformations, which are described in detail in the Coordinate system transformations section in Chapter 2, Drawing in 2D.

We need to carry out the following steps for drawing a rotated image:

  1. Store the current transformation matrix using ofPushMatrix().
  2. Change the matrix by applying rotation transformation using ofRotate().
  3. Draw the image using image.draw().
  4. Restore the original transformation matrix using ofPopMatrix().

The following code illustrates these steps. It draws the image rotated at 10 degrees around the current center of coordinates, which is (0, 0).

void testApp::draw(){ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required