void ofCapsule(const ofShapeCapsule2& Capsule,float z,bool DrawCenterLine) { if ( !Capsule.IsValid() ) return; // generate triangle points float mRadius = Capsule.mRadius; ofLine2 Line = Capsule.mLine; vec2f Normal = Line.GetNormal(); vec2f Right = Normal.getPerpendicular(); // BL TL TR BR (bottom = start) vec2f Quad_BL2( Line.mStart - (Right*mRadius) ); vec2f Quad_TL2( Line.mEnd - (Right*mRadius) ); vec2f Quad_TR2( Line.mEnd + (Right*mRadius) ); vec2f Quad_BR2( Line.mStart + (Right*mRadius) ); vec3f Quad_BL( Quad_BL2.x, Quad_BL2.y, z ); vec3f Quad_TL( Quad_TL2.x, Quad_TL2.y, z ); vec3f Quad_TR( Quad_TR2.x, Quad_TR2.y, z ); vec3f Quad_BR( Quad_BR2.x, Quad_BR2.y, z ); if ( ofGetFill() == OF_FILLED ) { ofTriangle( Quad_BL, Quad_TL, Quad_TR ); ofTriangle( Quad_TR, Quad_BR, Quad_BL ); } else if ( ofGetFill() == OF_OUTLINE ) { ofLine( Quad_BL, Quad_TL ); ofLine( Quad_BR, Quad_TR ); //ofLine( Line.mStart, Line.mEnd ); //ofRect( Line.mStart, mRadius/4.f, mRadius/4.f ); } if ( ofGetFill() == OF_OUTLINE && DrawCenterLine ) { ofLine( Line.mStart, Line.mEnd ); } // http://digerati-illuminatus.blogspot.co.uk/2008/05/approximating-semicircle-with-cubic.html vec3f BLControl = Quad_BL - (Normal * mRadius * 4.f/3.f) + (Right * mRadius * 0.10f ); vec3f BRControl = Quad_BR - (Normal * mRadius * 4.f/3.f) - (Right * mRadius * 0.10f ); vec3f TLControl = Quad_TL + (Normal * mRadius * 4.f/3.f) + (Right * mRadius * 0.10f ); vec3f TRControl = Quad_TR + (Normal * mRadius * 4.f/3.f) - (Right * mRadius * 0.10f ); BLControl.z = BRControl.z = TLControl.z = TRControl.z = z; ofBezier( Quad_BL, BLControl, BRControl, Quad_BR ); ofBezier( Quad_TL, TLControl, TRControl, Quad_TR ); }
void ofxTLCameraTrack::draweEase(CameraTrackEase ease, ofPoint screenPoint, bool easeIn) { switch (ease) { case CAMERA_EASE_LINEAR: if(easeIn) { ofTriangle(screenPoint.x-bounds.height, screenPoint.y, screenPoint.x, screenPoint.y, screenPoint.x, screenPoint.y+bounds.height); } else { ofTriangle(screenPoint.x, screenPoint.y, screenPoint.x, screenPoint.y+bounds.height, screenPoint.x+bounds.height, screenPoint.y+bounds.height); } break; case CAMERA_EASE_SMOOTH: if(easeIn) { ofBezier(screenPoint.x-bounds.height, screenPoint.y, screenPoint.x-bounds.height/2, screenPoint.y, screenPoint.x, screenPoint.y+bounds.height/2, screenPoint.x, screenPoint.y+bounds.height); ofLine(screenPoint.x-bounds.height, screenPoint.y, screenPoint.x, screenPoint.y); ofLine(screenPoint.x, screenPoint.y, screenPoint.x, screenPoint.y+bounds.height); } else { ofBezier(screenPoint.x, screenPoint.y, screenPoint.x, screenPoint.y+bounds.height/2, screenPoint.x+bounds.height/2, screenPoint.y+bounds.height, screenPoint.x+bounds.height, screenPoint.y+bounds.height); ofLine(screenPoint.x, screenPoint.y, screenPoint.x, screenPoint.y+bounds.height); ofLine(screenPoint.x, screenPoint.y+bounds.height, screenPoint.x+bounds.height, screenPoint.y+bounds.height); } break; case CAMERA_EASE_CUT: if(easeIn) { ofRect(screenPoint.x-bounds.height/2, screenPoint.y, bounds.height/2, bounds.height/2); } else { ofRect(screenPoint.x, screenPoint.y+bounds.height/2, bounds.height/2, bounds.height/2); } break; default: ofLogError("ofxTLCameraTrack::draweEase -- invalid ease"); break; } }
void patch::customDraw() { ofxPatch::customDraw(); if (bEditMode) { // Draw video interface /*if (type.compare("ofVideoPlayer") == 0) videoInterface->draw();*/ if (type.compare("ofImage") == 0) { if (bInspector) { ofVec3f scale = ((ofCamera*)this->getParent())->getScale(); inspector->setPosition(textureCorners[1].x/scale.x+2, textureCorners[1].y/scale.y); inspector->setVisible(true); } else inspector->setVisible(false); } // Draw the links // for (int i = 0; i < outPut.size(); i++){ if (outPut[i].to != NULL){ ofFill(); ofCircle(outPut[i].pos, 3); if (linkType == STRAIGHT_LINKS) ofLine(outPut[i].pos, outPut[i].to->pos); else if (linkType == CURVE_LINKS) { ofNoFill(); ofBezier(outPut[i].pos.x, outPut[i].pos.y, outPut[i].pos.x+55, outPut[i].pos.y, outPut[i].to->pos.x-55, outPut[i].to->pos.y, outPut[i].to->pos.x, outPut[i].to->pos.y); ofFill(); } else { if (outPut[i].path_coorners.size() > 0) { ofNoFill(); for(int j = 0; j < outPut[i].path_coorners.size(); j++){ ofCircle( outPut[i].path_coorners[j], 4); } } outPut[i].path_line.clear(); outPut[i].path_line.addVertex(outPut[i].pos); if (outPut[i].path_coorners.size() > 0) outPut[i].path_line.addVertices(outPut[i].path_coorners); outPut[i].path_line.addVertex(outPut[i].to->pos); outPut[i].path_line.draw(); ofFill(); } ofCircle(outPut[i].to->pos, 3); } } } else { if (bInspector) { inspector->setVisible(false); } } }
//---------------------------------------------------------- void ofxVectorGraphics::bezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4){ if(bDraw){ ofBezier(x1, y1, x2, y2, x3, y3, x4, y4); } if(bRecord){ if(bFill){ creeps.startPath(x1, y1); creeps.addCurve(x2, y2, x3, y3, x4, y4); creeps.addLine(x1, y1); creeps.endPath(CreEPS::FILL); } else creeps.curve(x1, y1, x2, y2, x3, y3, x4, y4); } }
void EditableBezier::draw() { ofBezier(start, c1, c2, end); if(editable) { ofPushStyle(); ofNoFill(); ofCircle(start, handleSize); ofCircle(c1, handleSize); ofCircle(c2, handleSize); ofCircle(end, handleSize); ofLine(start, c1); ofLine(end, c2); ofPopStyle(); } }
//-------------------------------------------------------------- void eraser::draw(){ ofEnableSmoothing(); ofEnableAlphaBlending(); // if(waiting < 80){ // waiting++; // }else{ // if(a > 0){ a --; }else{ a = 255;} // } if (step < waitCnt) { step++; } else { float thisRadius = radius + (ofNoise(radiusNoise) * 10) -5; x = centx + (thisRadius * cos(ang*3.141592/180)); y = centy + (thisRadius * sin(ang*3.141592/180)); oppx = centx - (thisRadius * cos(ang*3.141592/180)); oppy = centy - (thisRadius * sin(ang*3.141592/180)); ofSetColor(r, g, b); ofSetLineWidth(ofRandom(1,5)); ofNoFill(); ofLine(x, y, oppx, oppy); ofBezier(x, y, x + bX, y + bY, oppx, oppy, oppx + bX, oppy + bY); if ((ang > 360) || (ang < -360) ) { ang = 0; } if ((radius > 150) || (radius < 0) ) { radius = 3; } } }
void Particle::draw(){ ofSetColor(thisColor); ofSetLineWidth(0.5); ofNoFill(); ofPushMatrix(); ofTranslate(pos-pos/4); ofScale(pSize*0.05, pSize*0.05); //ofRectMode(CENTER); ofRotate(thisAngle); ofBezier(9,6,16,13,29,11,34,5); ofBezier(34,5,39,0,34,-3,29,3); ofBezier(29,3,24,9,24,17,41,16); ofBezier(41,16,58,15,43,26,33,24); ofBezier(33,24,17,21,-12,37,12,38); ofBezier(12,38,38,39,29,29,12,20); ofBezier(12,20,-4,11,-3,-4,9,6); //ofCircle(pos, pSize); ofPopMatrix(); }
void DomeData :: draw() { editable = gui.getVisible(); if(!editable) return; //level1.draw(); ofPushStyle(); ofPushMatrix(); ofTranslate(940,480); level1Handle.render(); level2Handle.render(); level3Handle.render(); level4Handle.render(); startHandle.render(); c1Handle.render(); c2Handle.render(); endHandle.render(); ofSetLineWidth(3); ofSetColor(255,0,255); ofBezier(start, c1, c2, end); ofLine(start, c1); ofLine(end,c2); ofSetColor(0,255,255); ofTranslate(-300,0); ofPopMatrix(); ofPushMatrix(); ofTranslate(pos); ofRotateX(rotation->x); ofRotateY(rotation->y); ofRotateZ(rotation->z); ofScale(scale, scale, scale); ofSetColor(255, 100); ofSetLineWidth(0.5); ofPushMatrix(); ofScale(scaleXY->x, scaleXY->y, scaleXY->z); for(float x = level4->x; x <= -level4->x; x+= level4->x / -5.0f) { ofLine(x, level4->y, x, end->y); } for(float y = level4->y; y >= end->y; y+= (end->y - level4->y)/10.0f) { ofLine(level4->x, y, -level4->x, y); } ofPopMatrix(); ofSetColor(0,255,0); ofPoint scalarXY = scaleXY.get(); for(float angle = 0; angle>= -90; angle-=divAngle) { ofPushMatrix(); ofRotateY( angle); ofScale(scaleXY->x, scaleXY->y, scaleXY->z); ofSetLineWidth(0.5); ofBezier(start, c1, c2, end); ofSetLineWidth(3); ofCircle(level1, 1); ofCircle(level2, 1); ofCircle(level3, 1); ofCircle(level4, 1); ofPopMatrix(); ofPushMatrix(); ofRotateY( -180 - angle); ofScale(scaleXY->x, scaleXY->y, scaleXY->z); ofSetLineWidth(0.5); //ofBezier(start, c1, c2, end); ofSetLineWidth(3); ofCircle(level1, 1); ofCircle(level2, 1); ofCircle(level3, 1); ofCircle(level4, 1); ofPopMatrix(); } ofPopStyle(); ofPopMatrix(); //gui.draw(); }
//------------------------------------------------------------------ void demoParticle::drawp(){ ofNoFill (); ofSetColor(103, 160, 237); //ofEllipse (ofGetMouseX(), ofGetMouseY(), 40, 40); ofVec2f Xaxix; Xaxix.set(1,0); float heading = -vel.angle(ofVec2f(1,0)); heading = heading - PI/2; //float theta = vel.angle(Xaxix)-PI/2; ofFill(); ofSetColor(103, 160, 237); ofPushMatrix(); ofTranslate(pos.x,pos.y); ofRotateZ(heading); ofScale(2,2); ofSetColor(0); ofFill(); ofSetColor(103, 160, 237); ofRect( -14, 0, 28, 14); ofSetColor(0); ofFill(); ofSetColor(0, 128, 0); ofEllipse( -14, 0, 10, 10 ); // left wheel ofEllipse( -14, 14, 10, 10 ); // right wheel /** Experimental Feature */ // ofFill(); // ofSetColor(255,0,0); // // if(blink>-90&&blink<=90) // ofEllipse( -14, 0, 10, 10 ); // left wheel // else ofEllipse( -14, 14, 10, 10 ); // right wheel /// // show the sensor/wheel connections ofNoFill(); if (mode == aggressive || mode == fear) ofSetColor(0, 128, 0); else ofSetColor(128, 0, 0); if (mode == templove|| mode == fear) ofBezier(-7*2, 0, 0, 3*2, 0, 3*2, 7*2, 0); else ofBezier(-7*2, 0, 0, 5*2, 0, 5*2, 7*2, 7*2); if (mode == templove || mode == fear) ofBezier(-7*2, 7*2, 0, 4*2, 0, 4*2, 7*2, 7*2); else ofBezier(-7*2, 7*2, 0, 2*2, 0, 2*2, 7*2, 0); ofSetColor(255, 255, 255); ofBezier(7*2+7,5, 7*2, 0, 7*2, 0, 7*2+7, -5); ofBezier(7*2+7,5+7*2, 7*2, 7*2, 7*2,7*2, 7*2+7, 7*2 -5); path.arc(7, 0, 5, 5, PI/2, PI/2+PI); path.arc(7, 7, 5, 5, PI/2, PI/2+PI); ofPopMatrix(); }
void ofCircles::draw() { ofNoFill(); ofSetColor(r,g,b,a); ofBezier(centerX, centerY, cx1, cy1, cx2, cy2, x2, y2); }
//-------------------------------------------------------------- void testApp::draw(){ ofSetColor(255, 255, 255); // video.draw(0,0,ofGetWidth(),ofGetHeight()); ofPushMatrix(); // draw debug (ie., image, depth, skeleton) openNIDevice.drawDebug(); ofPopMatrix(); ofPushMatrix(); // use a blend mode so we can see 'through' the mask(s) ofEnableBlendMode(OF_BLENDMODE_ALPHA); image.draw(0,160); // get number of current users int numUsers = openNIDevice.getNumTrackedUsers(); // ofSetColor(ofRandom(220,240)); ofSetColor(ofRandom(240,255), 139, 212); // iterate through users for (int i = 0; i < numUsers; i++){ if(numUsers == 0){ image.draw(0,160); }else{image.clear();} image.clear(); // get a reference to this user ofxOpenNIUser & user = openNIDevice.getTrackedUser(i); /*give up draw Mask if (numUsers==2 && (counter2 - counter) < -1) { user.drawMask(); } counter2 = counter; if(user.isSkeleton()){ counter = counter +1; };*/ //extract heart xh = ((user.getJoint(JOINT_LEFT_SHOULDER).getProjectivePosition().x)+(user.getJoint(JOINT_RIGHT_SHOULDER).getProjectivePosition().x))*0.5; yh = ((user.getJoint(JOINT_LEFT_SHOULDER).getProjectivePosition().y)+(user.getJoint(JOINT_RIGHT_SHOULDER).getProjectivePosition().y))*0.5; ofSetColor(220,0,0); ofCircle(xh, yh, 20); //extract joint position left x0 = user.getJoint(JOINT_LEFT_ELBOW).getProjectivePosition().x; y0 = user.getJoint(JOINT_LEFT_ELBOW).getProjectivePosition().y; x1 = user.getJoint(JOINT_LEFT_HAND).getProjectivePosition().x; y1 = user.getJoint(JOINT_LEFT_HAND).getProjectivePosition().y; l1 = ofDist(x0,y0,x1,y1); theta1 = acos((x1-x0)/l1); angle1 = 180 * theta1; c1 = cos(theta1); s1 = sin(theta1); c2 = cos(2*PI - theta1); s2 = sin(2*PI - theta1); d1 = ofDist(xe,ye,xh,yh); d2 = ofDist(xe, ye, xe1, ye1); //x-coordinate, y-coordinate, tip of sword if (y0<y1) { xe = x1 + l1 * c1 * 2.5; ye = y1 + l1 * s1 * 2.5; xe1 = x1 + l1 * c1 * 2.2; ye1 = x1 + l1 * s1 * 2.2; }else{ xe = x1 + l1 * c2 * 2.5; ye = y1 + l1 * s2 * 2.5; xe1 = x1 + l1 * c2 * 2.2; ye1 = x1 + l1 * s2 * 2.2; } if (d2<20) { sound3.play(); }else{} p = l1/100; ofSetColor(255, 139, 212); ofPushMatrix(); ofTranslate(x1,y1); ofSetLineWidth(3); if(y0<y1){ if(d1<50){ sound1.play(); ofCircle(xh-x1,yh-y1,30); if(xh<320){ scoreR = scoreR +V; }else{scoreL = scoreL + V;} }else{} ofLine(0, 0,xe-x1,ye-y1); ofPushMatrix(); ofRotate(angle1/2+90); ofBeginShape(); ofBezier(0, -32*p, -24*p, -24*p, -24*p, 24*p, 0, 32*p); ofEndShape(); ofPopMatrix(); } else{ if(d1<50){ ofCircle(xh-x1,yh-y1,30); sound1.play(); if(xh<320){ scoreR = scoreR +V; }else{scoreL = scoreL + V;} }else{} ofLine(0, 0,xe-x1,ye-y1); ofPushMatrix(); ofRotate(-angle1/2+270); ofBeginShape(); ofBezier(0 , -32*p, -24*p, -24*p, -24*p, 24*p, 0, 32*p); ofEndShape(); ofPopMatrix(); } ofPopMatrix(); // } // you can also access the pixel and texture references individually: // TEXTURE REFERENCE //ofTexture & tex = user.getMaskTextureReference(); // do something with texture... // PIXEL REFERENCE //ofPixels & pix = user.getMaskPixels(); // do something with the pixels... // and point clouds: ofPushMatrix(); // move it a bit more central //ofTranslate(320, 240, 10); user.drawPointCloud(); // you can also access the mesh: // MESH REFERENCE //ofMesh & mesh = user.getPointCloud(); // do something with the point cloud mesh ofPopMatrix(); } ofDisableBlendMode(); ofPopMatrix(); // draw some info regarding frame counts etc ofSetColor(240, 0, 0); string msg = "Score 8th Ave: " + ofToString(scoreL) + " Score 9th Ave: " + ofToString(scoreR) ; verdana.drawString(msg, 70, openNIDevice.getNumDevices() * 80 - 20); }
//-------------------------------------------------------------- void ofApp::draw() { ofBackground(ofColor(120,120,120)); ofSetColor(100); if (sensor0 == true) { ofDrawBitmapString("I am sad..make me happy...", 50, 50); ofEllipse(250, 250, 300 ,300); ofSetColor(0,0,255); ofFill(); ofRect(200, 210 , 30, 50); ofSetColor(0,0,255); ofFill(); ofRect(300, 210 , 30, 50); ofSetColor(0,0,255); ofFill(); //ofBezier(150, 295, 200, 370, 300, 370, 350, 295); ofLine(150, 295, 350, 295); ofLine(160, 180, 210, 135); ofLine(160, 180, 290, 180); } if ((sensor0 == false) && (sensor1 == true)) { ofDrawBitmapString("Hey! You are awesome!", 50,50); ofEllipse(250, 250, 300 ,300); ofSetColor(0,0,255); ofFill(); ofEllipse(200, 210 , 30, 70); ofSetColor(0,0,255); ofFill(); ofEllipse(300, 210 , 30, 70); ofSetColor(0,0,255); ofFill(); ofBezier(150, 295, 200, 370, 300, 370, 350, 295); ofLine(150, 295, 350, 295); // ofLine(160, 180, 210, 135); // ofLine(160, 180, 290,180 ); } if ((sensor0 == false) && (sensor1 == false) && (sensor2 == true)){ ofDrawBitmapString("Hahahahaha", 50,50); ofEllipse(250, 250, 300 ,300); ofSetColor(0,0,255); ofFill(); ofEllipse(200, 210 , 30, 70); ofSetColor(0,0,255); ofFill(); ofEllipse(300, 210 , 30, 70); ofSetColor(0,0,255); ofFill(); // ofBezier(150, 295, 200, 370, 300, 370, 350, 295); ofEllipse(245,295,150,50); //ofLine(150, 295, 350, 295); // ofLine(160, 180, 210, 135); // ofLine(160, 180, 290,180 ); } }