Book Image

OpenFrameworks Essentials

Book Image

OpenFrameworks Essentials

Overview of this book

Table of Contents (19 chapters)
openFrameworks Essentials
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing a checkbox, a color selector, and a 2D slider


Until now, we have dealt only with float and integer sliders. Let's explore new types of controls: checkbox, color selector, and 2D slider, implemented by the ofxToggle, ofColorSlider, and ofVec2Slider classes, respectively.

Note

There exist classes of controls that are out of the scope of this book. These are the ofxButton button class, the ofxLabel text label class, and the ofxVec3Slider 3D slider class and the ofxVec4Slider 4D slider class. See openFrameworks' gui/guiExample example for details on using buttons and labels. The 3D sliders work similarly to 2D sliders, which we will consider now.

We investigate them by creating a group of controls to adjust the geometric primitive's drawing parameters:

  1. Declare the group and its components in the ofApp class's declaration:

    ofxGuiGroup primGroup;
    ofxFloatSlider shiftY, rotate;
    ofxVec2Slider size;
    ofxColorSlider color;
    ofxToggle filled, type;

    The first line declares a new group of controls...