void ofxGuiGroup::draw(){ currentFrame = ofGetFrameNum(); border.draw(); headerBg.draw(); ofBlendMode blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } ofColor c = ofGetStyle().color; ofSetColor(thisTextColor); font.getFontTexture().bind(); /*font.drawString(getName(), textPadding + b.x, header / 2 + 4 + b.y+ spacingNextElement); if(minimized){ font.drawString("+", b.width-textPadding-8 + b.x, header / 2 + 4+ b.y+ spacingNextElement); }else{ font.drawString("-", b.width-textPadding-8 + b.x, header / 2 + 4 + b.y+ spacingNextElement); }*/ textMesh.draw(); font.getFontTexture().unbind(); if(!minimized){ for(int i = 0; i < (int)collection.size(); i++){ collection[i]->draw(); } } ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } }
void ofxPanel::render(){ border.draw(); headerBg.draw(); ofBlendMode blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } ofColor c = ofGetStyle().color; ofSetColor(thisTextColor); bindFontTexture(); textMesh.draw(); unbindFontTexture(); bool texHackEnabled = ofIsTextureEdgeHackEnabled(); ofDisableTextureEdgeHack(); loadIcon.draw(loadBox); saveIcon.draw(saveBox); if(texHackEnabled){ ofEnableTextureEdgeHack(); } for(int i = 0; i < (int)collection.size(); i++){ collection[i]->draw(); } ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } }
void ofxGuiGroup::render(){ border.draw(); headerBg.draw(); ofBlendMode blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } ofColor c = ofGetStyle().color; ofSetColor(thisTextColor); bindFontTexture(); textMesh.draw(); unbindFontTexture(); if(!minimized){ for(int i = 0; i < (int)collection.size(); i++){ collection[i]->draw(); } } ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } }
void ofGLRenderer::draw(ofShapeTessellation & shape){ if(shape.isFilled()){ vector<ofPrimitive> & mesh = shape.getTessellation(); if(bUseShapeColor){ ofPushStyle(); setColor( shape.getFillColor() * ofGetStyle().color,shape.getFillColor().a/255. * ofGetStyle().color.a); } glEnableClientState(GL_VERTEX_ARRAY); for(int i=0;i<(int)mesh.size();i++){ draw(mesh[i]); } if(bUseShapeColor){ ofPopStyle(); } } if(shape.hasOutline()){ if(bUseShapeColor){ ofPushStyle(); setColor( shape.getStrokeColor() * ofGetStyle().color, shape.getStrokeColor().a/255. * ofGetStyle().color.a); } vector<ofPolyline> & outlines = shape.getOutline(); glEnableClientState(GL_VERTEX_ARRAY); for(int i=0; i<(int)outlines.size(); i++) draw(outlines[i]); if(bUseShapeColor){ ofPopStyle(); } } }
//---------------------------------------------------------- void ofGLRenderer::draw(const ofPath & shape) const{ ofColor prevColor; if(shape.getUseShapeColor()){ prevColor = ofGetStyle().color; } ofGLRenderer * mut_this = const_cast<ofGLRenderer*>(this); if(shape.isFilled()){ const ofMesh & mesh = shape.getTessellation(); if(shape.getUseShapeColor()){ mut_this->setColor( shape.getFillColor(),shape.getFillColor().a); } draw(mesh,OF_MESH_FILL); } if(shape.hasOutline()){ float lineWidth = ofGetStyle().lineWidth; if(shape.getUseShapeColor()){ mut_this->setColor( shape.getStrokeColor(), shape.getStrokeColor().a); } mut_this->setLineWidth( shape.getStrokeWidth() ); const vector<ofPolyline> & outlines = shape.getOutline(); for(int i=0; i<(int)outlines.size(); i++) draw(outlines[i]); mut_this->setLineWidth(lineWidth); } if(shape.getUseShapeColor()){ mut_this->setColor(prevColor); } }
//---------------------------------------------------------- void ofGLRenderer::draw(ofPath & shape){ ofColor prevColor; if(shape.getUseShapeColor()){ prevColor = ofGetStyle().color; } if(shape.isFilled()){ ofMesh & mesh = shape.getTessellation(); if(shape.getUseShapeColor()){ setColor( shape.getFillColor() * ofGetStyle().color,shape.getFillColor().a/255. * ofGetStyle().color.a); } draw(mesh); } if(shape.hasOutline()){ float lineWidth = ofGetStyle().lineWidth; if(shape.getUseShapeColor()){ setColor( shape.getStrokeColor() * ofGetStyle().color, shape.getStrokeColor().a/255. * ofGetStyle().color.a); } setLineWidth( shape.getStrokeWidth() ); vector<ofPolyline> & outlines = shape.getOutline(); for(int i=0; i<(int)outlines.size(); i++) draw(outlines[i]); setLineWidth(lineWidth); } if(shape.getUseShapeColor()){ setColor(prevColor); } }
//------------------------------------------------ void ofxBox2dRect::draw() { if(body == NULL) { return; } // update the polyline getRectangleShape(); ofPath path; for (int i=0; i<shape.size(); i++) { if(i==0)path.moveTo(shape[i]); else path.lineTo(shape[i]); } // draw the path path.setColor(ofGetStyle().color); path.setFilled(ofGetStyle().bFill); path.draw(); // are we sleeping if(isSleeping()) { ofPushStyle(); ofEnableAlphaBlending(); path.setColor(ofColor(255, 100)); path.setFilled(true); path.draw(); ofPopStyle(); } }
void ofxPanel::render(){ border.draw(); headerBg.draw(); ofBlendMode blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } ofColor c = ofGetStyle().color; ofSetColor(thisTextColor); bindFontTexture(); textMesh.draw(); unbindFontTexture(); bool texHackEnabled = ofIsTextureEdgeHackEnabled(); ofDisableTextureEdgeHack(); // loadIcon.draw(loadBox); // saveIcon.draw(saveBox); if(isDynamic){ ofSetColor(255,0,0); if(*isActive){ ofFill(); } else ofNoFill(); ofRect(activeBox); ofSetColor(0,255,0); if(*isPiping){ ofFill(); } else ofNoFill(); ofRect(pipeBox); } if(texHackEnabled){ ofEnableTextureEdgeHack(); } for(int i = 0; i < (int)collection.size(); i++){ collection[i]->draw(); } ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } }
//-------------------------------------------------------------- void ofxFatLine::setFromPolyline(ofPolyline & poly){ // ofxFatLine(); setGlobalColor(ofGetStyle().color); setGlobalWidth(ofGetStyle().lineWidth); if (!poly.getVertices().empty()){ addVertices(poly.getVertices()); for (int i = 0; i <getVertices().size(); i++) { addColor(globalColor); addWeight(globalWidth); } update(); //*/ } }
void ofxPanel::render(){ this->prerender(); ofColor c; ofBlendMode blendMode; bool performDraw = !useFbo || requiresRerender; if( performDraw ){ border.draw(); headerBg.draw(); blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } c = ofGetStyle().color; ofSetColor(thisTextColor); bindFontTexture(); textMesh.draw(); unbindFontTexture(); bool texHackEnabled = ofIsTextureEdgeHackEnabled(); ofDisableTextureEdgeHack(); loadIcon.draw(loadBox); saveIcon.draw(saveBox); if(texHackEnabled){ ofEnableTextureEdgeHack(); } } int len = (int)collection.size(); for(int i = 0; i < len; i++){ collection[i]->draw(useFbo); } if( performDraw ){ ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } requiresRerender = false; } this->postrender(); }
void ofCairoRenderer::draw(ofPath & shape){ cairo_new_path(cr); vector<ofPath::Command> & commands = shape.getCommands(); for(int i=0;i<(int)commands.size();i++){ draw(commands[i]); } cairo_fill_rule_t cairo_poly_mode; if(shape.getWindingMode()==OF_POLY_WINDING_ODD) cairo_poly_mode=CAIRO_FILL_RULE_EVEN_ODD; else cairo_poly_mode=CAIRO_FILL_RULE_WINDING; cairo_set_fill_rule(cr,cairo_poly_mode); ofColor prevColor; if(shape.getUseShapeColor()){ prevColor = ofGetStyle().color; } if(shape.isFilled()){ if(shape.getUseShapeColor()){ ofColor c = shape.getFillColor(); c.a = shape.getFillColor().a; cairo_set_source_rgba(cr, (float)c.r/255.0, (float)c.g/255.0, (float)c.b/255.0, (float)c.a/255.0); } if(shape.hasOutline()){ cairo_fill_preserve( cr ); }else{ cairo_fill(cr); } } if(shape.hasOutline()){ float lineWidth = ofGetStyle().lineWidth; if(shape.getUseShapeColor()){ ofColor c = shape.getStrokeColor(); c.a = shape.getStrokeColor().a; cairo_set_source_rgba(cr, (float)c.r/255.0, (float)c.g/255.0, (float)c.b/255.0, (float)c.a/255.0); } cairo_set_line_width( cr, shape.getStrokeWidth() ); cairo_stroke( cr ); cairo_set_line_width( cr, lineWidth ); } if(shape.getUseShapeColor()){ setColor(prevColor); } }
void Java_cc_openframeworks_OFAndroid_onSurfaceCreated( JNIEnv* env, jclass thiz ){ if(appSetup){ ofLogNotice("ofAppAndroidWindow") << "onSurfaceCreated"; if(!surfaceDestroyed){ ofUnloadAllFontTextures(); ofPauseVideoGrabbers(); ofPauseVideoPlayers(); if(androidApp){ androidApp->unloadTextures(); } } ofGLReadyCallback(); ofReloadGLResources(); ofResumeVideoGrabbers(); ofResumeVideoPlayers(); if(androidApp){ androidApp->reloadTextures(); } ofSetStyle(ofGetStyle()); surfaceDestroyed = false; }else{ ofGLReadyCallback(); } }
void testApp::drawGrid(float scale, float ticks, bool labels, bool x, bool y, bool z) { ofColor c = ofGetStyle().color; ofPushStyle(); if (x) { c.setHue(0.0f); ofSetColor(c); drawGridPlane(scale, ticks, labels); } if (y) { c.setHue(255.0f / 3.0f); ofSetColor(c); ofPushMatrix(); ofRotate(90, 0, 0, 1); drawGridPlane(scale, ticks, labels); ofPopMatrix(); } if (z) { c.setHue(255.0f * 2.0f / 3.0f); ofSetColor(c); ofPushMatrix(); ofRotate(90, 0, 1, 0); drawGridPlane(scale, ticks, labels); ofPopMatrix(); } ofPopStyle(); }
void ramPyramidPrimitive::customDraw() { if (ofGetStyle().bFill) mesh.draw(); else mesh.drawWireframe(); }
void ramDrawBasicActor(const ramActor& actor) { if (actor.getNumNode() == 0) return; assert(actor.getNumNode() == ramActor::NUM_JOINTS); ofPushStyle(); const ofColor& color0 = ofGetStyle().color; const ofColor& color1 = ofColor::fromHsb(((int)color0.getHue() + 30) % 255, color0.getSaturation() * 0.5, color0.getBrightness(), color0.a); glPushMatrix(); for (int i = 0; i < actor.getNumNode(); i++) { const ramNode &node = actor.getNode(i); float jointSize = (i == ramActor::JOINT_HEAD) ? 8.0 : 5.0; ofPushStyle(); ofSetLineWidth(2); ofSetColor(color0); ramBox(node, jointSize); ofSetColor(color1); ramLine(node); ofPopStyle(); } glPopMatrix(); ofPopStyle(); }
void ofxGuiInputField<Type>::drawMesh(){ ofBlendMode blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } ofSetColor(textColor); bindFontTexture(); textMesh.draw(); unbindFontTexture(); ofColor c = ofGetStyle().color; ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } }
void ofxDelaunay::draw(){ if(ofGetStyle().bFill){ triangleMesh.draw(); } else{ triangleMesh.drawWireframe(); } }
//----------------------------------------------------------- void ofTrueTypeFont::drawCharAsShape(int c, float x, float y) { if (c - NUM_CHARACTER_TO_START >= nCharacters || c < NUM_CHARACTER_TO_START){ //ofLogError("ofTrueTypeFont") << "drawCharAsShape(): char " << << c + NUM_CHARACTER_TO_START << " not allocated: line " << __LINE__ << " in " << __FILE__; return; } //----------------------- if(ofIsVFlipped()){ ofTTFCharacter & charRef = charOutlines[c - NUM_CHARACTER_TO_START]; charRef.setFilled(ofGetStyle().bFill); charRef.draw(x,y); }else{ ofTTFCharacter & charRef = charOutlinesNonVFlipped[c - NUM_CHARACTER_TO_START]; charRef.setFilled(ofGetStyle().bFill); charRef.draw(x,y); } }
void Logo::draw(){ ofColor c = ofGetStyle().color; ofSetColor(color); ofPushMatrix(); ofScale(xScale,yScale,1); logo.draw(position); ofPopMatrix(); ofSetColor(c); }
void ofCairoRenderer::setup(string _filename, Type _type, bool multiPage_, bool b3D_, ofRectangle _viewport){ if( _viewport.width == 0 || _viewport.height == 0 ){ _viewport.set(0, 0, ofGetWidth(), ofGetHeight()); } filename = _filename; type = _type; streamBuffer.clear(); if(type == FROM_FILE_EXTENSION){ string ext = ofFilePath::getFileExt(filename); if(ofToLower(ext)=="svg"){ type = SVG; }else if(ofToLower(ext)=="pdf"){ type = PDF; }else{ // default to image type = IMAGE; } } switch(type){ case PDF: if(filename==""){ surface = cairo_pdf_surface_create_for_stream(&ofCairoRenderer::stream_function,this,_viewport.width, _viewport.height); }else{ surface = cairo_pdf_surface_create(ofToDataPath(filename).c_str(),_viewport.width, _viewport.height); } break; case SVG: if(filename==""){ surface = cairo_svg_surface_create_for_stream(&ofCairoRenderer::stream_function,this,_viewport.width, _viewport.height); }else{ surface = cairo_svg_surface_create(ofToDataPath(filename).c_str(),_viewport.width, _viewport.height); } break; case IMAGE: imageBuffer.allocate(_viewport.width, _viewport.height, 4); surface = cairo_image_surface_create_for_data(imageBuffer.getPixels(),CAIRO_FORMAT_ARGB32,_viewport.width, _viewport.height,_viewport.width*4); break; case FROM_FILE_EXTENSION: ofLogFatalError("ofCairoRenderer") << "Type not determined from file extension!"; break; default: ofLogError("ofCairoRenderer") << "Unknown type encountered!"; break; } cr = cairo_create(surface); cairo_set_antialias(cr,CAIRO_ANTIALIAS_SUBPIXEL); viewportRect = _viewport; viewport(viewportRect); page = 0; b3D = b3D_; multiPage = multiPage_; setStyle(ofGetStyle()); }
void ramCylinderPrimitive::customDraw() { ofVec3f size = body.getSize(); const int num_vtx = 32; vector<ofVec2f> p(num_vtx); for (int i = 0; i < num_vtx; i++) { float d = ofMap(i, 0, num_vtx - 1, 0, TWO_PI); ofVec3f v; v.x = sin(d) * size.x; v.y = cos(d) * size.x; p[i] = v; } glPushAttrib(GL_ENABLE_BIT); if (ofGetStyle().bFill) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } else { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } glBegin(GL_TRIANGLE_FAN); glVertex3f(0, -size.y, 0); for (int i = 0; i < num_vtx; i++) { glVertex3f(p[i].x, -size.y, p[i].y); } glEnd(); glBegin(GL_QUAD_STRIP); for (int i = 0; i < num_vtx; i++) { glVertex3f(p[i].x, size.y, p[i].y); glVertex3f(p[i].x, -size.y, p[i].y); } glEnd(); glBegin(GL_TRIANGLE_FAN); glVertex3f(0, size.y, 0); for (int i = 0; i < num_vtx; i++) { glVertex3f(p[i].x, size.y, p[i].y); } glEnd(); glPopAttrib(); }
void TextBox::draw() { ofPushStyle(); ofNoFill(); ofSetColor(255,100); // ofRectRounded(*this, 3); ofRect(*this); ofFill(); ofSetColor(100,100); // ofRectRounded(*this, 3); ofRect(*this); ofPopStyle(); ofPushMatrix(); ofTranslate(x, y); int margin = 10; string sType = ""; if (type == UNIFORM_SAMPLE2DRECT) { sType = "sample2DRect"; } else if (type == UNIFORM_VEC2) { sType = "vec2"; } else if (type == UNIFORM_FLOAT) { sType = "float"; } ofDrawBitmapString(sType+" "+name+": ", margin,12); int nameHeight = (sType.size()+1)*8+margin+(name.size()+2)*8; ofDrawBitmapString(text, nameHeight,12); width = nameHeight+(text.size()+2)*8; int cursorPos; // draw cursor line // if(drawCursor) { ofPushStyle(); float timeFrac = 0.5 * sin(3.0f * ofGetElapsedTimef()) + 0.5; ofColor col = ofGetStyle().color; cursorPos = nameHeight + 8*cursorx ; ofSetColor(col.r * timeFrac, col.g * timeFrac, col.b * timeFrac); ofSetLineWidth(3.0f); //TODO: multiline with fontRef ofLine(cursorPos, 13.7*cursory+2,cursorPos, 13.7*cursory+12); ofPopStyle(); } ofPopMatrix(); if (type == UNIFORM_FLOAT && mouseDownInRect && ofGetMousePressed()) { ofLine(x+nameHeight+16,y+height*0.5,lastMousePos.x,lastMousePos.y); } }
void DrawGame::CircleSprite::drawFill() { ofPushStyle(); ofStyle S = ofGetStyle(); S.bFill = true; S.circleResolution = 36; S.color = White?ofColor::white:ofColor::black; ofSetStyle(S); ofCircle(0,0,1.0f); ofPopStyle(); }
void DrawGame::CircleSprite::drawEdge() { ofPushStyle(); ofStyle S = ofGetStyle(); S.bFill = false; S.circleResolution = 36; S.color = White?ofColor::black:ofColor::white; S.lineWidth = 1.0f; ofSetStyle(S); ofCircle(0,0,1.0f); ofPopStyle(); }
//----------------------------------------------------------- void ofTrueTypeFont::drawCharAsShape(int c, float x, float y) { if (c >= nCharacters){ //ofLog(OF_LOG_ERROR,"Error : char (%i) not allocated -- line %d in %s", (c + NUM_CHARACTER_TO_START), __LINE__,__FILE__); return; } //----------------------- int cu = c; ofTTFCharacter & charRef = charOutlines[cu]; charRef.setFilled(ofGetStyle().bFill); charRef.draw(x,y); }
void ofxSlider<Type>::render(){ ofColor c = ofGetStyle().color; bg.draw(); bar.draw(); ofBlendMode blendMode = ofGetStyle().blendingMode; if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableAlphaBlending(); } ofSetColor(thisTextColor); bindFontTexture(); textMesh.draw(); unbindFontTexture(); ofSetColor(c); if(blendMode!=OF_BLENDMODE_ALPHA){ ofEnableBlendMode(blendMode); } }
//---------------------------------------------- void ttChar::drawBox2dObject(){ ofSetColor(255, 30, 220,100); character.draw(); if (step>0) { start.draw(); joint.draw(); } //draw sensor ofPolyline shape; const b2Transform& xf = character.body->GetTransform(); for (b2Fixture* f = character.body->GetFixtureList(); f; f = f->GetNext()) { if (f->IsSensor()) { ofSetColor(255,30,230,100); // ofCircle(sensor.getPosition(),f->GetShape()->m_radius*OFX_BOX2D_SCALE); b2PolygonShape* poly = (b2PolygonShape*)f->GetShape(); if(poly) { for(int i=0; i<poly->m_vertexCount; i++) { b2Vec2 pt = b2Mul(xf, poly->m_vertices[i]); shape.addVertex(worldPtToscreenPt(pt)); } } } } shape.setClosed(true); ofPath path; for (int i=0; i<shape.size(); i++) { if(i==0)path.moveTo(shape[i]); else path.lineTo(shape[i]); } path.setColor(ofGetStyle().color); path.setFilled(ofGetStyle().bFill); path.draw(); }
void ofxDelaunay::draw(){ if(ofGetStyle().bFill){ triangleMesh.draw(); } else{ triangleMesh.drawWireframe(); } // for(int i = 0; i < vertices.size(); i++ ){ // ofDrawBitmapStringHighlight(ofToString(i) , vertices[i].x, vertices[i].y); // } ofDrawBitmapStringHighlight("tri: " + ofToString(ntri) + "\nver:" + ofToString(vertices.size()), 30, 300); }
void LEDStrip::draw(float x, float radiusScale, float renderW, float renderH){ ofColor c = ofGetStyle().color; if(!stripMesh.usingColors()) ofSetColor(color); else ofSetColor(255); float sep = renderH/float(h+1); glPointSize(2*radius*renderH*radiusScale); ofPushMatrix(); ofTranslate(x*renderW,sep); ofScale(1,sep); stripMesh.draw(); ofPopMatrix(); ofSetColor(c); }
//---------------------------------------------------------- void ofPath::draw(){ if(ofGetCurrentRenderer()->rendersPathPrimitives()){ ofGetCurrentRenderer()->draw(*this); }else{ tessellate(); ofColor prevColor; if(bUseShapeColor){ prevColor = ofGetStyle().color; } if(bFill){ if(bUseShapeColor){ ofSetColor(fillColor); } ofGetCurrentRenderer()->draw(cachedTessellation,bUseShapeColor,false,false); } if(hasOutline()){ float lineWidth = ofGetStyle().lineWidth; if(bUseShapeColor){ ofSetColor(strokeColor); } ofSetLineWidth( strokeWidth ); vector<ofPolyline> & polys = getOutline(); for(int i=0;i<(int)polys.size();i++){ ofGetCurrentRenderer()->draw(polys[i]); } ofSetLineWidth(lineWidth); } if(bUseShapeColor){ ofSetColor(prevColor); } } }