void Spacebar::draw() { updateTime(); ofNoFill(); if (currentEvent.id == 0) { // Intro float rectw = easeInOut(getTime(), 0, w, 30); float recth = easeInOut(getTime()-15, 0, h, 15); float t = easeQuinticInOutBack(getTime(), 0, 1, 60); t *= flicker(getTime()-15,10,5); ofColor base = COLOR_15; base.lerp(KEYBOARD_COLOR,t); ofSetColor(base); ofRectRounded(ofPoint(x+(w-rectw)/2,y+(h-recth)/2), rectw, recth, r, r, r, r); } else if (currentEvent.id == 2) { float fillalpha = easeInOut(getTime(),255,0,20); fillalpha *= flicker(getTime(),6,3); // Draw fill ofSetColor(KEYBOARD_COLOR, fillalpha); ofFill(); ofRectRounded(ofPoint(x,y), w, h, r, r, r, r); // Draw stroke ofSetColor(KEYBOARD_COLOR); ofNoFill(); ofRectRounded(ofPoint(x,y), w, h, r, r, r, r); } else if (currentEvent.id == 1) { ofSetColor(KEYBOARD_COLOR); ofRectRounded(ofPoint(x,y), w, h, r, r, r, r); } }
void Toolbar::draw() { ofSetColor(200,200,200); ofFill(); ofRectRounded(20,20,mWidth,mHeight,5); ofPushMatrix(); ofTranslate(25,25,0); for (int iToolSet = 0; iToolSet < mcNumToolSets; iToolSet++) { if ((iToolSet != 0) && (mToolSets[iToolSet]->size() != 0)) { ofSetColor(100,100,100); ofSetLineWidth(1); ofLine(2,3,28,3); ofTranslate(0,5,0); } for (int iTool = 0; iTool < mToolSets[iToolSet]->size(); iTool++) { if ((iToolSet == mActiveTool.first) && (iTool == mActiveTool.second)) { ofSetColor(80,180,20); ofFill(); ofRectRounded(0,0,30,30,2); } mToolSets[iToolSet]->at(iTool)->drawButton(); ofTranslate(0,30,0); } } ofPopMatrix(); }
void BPMController::draw() { //draw pitcher ofSetColor(0); ofFill(); ofRectRounded(pitcher.x, pitcher.y, pitcher.z, pitcher.w, 10); ofSetColor(255); ofLine(pitcher.x + pitcher.z/2, pitcher.y, pitcher.x + pitcher.z/2, pitcher.y + pitcher.w); //draw the bpm counter ofSetColor(0); ofRectRounded(tapper.x, tapper.y, tapper.z, tapper.w , 5); ofPushMatrix(); ofTranslate(tapper.x+50, tapper.y+50); ofRotate(180 + fourBeat % 4 * 90, 0, 0, 1); ofSetColor(255); ofRectRounded( 0, 0, 45, 45, 5); ofPopMatrix(); //draw puller and pusher; ofSetColor(0); ofNoFill(); ofRectRounded(puller.x, puller.y, puller.z, puller.w, 10); ofRectRounded(pusher.x, pusher.y, pusher.z, pusher.w, 10); }
void ofxKey::draw(){ update(); if (pressed){ fg.lerp(*foregroundColor, 0.1); bg.lerp(*backgroundColor, 0.1); } ofPushMatrix(); ofTranslate(position.x, position.y); ofRotateZ(ofRadToDeg(*keyboardNorth)); ofSetColor(bg); ofFill(); ofRectRounded(-width*0.5, -height*0.5, width, height, 5); ofNoFill(); ofSetLineWidth(2); ofSetColor(fg); ofRectRounded(-width*0.5, -height*0.5, width, height, 5); ofFill(); ofSetColor(fg); ofScale(width * scaleW,height * scaleH, 1); font->drawString(letter, -font->stringWidth(letter)*0.5, font->stringHeight(letter)*0.35);//(height/10)*1.3); ofPopMatrix(); }
void hzTextArea::draw() { if(text.size() == 0) return; int radius = 15; ofSetColor(255,255,255, 255); ofFill(); ofRectRounded(rect.x-radius, rect.y-radius, rect.width+radius*2,rect.height+radius*2, radius); ofSetColor(0,0,0, 255); ofNoFill(); ofRectRounded(rect.x-radius, rect.y-radius, rect.width+radius*2,rect.height+radius*2, radius); ofSetColor(0, 0, 0); font->drawString(text, pos.x, pos.y); }
void ofApp::draw() { ofBackgroundGradient(ofColor::white, ofColor::black); // get the screen Y values of range1 float y0 = ofMap(interval1.getStart().utcTime(), interval0.getStart().utcTime(), interval0.getEnd().utcTime(), 0, ofGetHeight()); float y1 = ofMap(interval1.getEnd().utcTime(), interval0.getStart().utcTime(), interval0.getEnd().utcTime(), 0, ofGetHeight()); // draw range0 ofFill(); ofSetColor(ofColor::yellow, 80); ofRectRounded(0, 0, ofGetWidth() / 4, ofGetHeight(), 5); // draw range1 ofFill(); ofSetColor(ofColor::red, 80); ofRectRounded(0, y0, ofGetWidth() / 4, y1 - y0, 5); // get the range boundaries as formatted strings std::string range0Min = Utils::format(interval0.getStart()); std::string range0Max = Utils::format(interval0.getEnd()); std::string range1Min = Utils::format(interval1.getStart()); std::string range1Max = Utils::format(interval1.getEnd()); // draw the range boundaries ofDrawBitmapStringHighlight(range0Min, ofVec2f(ofGetWidth() / 4, + 14)); ofDrawBitmapStringHighlight(range0Max, ofVec2f(ofGetWidth() / 4, ofGetHeight())); ofDrawBitmapStringHighlight(range1Min, ofVec2f(ofGetWidth() / 4, y0)); ofDrawBitmapStringHighlight(range1Max, ofVec2f(ofGetWidth() / 4, y1)); // draw a line based on the cursor position ofSetColor(255); ofLine(0, ofGetMouseY(), ofGetWidth(), ofGetMouseY()); // calculate the noramlized cursor position float normalizedMousePosition = ofGetMouseY() / (float)ofGetHeight(); // use the range0's lerp function to interpolate the date under the mouse Poco::Timestamp ts = interval0.lerp(normalizedMousePosition); // formate the interpolated date to a string std::string ts0 = Utils::format(ts); // draw the interpolated date ofDrawBitmapStringHighlight(ts0, ofVec2f(ofGetWidth() / 4, ofGetMouseY())); }
void ofxJFButton::drawController(){ ofPushStyle(); ofSetColor(PANEL_COLOR); ofRectRounded(location.x, location.y, size.x, size.y,5); ofSetColor(255); ofRectRounded(location.x, location.y, size.x*value, size.y,5); ofNoFill(); ofSetColor(0); ofRectRounded(location.x, location.y, size.x, size.y,5); drawLabel(); state.drawLabel(); ofPopStyle(); }
void Pedal::draw(){ //default pedal, this will be overriden in each child class. ofFill(); ofSetHexColor(0xffffff); ofRectRounded(x,y,xsize, ysize, 8); bypass_btn.draw(); input.draw(); output.draw(); }
void thumb::urdate(){ update(); mascara.begin(); ofClear(0); if(img.getWidth()>0 && cambioY<.1){ ofSetColor(0,0,0); ofRect(0,0,50,50); if(activo){ ofSetColor(255,255,255,255); }else{ ofSetColor(255,255,255,120); } ofRectRounded(0, 0, (width-cambioY) * escala, (height-cambioY) * escala, 10); }else{ ofSetColor(255,255,255); ofRectRounded(0, 0, (width-cambioY) * escala, (height-cambioY) * escala, 10); } mascara.end(); }
void GamePanel::showObj() { ofColor c1(160); ofColor c2(30); ofBackgroundGradient(c1, c2); RedPiece redP( getX()+getWidth() * 3 / 4, getY()+getHeight()/(2*multiple), getWidth()/64); redP.show(); redP.showObj(); BluePiece blueP(getX()+getWidth()/4, getY()+getHeight()/(2*multiple), getWidth()/64); blueP.show(); blueP.showObj(); // Labels // Player 1 Rectangle if(player1Turn) ofSetColor(255,255,0); else ofSetColor(40, 60, 255); //Draw Pieces ofRectRounded((width*1/4)+(width/20),height/10, width/8,height/16,width/32); //ofSetColor(0,0,0); //ofDrawBitmapString("Player 1" ,width*1/4+(width/13), height/10+(width/34)); // Player 2 Rectangle if(!player1Turn) ofSetColor(255,255,0); else ofSetColor(255, 30, 10); ofRectRounded(redP.getX()-(width/20)-(width/8),height/10, width/8,height/16,width/32); //ofSetColor(0,0,0); //ofDrawBitmapString("Player 2" ,width*1/2+(width/9), height/10+(width/34)); }
void GameBlock::paintBlock(int y, ofColor block_color, int bonus){ if(bonus == 2 && pieces == 1){ Assets::getInstance()->star.draw(x, y, Settings::getInstance()->PIECE_WIDTH*1.5, Settings::getInstance()->PIECE_WIDTH*1.5); } else { ofRectangle r; r.x = x; r.y = y; r.height = Settings::getInstance()->PIECE_WIDTH; r.width = (pieces > 1) ? pieces * Settings::getInstance()->PIECE_SIZE : r.height; ofSetColor(block_color); ofRectRounded(r, 20 * SCALE); } }
//-------------------------------------------------------------- void essClient::drawSnakeBlock(int xPos, int yPos, int snake, int i){ xPos = xPos - ofGetWindowWidth(); if(snake == 1){ if(i == 0){ ofSetColor(255, 0, 0); }else{ ofSetColor(255, 0, 0,150); } }else{ if(i == 0){ ofSetColor(0, 255, 0); }else{ ofSetColor(0, 255, 0,150); } } ofFill(); ofRectRounded(xPos,yPos, snakeBlockSize, snakeBlockSize, 10); }
void Key::draw() { updateTime(); ofPushMatrix(); { ofTranslate(x,y); if (currentEvent.id == 0) { // Intro if (getTime() > 0) { float t = easeQuinticInOutBack(getTime(), 0, 1, 60); t *= flicker(getTime()-5,20,5); ofColor base = COLOR_15; base.lerp(KEYBOARD_COLOR,t); ofSetColor(base); font.drawString(s, s_xoff, s_yoff); } } else if (currentEvent.id == 2) { float fillalpha = easeInOut(getTime(),255,0,20); fillalpha *= flicker(getTime(),6,3); // Draw rect ofFill(); ofSetColor(KEYBOARD_COLOR, fillalpha); ofRectRounded(0,0,w,h,3); // Draw text // float textalpha = easeInOut(getTime(),0,150,20); // ofSetColor(KEYBOARD_COLOR, textalpha); font.drawString(s, s_xoff, s_yoff); } else if (currentEvent.id == 1) { ofSetColor(KEYBOARD_COLOR); font.drawString(s, s_xoff, s_yoff); if (debug) { debug_draw_bounding_rect(); } } } ofPopMatrix(); }
//-------------------------------------------------------------- void ofApp::draw(){ // Hack to fix mouse disappearance bug. ofHideCursor(); ofShowCursor(); SMState foodState = sm->GetFoodState(); ofClear(colorForFoodState(foodState) * 0.1); float numHorizontalSquares = sm->GetWidth(); float numVerticalSquares = sm->GetHeight(); for (int x = 0; x < numHorizontalSquares; x++) { for (int y = 0; y < numVerticalSquares; y++) { ofColor currentColor; // Set square color based on properties. if (x == sm->GetHeadPosition().x && y == sm->GetHeadPosition().y) { currentColor = ofColor(255, 255, 255, 255); } else if (sm->isSnake(x, y)) { if (foodState) { currentColor = colorForFoodState(foodState); } else { currentColor = ofColor(0, 230, 0, 255); } } else if (sm->isSinFood(x, y)) { currentColor = ofColor(0, 200, 255, 255); } else if (sm->isTriangleFood(x, y)) { currentColor = ofColor(230, 0, 230, 255); } else if (sm->isSquareFood(x, y)) { currentColor = ofColor(230, 0, 0, 255); } else { currentColor = colorForFoodState(foodState) * 0.2; } // Highlight active squares. if (sm->isOnBeat(x, y)) { currentColor *= 1.3f; } // Draw squares. ofSetColor(currentColor); ofRectRounded(startX + (squareSize + squarePadding) * x, startY + (squareSize + squarePadding) * y, squareSize, squareSize, 5); // Draw food labels ofSetColor(255, 255, 255, 255); float imageStartX = startX + (squareSize + squarePadding) * x + squareSize * 0.1; float imageStartY = startY + (squareSize + squarePadding) * y + squareSize * 0.1; if (sm->isSinFood(x, y)) { sinImage.draw(imageStartX, imageStartY); } else if (sm->isTriangleFood(x, y)) { triangleImage.draw(imageStartX, imageStartY); } else if (sm->isSquareFood(x, y)) { squareImage.draw(imageStartX, imageStartY); } } } // Print framerate. std::ostringstream buff; buff << ofGetFrameRate();; font.drawString(buff.str(), 10, 30); }
int l_rectRounded(lua_State *L) { ofRectRounded(luaL_checknumber(L, 1), luaL_checknumber(L, 2), luaL_checknumber(L, 3), luaL_checknumber(L, 4), luaL_checknumber(L, 5)); return 0; }
void createPrimitive::draw(property &p) { prop = p; if(prop.points.size() == 0) return; switch (prop.dType) { case CP_POINT: glDepthMask(GL_FALSE); ofEnableAlphaBlending(); ofEnableBlendMode(OF_BLENDMODE_ALPHA); ofEnablePointSprites(); shader.begin(); texture.bind(); prop.vbo.draw(GL_POINTS, 0, (int)prop.points.size()); texture.unbind(); shader.end(); ofDisablePointSprites(); glDepthMask(GL_TRUE); break; case CP_LINE: //ofSetLineWidth(mags[0].x/10); ofSetLineWidth(20); prop.vbo.drawElements(GL_LINE_STRIP, prop.points.size()); break; case CP_CYLINDER: for (int i = 0; i < prop.points.size(); i++) { ofPushMatrix(); //glDepthMask(GL_FALSE); ofEnableDepthTest(); ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255,prop.colors[i].a*255); ofTranslate(prop.points[i].x, prop.points[i].y-prop.mags[i].x/2, prop.points[i].z); ofDrawCylinder(0,0,0, 10, prop.mags[i].x); //glDepthMask(GL_TRUE); ofPopMatrix(); } break; case CP_CYLINDER_SPECTRUM: //if (!prop.drawBins.size()) break; for (int i = 0; i < prop.points.size(); i++) { if(prop.origMags[i] == 0) continue ; ofPushMatrix(); ofTranslate(prop.points[i].x, prop.points[i].y- prop.drawBins[(i % 10)] *200/2, prop.points[i].z); ofDrawCylinder(0,0,0, 10, prop.drawBins[(i % 10)] * 200); ofPopMatrix(); //cout << (i % 10) << " " << prop.drawBins[(i % 10)] << endl; } break; case CP_RECT: //ofNoFill(); for (int i = 0; i < prop.points.size(); i++) { ofPushMatrix(); ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255,prop.colors[i].a*255); ofTranslate(prop.points[i].x-prop.mags[i].x/2, prop.points[i].y-prop.mags[i].x/4, prop.points[i].z); ofRotate(-prop.angle, 0, 0, 1); //ofRect(0, 0, mags[i].x, mags[i].x/2); ofDrawBox(0, 0, 0, prop.mags[i].x, prop.mags[i].x, prop.mags[i].x); ofPopMatrix(); } break; case CP_RECT_ROUNDED: for (int i = 0; i < prop.points.size(); i++) { ofRectRounded(prop.points[i].x-prop.mags[i].x/2, prop.points[i].y-prop.mags[i].x/4, prop.mags[i].x, prop.mags[i].x/2, prop.mags[i].x/4); } break; case CP_ELLIPPSE: for (int i = 0; i < prop.points.size(); i++) { ofEllipse(prop.points[i].x, prop.points[i].y, prop.mags[i].x, prop.mags[i].x/2); //ofRect(points[i].x-mags[i].x/2, points[i].y-mags[i].x/2, mags[i].x, mags[i].x); } break; case CP_LINE_IND: ofSetLineWidth(10); for (int i = 0; i < prop.points.size(); i++) { ofLine(prop.points[i].x, prop.points[i].y, prop.points[i].x, prop.points[i].y+prop.mags[i].x); } break; case CP_SPHERE: for (int i = 0; i < prop.points.size(); i++) { ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255,prop.colors[i].a*255); ofDrawSphere(prop.points[i].x, prop.points[i].y, prop.points[i].z, prop.mags[i].x); } if (particleFlg) { for (int i = 0; i < prop.mags.size(); i++) { prop.mags[i] *= 10.0; } prop.vbo.setNormalData(&prop.mags[0], prop.mags.size(), GL_DYNAMIC_DRAW); glDepthMask(GL_FALSE); ofEnableAlphaBlending(); ofEnableBlendMode(OF_BLENDMODE_ALPHA); ofEnablePointSprites(); shader.begin(); texture.bind(); prop.vbo.draw(GL_POINTS, 0, (int)prop.points.size()); texture.unbind(); shader.end(); ofDisablePointSprites(); glDepthMask(GL_TRUE); } break; case CP_TRIANGLE: prop.vbo.drawElements(GL_TRIANGLE_STRIP, prop.points.size()); break; case CP_TRIANGLE_IND: prop.angle+=5; //ofNoFill(); ofSetLineWidth(10); for (int i = 0; i < prop.points.size(); i++) { ofPushMatrix(); //glDepthMask(GL_FALSE); ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255,prop.colors[i].a*255); ofTranslate(prop.points[i].x, prop.points[i].y); ofRotate(prop.angle, 0, 0, 1); /* ofTriangle(0, -prop.mags[i].x, prop.mags[i].x/-2, prop.mags[i].x/2*sqrt(3), prop.mags[i].x/2, prop.mags[i].x/2*sqrt(3)); */ ofDrawCone(0, prop.mags[i].x/-2,prop.points[i].z, prop.mags[i].x/2, prop.mags[i].x); // glDepthMask(GL_TRUE); ofPopMatrix(); } break; case CP_CIRCLE: for (int i = 0; i < prop.points.size(); i++) { ofSetColor(prop.colors[i].r*255, prop.colors[i].g*255, prop.colors[i].b*255); ofCircle(prop.points[i].x, prop.points[i].y, prop.points[i].z, prop.mags[i].x/2); } default: break; } }
//-------------------------------------------------------------- void essClient::drawFood(int xPos, int yPos){ xPos = xPos - ofGetWindowWidth(); ofSetColor(255, 255, 255); ofFill(); ofRectRounded(xPos, yPos, foodSize, foodSize, 5); }
void thumb::drawThumb(){ //drawRound(); ofPushStyle(); ofSetColor(0,0,0,200); ofRectRounded(x-((width-cambioY)/2) + width/2 + 3, y-((height-cambioY)/2) + height/2 + 3, (width-cambioY) * escala, (height-cambioY) * escala, 10); ofSetColor(150,150,150,255); ofRectRounded(x-((width-cambioY)/2) + width/2 + 1, y-((height-cambioY)/2) + height/2 + 1, (width-cambioY) * escala - 1, (height-cambioY) * escala - 1, 10); ofSetColor(255,255,255,255); //ofPopStyle(); if(img.getWidth()>0 && cambioY<.1){ // img.draw(x, y, 50, 50); /* ofPushMatrix(); ofTranslate(x-((width-cambioY)/2) + width/2, y-((height-cambioY)/2) + height/2); mascaraShader->begin(); glActiveTexture(GL_TEXTURE0_ARB); img.getTextureReference().bind(); glActiveTexture(GL_TEXTURE1_ARB); mascara.getTextureReference().bind(); //draw a quad the size of the frame glBegin(GL_QUADS); //move the mask around with the mouse by modifying the texture coordinates glMultiTexCoord2d(GL_TEXTURE0_ARB, 0, 0); glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, 0); glVertex2f( 0, 0); glMultiTexCoord2d(GL_TEXTURE0_ARB, 50, 0); glMultiTexCoord2d(GL_TEXTURE1_ARB, 50, 0); glVertex2f(50, 0); glMultiTexCoord2d(GL_TEXTURE0_ARB, 50, 50); glMultiTexCoord2d(GL_TEXTURE1_ARB, 50, 50); glVertex2f(50,50); glMultiTexCoord2d(GL_TEXTURE0_ARB, 0,50); glMultiTexCoord2d(GL_TEXTURE1_ARB, 0,50); glVertex2f( 0, 50); glEnd(); //deactive and clean up glActiveTexture(GL_TEXTURE1_ARB); img.getTextureReference().unbind(); glActiveTexture(GL_TEXTURE0_ARB); mascara.getTextureReference().unbind(); mascaraShader->end(); ofPopMatrix(); */ img.draw(x-((width-cambioY)/2) + width/2, y-((height-cambioY)/2) + height/2); }else{ mascara.draw(x-((width-cambioY)/2) + width/2, y-((height-cambioY)/2) + height/2); } /* if (activo) { /// si la mini esta pulsada le ponemos un border ofPushStyle(); ofSetColor(255); ofNoFill(); ofSetLineWidth(2); roundedRect(x-((width-cambioY)/2) + width/2, y-((height-cambioY)/2) + height/2, (width-cambioY) * escala, (height-cambioY) * escala, 10); ofPopStyle(); }*/ }