-
Book Overview & Buying
-
Table Of Contents
OpenFrameworks Essentials
By :
Let's load an image file and draw it on the screen. We will not want to change the pixel values, so we will use the ofTexture class for this task. Perform the following steps:
Add the image object definition to the ofApp class:
ofTexture image;
Add the command for loading the image from the collage.png file to setup():
ofLoadImage( image, "collage.png" );
At the beginning of the draw() function, right after the ofBackground... command, add the code for drawing the image:
ofSetColor( 255 ); image.draw( 0, 0, ofGetWidth(), ofGetHeight() );
The first line sets up the white drawing color, which serves here as an image drawing color (see the details about the ofSetColor function in Chapter 2, Creating Your First openFrameworks Project). By setting the color to white, we are guaranteed that the image will be drawn without color change.
Setting another color will lead to changing the appearance of the image on the screen. For example, if we use the ofSetColor( 0, 255, 0 ) command...
Change the font size
Change margin width
Change background colour