Basic graphics

These functions are usually used within the draw() method implementation.

cinder::gl::clear( Color color )

The preceding code clears the screen with the color specified in Color.

cinder::gl::drawLine( Vec2f from, Vec2f to )

The preceding code draws a line from a point defined in from to a point defined in to.

cinder::gl::color( float r, float g, float b, float a )

The preceding code sets the color that is then used in drawing shapes and lines. Color is defined as the separate r, g, b, and a (optional) float values.

cinder::glLineWidth( float width )

The preceding code sets the line width of Cinder line drawing functions.

cinder::gl::drawSolidCircle( Vec2f center, float radius, int numSegments = 0 )

The preceding code draws filled circle at the position defined in center and radius defined in radius.

cinder::gl::drawStrokedCircle( Vec2f center, float radius, int numSegments = 0 )

The preceding code draws just the outline of a circle whose position is defined in center and radius in radius.

cinder::gl::drawSolidRect( Rectf rect )

The preceding code draws a solid filled rectangle that is defined in rect.

cinder::gl::drawStrokedRect( Rectf rect )

The preceding code draws an outline of a rectangle defined in rect.

cinder::gl::drawSolidEllipse( Vec2f position, float radiusX, float radiusY, int numSegments = 0 )

The preceding code draws a solid filled ellipse at the position defined in position. Radius along x axis is defined in radiusX and radius along y axis is defined in radiusY. numSegments is optional; that defines how many triangles are used for drawing the ellipse as this shape is drawn using OpenGL triangle fans. If it is 0, the number of fans is decided automatically.

cinder::gl::drawStrokedEllipse( Vec2f position, float radiusX, float radiusY, int numSegments = 0 )

The preceding code draws just the outline of an ellipse whose position is defined in position, radius along x axis in radiusX, radius along y axis in radiusY. and optionally, number of segments in numSegments.

cinder::gl::drawSolidRoundedRect( Rectf rect, float cornerRadius, int numSegmentsPerCorner = 0 )

The preceding code draws a solid filled rectangle with rounded corners. Rectangle is defined in rect, its corner radius in cornerRadius, and it is possible to optionally define the number of segments that are used for drawing each corner in numSegmentsPerCorner. If it is set to 0, the number of segments is decided automatically.

cinder::gl::drawStrokedRoundedRect( Rectf, float cornerRadius, int numSegmentsPerCorner = 0 )

The preceding code draws just the outline of a rectangle with rounded corners. Rectangle is defined in rect, its corner radius in cornerRadius, and it is possible to optionally define the number of segments that are used for drawing each corner in numSegmentsPerCorner. If it is set to 0, the number of segments is decided automatically.

To make these functions work, you have to import the OpenGL header file as follows:

#include "cinder/gl/gl.h"
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.51.157