-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Mastering openFrameworks: Creative Coding Demystified
By :
Maybe you noted a problem when considering the preceding flower example: drawing primitives by specifying the coordinates of all the vertices is a little cumbersome. There are too many numbers in the code, so it is hard to understand the relation between primitives. To solve this problem, we will learn about using the ofPoint class and then apply it for drawing primitives using control points.
ofPoint
is a class that represents the coordinates of a 2D point. It has two main fields: x and y, which are float type.
Actually, ofPoint has the third field z, so ofPoint can be used for representing 3D points too (we use this capability in Chapter 7, Drawing in 3D). If you do not specify z, it sets to zero by default, so in this case you can think of ofPoint as a 2D point indeed.
To represent some point, just declare an object of the ofPoint class.
ofPoint p;
To initialize the point, set its coordinates.
p.x = 100.0; p.y = 200.0;
Or, alternatively, use the constructor...
Change the font size
Change margin width
Change background colour