- english
- /
- japanese
functions
- ofBackground()
- ofBackgroundGradient()
- ofBackgroundHex()
- ofBeginSaveScreenAsPDF()
- ofBeginShape()
- ofBezier()
- ofBezierVertex()
- ofBgColorPtr()
- ofBox()
- ofCircle()
- ofClear()
- ofClearAlpha()
- ofCone()
- ofCurve()
- ofCurveVertex()
- ofCurveVertices()
- ofDisableAlphaBlending()
- ofDisableBlendMode()
- ofDisablePointSprites()
- ofDisableSmoothing()
- ofDrawBitmapString()
- ofDrawBitmapStringHighlight()
- ofEllipse()
- ofEnableAlphaBlending()
- ofEnableBlendMode()
- ofEnablePointSprites()
- ofEnableSmoothing()
- ofEndSaveScreenAsPDF()
- ofEndShape()
- ofFill()
- ofGetCoordHandedness()
- ofGetCurrentRenderer()
- ofGetCurrentViewport()
- ofGetFill()
- ofGetGLRenderer()
- ofGetRectMode()
- ofGetStyle()
- ofGetViewportHeight()
- ofGetViewportWidth()
- ofLine()
- ofLoadIdentityMatrix()
- ofLoadMatrix()
- ofMultMatrix()
- ofNextContour()
- ofNoFill()
- ofOrientationToDegrees()
- ofPopMatrix()
- ofPopStyle()
- ofPopView()
- ofPushMatrix()
- ofPushStyle()
- ofPushView()
- ofRect()
- ofRectRounded()
- ofRotate()
- ofRotateX()
- ofRotateY()
- ofRotateZ()
- ofScale()
- ofSetBackgroundAuto()
- ofSetBackgroundColor()
- ofSetBackgroundColorHex()
- ofSetCircleResolution()
- ofSetColor()
- ofSetCoordHandedness()
- ofSetCurrentRenderer()
- ofSetCurveResolution()
- ofSetDrawBitmapMode()
- ofSetHexColor()
- ofSetLineWidth()
- ofSetPolyMode()
- ofSetRectMode()
- ofSetSphereResolution()
- ofSetStyle()
- ofSetupScreen()
- ofSetupScreenOrtho()
- ofSetupScreenPerspective()
- ofSphere()
- ofTranslate()
- ofTriangle()
- ofVertex()
- ofVertices()
- ofViewport()
- ofbClearBg()
ofBackground(...)
void ofBackground(int r, int g, int b)
Sets the background color. It takes as input r,g,b (0-255). The background is cleared automatically, just before the draw() command, so if the background color is not changing, you could call this inside of setup() (once, at the start of the application). If the background color is changing, you can call this inside of update().
void testApp::setup(){
ofBackground(255,0,0); // Sets the background color to red
}
ofBackgroundGradient(...)
void ofBackgroundGradient(const ofColor &start, const ofColor &end, ofGradientMode mode=OF_GRADIENT_CIRCULAR)
ofBeginSaveScreenAsPDF(...)
void ofBeginSaveScreenAsPDF(string filename, bool bMultipage=false, bool b3D=false, ofRectangle viewport=ofRectangle(0, 0, 0, 0))
ofBeginShape()
void ofBeginShape()
Call this to start drawing a new shape. Needs to be followed by a list of vertex points and lastly a call to ofEndShape().
//draws a star
ofSetPolyMode(OF_POLY_WINDING_NONZERO);
ofBeginShape();
ofVertex(400,135);
ofVertex(215,135);
ofVertex(365,25);
ofVertex(305,200);
ofVertex(250,25);
ofEndShape();
ofBezier(...)
void ofBezier(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
Draws a bezier curve from point (x0, y0) to point (x3, y3). The curve is shaped by the two control points (x1,y1) and (x2,y2) in a way where they are the respective tangents for the line at either ends.
ofBezier(...)
void ofBezier(float x0, float y0, float z0, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3)
ofBezierVertex(...)
void ofBezierVertex(float x1, float y1, float x2, float y2, float x3, float y3)
Describes a bezier curve through three points of a shape. To be called between ofBeginShape() and ofEndShape().
ofBezierVertex(...)
void ofBezierVertex(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3)
ofBgColorPtr()
float * ofBgColorPtr()
Gets the current background color that is set by ofBackground() or default. eg:
float * bgColor = ofBgColorPtr();
//lets get the individual values!
float r = bgColor[0]; //red
float g = bgColor[1]; //green
float b = bgColor[2]; //blue
float a = bgColor[3]; //alpha
ofBox(...)
void ofBox(float x, float y, float z, float size)
Draws a 3-dimensional box with equal sides (size) at the position of X and Y and Z.
void testApp::draw(){
ofBox(50,50,-10,40);
}
ofBox(...)
void ofBox(float x, float y, float size)
Draws a 3-dimensional box with equal sides (size) at the position of X and Y, at the current depth.
void testApp::draw(){
ofBox(50,50,40);
}
ofBox(...)
void ofBox(const ofPoint &position, float size)
Draws a 3-dimensional box with equal sides (size) at the position of point.
void testApp::draw(){
ofPoint p;
p.x = 50;
p.y = 50;
ofBox(p,40);
}
ofBox(...)
void ofBox(float size)
Draws a 3-dimensional box with equal sides at the current coordinate point.
void testApp::draw(){
ofTranslate(50,50);
ofBox(40);
}
ofCircle(...)
void ofCircle(float x, float y, float radius)
Draws a circle, centered at x,y, with a given radius.
void testApp::draw(){
ofCircle(150,150,100);
}
ofCurve(...)
void ofCurve(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
Draws a curve from point (x1, y1) to point (x2, y2). The curve is shaped by the two control points (x0,y0) and (x3,y3).
ofCurve(...)
void ofCurve(float x0, float y0, float z0, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3)
Draws a 3-dimensional curve from point (x1, y1, z1) to point (x2, y2, z2). The curve is shaped by the two control points (x0, y0, z0) and (x3, y3, z3).
ofCurveVertex(...)
void ofCurveVertex(float x, float y)
Specifies a single point of a shape. The difference from ofVertex is that the line describing the edge of the shape between two points will be a curve as opposed to a straight line. The curve is automatically generated using the catmull rom forumla. To be called between ofBeginShape() and ofEndShape().
ofDisableAlphaBlending()
void ofDisableAlphaBlending()
Turns off alpha blending.
void testApp::draw(){
ofEnableAlphaBlending(); // turn on alpha blending
ofSetColor(255,0,0,127); // red, 50% transparent
ofRect(20,20,100,100); // draws the rect with alpha
ofDisableAlphaBlending(); // turn off alpha
ofRect(120,20,100,100); // draws the rect without alpha
}
ofDisableSmoothing()
void ofDisableSmoothing()
Turns off smoothing. Currently, this only works for lines. You can draw a filled object, and then draw the outline with smoothing enabled to get smoothing effects on filled shapes.
ofDrawBitmapString(...)
void ofDrawBitmapString(string textString, float x, float y)
Draws a bitmapped string, on screen, at point (x,y). For example, you can write some text on screen like this:
void testApp::draw(){
ofDrawBitmapString("hi!!", 100,100);
}
Your strings can even be multiline:
ofDrawBitmapString("a test
of multiline
text", 100,100);
you can also using dynamically generated strings. For example, to print the frame rate:
string fpsStr = "frame rate: "+ofToString(ofGetFrameRate(), 2);
ofDrawBitmapString(fpsStr, 100,100);
Please note, ofDrawBitmapString wraps a glut function that uses glDrawPixels. On some graphics cards, you may discover that glDrawPixels is slow (or even, very slow). If so, you might want to invsetigate using ofTrueTypeFont with a small typeface, non-anti-aliased, as a suitable alternative.
ofDrawBitmapStringHighlight(...)
void ofDrawBitmapStringHighlight(string text, const ofPoint &position, const ofColor &background=ofColor::black, const ofColor &foreground=ofColor::white)
ofDrawBitmapStringHighlight(...)
void ofDrawBitmapStringHighlight(string text, int x, int y, const ofColor &background=ofColor::black, const ofColor &foreground=ofColor::white)
ofEllipse(...)
void ofEllipse(float x, float y, float width, float height)
Draws an ellipse from point (x,y) with a given width (w) and height (h).
void testApp::draw(){
ofEllipse(10,10,50,30);
}
ofEnableAlphaBlending()
void ofEnableAlphaBlending()
Turns on alpha blending, which is off by default for performance purposes. It simply wraps opengl commands that enable blending, and turn on a common blend mode.
void testApp::draw(){
ofEnableAlphaBlending(); // turn on alpha blending
ofSetColor(255,0,0,127); // red, 50% transparent
ofRect(20,20,100,100); // draws the rect with alpha
ofDisableAlphaBlending(); // turn off alpha
ofRect(120,20,100,100); // draws the rect without alpha
}
ofEnableSmoothing()
void ofEnableSmoothing()
Turns on smoothing. Currently, this only works for lines. You can draw a filled object, and then draw the outline with smoothing enabled to get smoothing effects on filled shapes.
ofEndShape(...)
void ofEndShape(bool bClose=false)
This tells the program that your shape is finished and that it should now draw it to the screen. If you set the optional 'bClose' argument to true it will automatically close your shape for you.'bClose' is set to false by default. This function must be called otherwise you will not see your shape.
ofFill()
void ofFill()
Draw shapes filled with the current draw color.
void testApp::draw(){
ofSetColor(0,0,255);
ofFill();
ofRect(10,10,100,100); //draws the rectangle filled in blue
}
ofGetRectMode()
ofRectMode ofGetRectMode()
Tells you if rect drawing mode is set to drawn from the center or drawn from the top left corner, as set with the ofSetRectMode() function.
void testApp::draw(){
if(ofGetRectMode() == OF_RECTMODE_CORNER){
ofRect(10,10,80,80);
}
else {
ofRect(50,50,80,80);
}
}
ofLine(...)
void ofLine(float x1, float y1, float x2, float y2)
Draws a line between two points: (x1,y1),(x2,y2).
void testApp::draw(){
ofLine(10,10,100,100);
}
ofNextContour(...)
void ofNextContour(bool bClose=false)
Allows you to draw multiple contours within one shape. Call this between ofBeginShape() and ofEndShape() to create a new contour for your shape. If you set the optional argument 'bClose' to true then the previous contour will be automatically closed. 'bClose' is set to false by default.
ofNoFill()
void ofNoFill()
Draw shapes as outlines with the current draw color.
void testApp::draw(){
ofSetColor(0,0,255);
ofNoFill();
ofRect(10,10,100,100); //draws only the outline in blue
}
ofPopMatrix()
void ofPopMatrix()
ofPopMatrix() restores the prior coordinate system.
void testApp::draw(){
ofCircle(10, 10, 5); // draw a circle
ofPushMatrix(); // push the current coordinate position
ofRotateX(90); // change the coordinate system
ofRect(10,10,40,40); // draw a rect
ofPopMatrix(); // recall the pushed coordinate position
}
ofPopStyle()
void ofPopStyle()
ofPopStyle() restores the prior style settings. It needs to be called after ofPushStyle.
void testApp::draw(){
ofCircle(10,10,5);
ofPushStyle(); // push the current style for use later
ofFill();
ofsetColor(255,0,0);
ofEllipse(30,10,40,40);
ofPopStyle(); // recall the pushed style
}
ofPushMatrix()
void ofPushMatrix()
ofPushMatrix saves the current coordinate system allowing users to develop specific movements in some graphic objects. ofPopMatrix needs to be called after. In the following example we only rotate the square.
void testApp::draw(){
ofCircle(10, 10, 5); // draw a circle
ofPushMatrix(); // push the current coordinate position
ofRotateX(90); // change the coordinate system
ofRect(10,10,40,40); // draw a rect
ofPopMatrix() // recall the pushed coordinate position
}
ofPushStyle()
void ofPushStyle()
ofPushStyle saves the current style settings for the ofGraphics after its call. Usage of ofPushStyle and ofPopStyle allow users to have more control of certain graphics elements. All the style that applies to certain elements is controled using ofStyle class. See ofStyle type. In the following example the properties of being red and filled only applies to the ellipse:
void testApp::draw(){
ofCircle(10,10,5);
ofPushStyle(); // push the current style for use later
ofFill();
ofSetColor(255,0,0);
ofEllipse(30,10,40,40);
ofPopStyle(); // recall the pushed style
}
ofRect(...)
void ofRect(float x1, float y1, float w, float h)
Draws a rectangle from point x,y with a given width and height.
void testApp::draw(){
ofRect(10,10,100,100);
}
ofRect(...)
void ofRect(const ofRectangle &r)
Draws an rectangle from the given rectangle.
void testApp::draw(){
ofRectangle rect;
rect.x = 10;
rect.y = 10;
rect.width = 100;
rect.height = 100;
ofRect(rect);
}
ofRect(...)
void ofRect(const ofPoint &p, float w, float h)
Draws an rectangle from point p, with a given width and height.
void testApp::draw(){
ofPoint p; // create a point P
p.x = 10; // set the x of the point
p.y = 10; // set the y of the point
ofRect(p, 80, 80); // Draw the rectangle
}
ofRect(...)
void ofRect(float x, float y, float z, float w, float h)
Draws an rectangle from point X, Y at depth Z with a given width and height.
void testApp::draw(){
ofRect(10,10,-100, 80, 80); // Draw a rectangle at 100 pixels in depth
}
ofRotate(...)
void ofRotate(float degrees, float vecX, float vecY, float vecZ)
ofRotate produces a rotation of angle "degrees" around the vector (vecX,vecY,vecZ). "degrees"specifies the angle of rotation, in degrees. vecX, vecY, vecZ specify the x, y, and z coordinates of a vector, respectively. All graphics drawn after ofRotate is called are rotated. Use ofPushMatrix and ofPopMatrix to save and restore the unrotated coordinate system.
void testApp::draw(){
ofRotate(50, 1, 0.5, 0); //rotates the coordinate system 50 degrees along the x-axis and 25 degrees on the y-axis
ofRect(20,20,100,100);
}
ofRotateX(...)
void ofRotateX(float degrees)
ofRotateX produces a rotation of angle "degrees" around the X-axis of our coordinate system represented by the vector (1,0,0)."degrees"specifies the angle of rotation, in degrees.
void testApp::draw(){
ofRotateX(45); //rotates the coordinate system 45 degrees around the x-axis
ofRect(20,20,100,100);
}
ofRotateY(...)
void ofRotateY(float degrees)
ofRotateY produces a rotation of angle "degrees" around the Y-axis of our coordinate system represented by the vector (0,1,0). "degrees"specifies the angle of rotation, in degrees.
void testApp::draw(){
ofRotateY(45); //rotates the coordinate system 45 degrees around the x-axis
ofRect(20,20,100,100);
}
ofRotateZ(...)
void ofRotateZ(float degrees)
ofRotateZ produces a rotation of angle "degrees" around the Z-axis of our coordinate system represented by the vector (0,0,1). "degrees"specifies the angle of rotation, in degrees.
void testApp::draw(){
ofRotateZ(45); //rotates the coordinate system 45 degrees around the x-axis
ofRect(20,20,100,100);
}
ofScale(...)
void ofScale(float xAmnt, float yAmnt, float zAmnt=1)
ofScale produces a nonuniform scaling along the x, y, and z axes. The three parameters xAmnt, yAmnt and zAmnt indicate the desired scale factor along each of the three axes. e.g:
void testApp::draw(){
ofScale(0.5,1,1); // scale 0.5 in height
ofRect(10,10,40,40); // draw a square rectangle
}
Rectangle width will be now 20px heigh!
ofSetBackgroundAuto(...)
void ofSetBackgroundAuto(bool bManual)
Sets the background clearing function to be auto (default) or not. If non-auto, then background clearing will not occur per frame (at the start of draw) but rather, whenever ofBackground is called.
void testApp::setup(){
ofSetBackgroundAuto(false); //disable automatic background redraw
}
void testApp::draw(){
if(ofGetFrameNum() % 10 == 0){
// draws a black background every 10 frames
ofBackground(0,0,0);
}
}
ofSetCircleResolution(...)
void ofSetCircleResolution(int res)
Sets the resolution for the ofCircle command. By default, the circle is 22 points, but if you need to draw larger circles, you can adjust the resolution using this command. all circles are cached in opengl using a display list for optimization purposes.
void testApp::draw(){
ofSetCircleResolution(10);
ofCircle(150,150,100); //draws a rough circle
ofSetCircleResolution(100);
ofCircle(450,150,100); //draws a fine circle
}
ofSetColor(...)
void ofSetColor(int r, int g, int b)
Sets the draw color with r,g,b, 0-255. For example, red (0xff0000) would be: ofSetColor(255,0,0). This affects not only the color of shapes drawn with ofRect(...), ofCircle(...), etc, but also the tint of images and textures.
void testApp::draw(){
ofSetColor(0,0,255); //set te color to blue
ofRect(10,10,100,100);
}
ofSetColor(...)
void ofSetColor(int r, int g, int b, int a)
sets the draw color with r,g,b,a 0-255. For alpha (transparency), you must first enable transparent blending (turned off by default for performance reasons), and draw in the proper z-order (objects in the back drawn first). For example, to draw a transparent red rectangle:
void testApp::draw(){
ofEnableAlphaBlending(); // turn on alpha blending
ofSetColor(255,0,0,127); // red, 50% transparent
ofRect(20,20,100,100);
ofDisableAlphaBlending(); // turn it back off, if you don't need it
}
ofSetColor(...)
void ofSetColor(int gray)
Sets the draw color with r,g,b, passed in as a hex. Hex is a conventient way to write colors. Some examples:
void testApp::draw(){
ofSetColor(0xffffff); // white (255,255,255)
ofSetColor(0x000000); // black (0,0,0);
ofSetColor(0x00ff00); // green (0,255,0);
}
ofSetDrawBitmapMode(...)
void ofSetDrawBitmapMode(ofDrawBitmapMode mode)
takes OF_BITMAPMODE_SIMPLE, OF_BITMAPMODE_SCREEN, OF_BITMAPMODE_VIEWPORT, OF_BITMAPMODE_MODEL and OF_BITMAPMODE_MODEL_BILLBOARD
ofSetLineWidth(...)
void ofSetLineWidth(float lineWidth)
ofSetLineWidth sets the width of the ofLines called after.
void testApp::draw(){
ofSetLineWidth(1); // set line width to 1
ofLine(10,10,100,100); // draw thin line
ofSetLineWidth(10); // set line width to 10
ofLine(10,100,100,10); // draw fat line
}
ofSetPolyMode(...)
void ofSetPolyMode(int mode)
Sets the drawing behavior for ovelapping parts of the same polygon. Possible modes are: OF_POLY_WINDING_ODD - OF_POLY_WINDING_NONZERO - OF_POLY_WINDING_POSITIVE - OF_POLY_WINDING_NEGATIVE - OF_POLY_WINDING_ABS_GEQ_TWO -
ofSetRectMode(...)
void ofSetRectMode(int mode)
Sets the mode for drawing rectangles and other rectangular objects, if they are corner aligned, or drawn so that the x,y position is the center of the rectangle. possible options are OF_RECTMODE_CENTER and OF_RECTMODE_CORNER. This afects not only how ofRect() objects are drawn, but also ofTexture (and threfore ofImage) objects.
void testApp::draw(){
ofSetRectMode(OF_RECTMODE_CORNER); //set rectangle mode to the corner
ofRect(10,10,80,80);
ofSetRectMode(OF_RECTMODE_CENTER); //set rectangle mode to the center
ofRect(50,50,80,80);
// both rectangles are drawn at the same place
}
ofSetStyle(...)
void ofSetStyle(ofStyle style)
We use ofSetStyle to set the current style of the ofGraphics. Parameter style contains information of the graphics style such as ofColor, ofFill, polyMode and others. See ofStyle for more details.
ofSetupScreenOrtho(...)
void ofSetupScreenOrtho(float width=0, float height=0, ofOrientation orientation=OF_ORIENTATION_UNKNOWN, bool vFlip=true, float nearDist=-1, float farDist=-1)
ofSetupScreenPerspective(...)
void ofSetupScreenPerspective(float width=0, float height=0, ofOrientation orientation=OF_ORIENTATION_UNKNOWN, bool vFlip=true, float fov=60, float nearDist=0, float farDist=0)
ofSphere(...)
void ofSphere(float x, float y, float z, float radius)
Draws a 3-dimensional sphere at X, Y and Z with the given radius.
void testApp::draw(){
ofSphere(50,50,-10,40);
}
ofSphere(...)
void ofSphere(float x, float y, float radius)
Draws a 3-dimensional sphere at X and Y at the current depth with the given radius.
void testApp::draw(){
ofSphere(50,50,40);
}
ofSphere(...)
void ofSphere(const ofPoint &position, float radius)
Draws a 3-dimensional sphere at position by point with the given radius.
void testApp::draw(){
ofPoint p;
p.x = 50;
p.y = 50;
ofSphere(p, 40);
}
ofSphere(...)
void ofSphere(float radius)
Draws a 3-dimensional sphere with the given radius.
void testApp::draw(){
ofTranslate(50,50,0);
ofSphere(40);
}
ofTranslate(...)
void ofTranslate(float x, float y, float z=0)
ofTranslate produces a translation by (x,y,z) vector of our coordinate system. The call of ofTranslate modifies graphics positions. Use ofPushMatrix and ofPopMatrix to save and restore the untranslated coordinate system.
void testApp::draw(){
ofTranslate(100, 100, 0); // move the coordinate system to position x 100 and y 100 and make that zero.
ofRect(0, 0, 10, 10); // draw a rect at that position
}
ofTranslate(...)
void ofTranslate(const ofPoint &p)
ofTranslate produces a translation by (x,y,z) vector of our coordinate system. The call of ofTranslate modifies graphics positions. Use ofPushMatrix and ofPopMatrix to save and restore the untranslated coordinate system.
void testApp::draw(){
ofPoint point;
point.x = 100;
point.y = 100;
ofTranslate(point); // move the coordinate system to position of point and make that zero.
ofRect(0, 0, 10, 10); // draw a rect at that position
}
ofTriangle(...)
void ofTriangle(float x1, float y1, float x2, float y2, float x3, float y3)
Draws a triangle, with the three points: (x1,y1),(x2, y2),(x3, y3).
void testApp::draw(){
ofTriangle(50,10,10,40,90,40);
}
ofTriangle(...)
void ofTriangle(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3)
ofVertex(...)
void ofVertex(float x, float y)
Specifies a single point of a shape. To be called between ofBeginShape() and ofEndShape().
ofViewport(...)
void ofViewport(float x=0, float y=0, float width=0, float height=0, bool invertY=true)
Last updated
Thursday, 16 May 2013 14:01:38 UTC
-
cbf0910627a25e6153f2452833c5313fe6067059

