O'Reilly logo

openFrameworks Essentials by Denis Perevalov, Igor Tatarnikov

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

2D drawing

The basic drawing functions are the following (see Chapter 2, Creating Your First openFrameworks Project, for details):

Example of function usage

Description

ofBackground( ofColor::white );

This sets the background to the white color.

float w = ofGetWidth();

The ofGetWidth() function returns the current width of the application's screen in pixels. In this code, this value is set to the variable w.

float h = ofGetHeight();

The ofGetHeight() function returns the current height of the application's screen in pixels. In this code, this value is set to the variable h.

ofLine( 100, 200, 300, 400 );

This draws a line segment connecting the points (100, 200) and (300, 400).

ofRect( 100, 200, 300, 400 );

This draws a rectangle ...

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