Esempio n. 1
0
void ofTurtle::draw(int _x, int _y)
{
  int ppi=pixPerInch;
  ofPoint wheel(.25*ppi,(2+3/8)*ppi);
  ofPoint rWheel(1.125*ppi,1.875*ppi);
  ofRectangle body(-3.25*ppi/2,-wheel.y/2,ppi*3.25,ppi*4.5);
  //int body=w-whlWid*2;
  //int leng=h;
  ofEnableSmoothing();
  for (unsigned int i=0; i<lines.size()-1&&lines.size()>1; i++) {
    ofSetLineWidth(2);
    ofLine(lines[i].x, lines[i].y, lines[i+1].x, lines[i+1].y);
  }
  ofDisableSmoothing();
  ofPushMatrix();
  ofTranslate(pos.x, pos.y, 0);
  ofRotate(360-bearing.absoluteAngle());
  
  ofEnableSmoothing();
  ofSetColor(black.opacity(128));
  ofRect(body.x,body.y,body.width,body.height);
  ofSetColor(white);
  ofNoFill();
  ofRect(body.x,body.y,body.width,body.height);
  ofFill();
  ofSetColor(black);
  ofRect(body.x-ppi*3/8, body.y, wheel.x, wheel.y);
  ofRect(body.x+body.width+ppi*3/32, body.y, wheel.x, wheel.y);
  /*ofSetColor(white*.8);
  ofRect(body.x+(body.width-ppi*1.375)/2, body.y+body.height, 1.375*ppi, .25*ppi);
  ofRect(body.x+(body.width-ppi*1.375)/2+1.125*ppi, body.y+body.height, .25*ppi,1.375*ppi);
  ofSetColor(white*.5);
  ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+.5*ppi, .875*ppi, 1.5*ppi);
  ofSetColor(orange);
  ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+.50625*ppi, .375*ppi, .4375*ppi);
  ofRect(body.x+(body.width-ppi*1.375)/2+.125*ppi, body.y+body.height+(2.-.4375)*ppi, .375*ppi, .4375*ppi);
  ofRect(body.x+(body.width-ppi*1.375)/2+(1-.375)*ppi, body.y+body.height+(.5+(1.5-.4375)/2)*ppi, .375*ppi, .4375*ppi);*/
  ofPopMatrix();
  ofDisableSmoothing();
  
  if(!frontIsClear(frontCheckDist)) ofSetColor(255, 0, 0);
  else ofSetColor(0, 255, 0);
  ofPoint ps = pointAlongBearing(frontCheckDist+wheel.y/2);
  ofCircle(ps.x, ps.y, 5);
  
  if(!leftIsClear(leftCheckDist)) ofSetColor(255, 0, 0);
  else ofSetColor(0, 255, 0);
  ps = pos+bearing.ortho().unit()*w/2-bearing.unit()*w/2+bearing.unit().rotate(270)*leftCheckDist;
  ofCircle(ps.x, ps.y, 5);
  
  for (unsigned int i=0; i<bdy.size(); i++) {
    ofSetColor(yellow);
    ofVector t=bdy[i];
    ofLine(pos, pos+t.rotate(360-bearing.absoluteAngle()));
  }
}
Esempio n. 2
0
void motionTable::drawForeground(){
	if(isHoming()){
		ofSetColor(black.opacity(.75));
		ofRect(0,0,ofGetWidth(),ofGetHeight());
		ofSetColor(white);
		spinner.draw(ofGetWidth()/2,ofGetHeight()/2,ofGetHeight()/4);
		header().setMode(OF_FONT_CENTER);
		header().setSize(70);
		ofSetColor(white);
		header().drawString("Centering table, please wait",ofGetWidth()/2,ofGetHeight()/8);
		header().setSize(30);
		header().setMode(OF_FONT_LEFT);
	}
}
Esempio n. 3
0
void controlBar::drawForeground(){
  
  if(anim.isPlaying()){
    drawStyledBox(skipBut.x-50, skipBut.y-50, skipBut.w+100, skipBut.h+100);
    skipBut.draw((ofGetWidth()-skipBut.w)/2, ofGetHeight()*3./4);
  }
  
  
  if(report().isReporting()){
	  report().draw();
  }
  else if(serChk.drawForeground());
  else if(upload.drawForeground());
  else if(cfg().savePrograms&&bPluginChoice){
	  ofSetColor(black.opacity(200));
	  ofRect(0,0,ofGetWidth(),ofGetHeight());
	  drawStyledBox(create.x-50, create.y-50, create.w+100, (edit.y-create.y)+edit.h+100);
	  create.draw((ofGetWidth()-create.w)/2,(ofGetHeight()-create.h*2)/2-50);
	  edit.draw((ofGetWidth()-edit.w)/2,(ofGetHeight()+edit.h*2)/2+50);
  }
  else if(bChooseLevel){
    //ofSetColor(0, 0, 0,192);
    //ofRect(0, y, ofGetWidth(), ofGetHeight());
    for (unsigned int i=0; i<sets.size(); i++) sets(i).w=sets(i).h=200,sets(i).setAvailable(true);
    
	subtitle.setSize(50);
	subtitle.setMode(OF_FONT_CENTER);
	subtitle.setMode(OF_FONT_TOP);
	string title1="Select a programmer level";
	string title2="to begin.";
	double boxWid=(sets.size()-1)*ofGetWidth()/(sets.size())+(sets(0).w)+100;
	boxWid=max(boxWid,double(subtitle.stringWidth(title1)));

	double stringHgt=subtitle.stringHeight(title1)*2+50;
	double boxHgt=sets(0).h+stringHgt+150;

	drawStyledBox(0, y, ofGetWidth(),ofGetHeight()-y);
    //drawStyledBox((ofGetWidth()-boxWid)/2, ofGetHeight()/2-stringHgt-50, boxWid,boxHgt);
	ofSetColor(cfg().textColor);
	subtitle.drawString(title1,ofGetWidth()/2,ofGetHeight()/2-stringHgt);
	subtitle.drawString(title2,ofGetWidth()/2,ofGetHeight()/2-stringHgt+(stringHgt)/2);
    for (unsigned int i=0; i<sets.size(); i++) sets(i).draw((i+.5)*ofGetWidth()/(sets.size())-(sets(i).w)/2,ofGetHeight()/2+50);
  }
  else if(cfg().test&&test().isTesting()) test().drawForeground();
  else anim.drawForeground();
  
  
  anim.drawCursor();
}
Esempio n. 4
0
void demoAnim::drawForeground()
{
  if(bPrompt){
    ofSetColor(black.opacity(200));
    ofRect(0,0,ofGetWidth(),ofGetHeight());
	if(!demoButtons.size()){
		string head="View Demo?";
		int w=max(double(header.stringWidth(head)),yes.w*2+50);
		int h=header.stringHeight(head)+50+no.h;
		ofRectangle r((ofGetWidth()-w)/2-50, (ofGetHeight()-h)/2-50, w+100, h+100);
		drawStyledBox(r.x,r.y,r.width,r.height);
		header.drawString(head, r.x+r.width/2, r.y+50);
		yes.draw(r.x+r.width/2-yes.w-25, r.y+r.height-50-yes.h);
		no.draw(r.x+r.width/2+25, r.y+r.height-50-no.h);
	}
	else{
		string head="Select a demo.";
		double w=max(double(header.stringWidth(head)),no.w+50);
		int h=header.stringHeight(head)+50+no.h;
		for(unsigned int i=0; i<demoButtons.size(); i++){
			h+=demoButtons[i].h+25;
				w=max(w,demoButtons[i].w+50);
		}
		ofRectangle r((ofGetWidth()-w)/2-25, (ofGetHeight()-h)/2-25, w+50, h+50);
		drawStyledBox(r.x,r.y,r.width,r.height);
		ofSetColor(white);
		header.drawString(head, r.x+r.width/2, r.y+50);
		//yes.draw(r.x+r.width/2-yes.w-25, r.y+r.height-50-yes.h);
		int totH=25;
		for(unsigned int i=0; i<demoButtons.size(); i++){
			demoButtons[i].draw(r.x+(r.width-demoButtons[i].w)/2,r.y+header.stringHeight(head)+50+totH);
			totH+=demoButtons[i].h+25;
		}
		no.draw(r.x+(r.width-no.w)/2, r.y+r.height-25-no.h);
	}

  }
}
Esempio n. 5
0
void controlBar::draw(int _x, int _y)
{
  buttonBar.x=x=_x;
  buttonBar.y=y=_y;
  subBar.x=x;
  subBar.y=y+buttonBar.height;
  
  
  //_-_-_-_-_//_-_-_-_-_//_-_-_-_-_//_-_-_-_-_//_-_-_-_-_
  //_-_-_-_-_//_-_-_-_-_//buttonbar//_-_-_-_-_//_-_-_-_-_
  
  if(!cfg().defaultColor) ofSetColor(cfg().controlBarColor);
  else ofSetColor(black);
  ofRect(buttonBar.x,buttonBar.y,buttonBar.width,buttonBar.height);
  
  ofSetColor(gray.opacity(128));
  if(cfg().defaultColor) drawHatching(buttonBar.x, buttonBar.y, buttonBar.width, buttonBar.height, 50,50);
  
  for (unsigned int i=0; i<sets.size(); i++) sets(i).w=sets(i).h=72;
  bHldr[0].draw(buttonBar.x,buttonBar.y);
  for (unsigned int i=1; i<bHldr.size(); i++) {
    bHldr[i].draw(bHldr[i-1].area.x+bHldr[i-1].area.width,buttonBar.y);
  }
  
  //_-_-_-_-_//_-_-_-_-_//_-_-_-_-_//_-_-_-_-_//_-_-_-_-_
  //_-_-_-_-_//_-_-_-_-_//subTitle //_-_-_-_-_//_-_-_-_-_
  
  if(cfg().defaultColor) ofSetColor(gray);
  else ofSetColor(cfg().subtitleColor);
  ofRect(subBar.x,subBar.y,subBar.width,subBar.height);
  drawBorder(subBar);
  
  if(cfg().defaultColor) ofSetColor(yellow);
  else ofSetColor(cfg().lineColor);
  ofRect(subBar.x, subBar.y, subBar.width, 1);
  
  if(sets.getSelected()){
    ofButton & t=sets.getSelected()->choice;
    int wid=t.w/16+1;
    if(cfg().defaultColor) ofSetColor(yellow);
	else ofSetColor(cfg().lineColor);
    ofRect(t.x-wid, y, t.w+wid*2, buttonBar.height);
    wid=t.w/16;
	if(cfg().defaultColor) ofSetColor(gray);
	else ofSetColor(cfg().subtitleColor);
    ofRect(t.x-wid, y, t.w+wid*2, buttonBar.height+10);
    t.draw(t.x,t.y);
    
    if(cfg().defaultColor) ofSetColor(yellow);
	else ofSetColor(cfg().textColor);
    subtitle.setSize(22);
    subtitle.setMode(OF_FONT_LEFT);
    subtitle.drawString(sets.getSelected()->subtitle, 50, subBar.y+(subBar.height-subtitle.stringHeight(sets.getSelected()->subtitle))/2+5);
  }
  
  if(cfg().test&&test().isTesting()){
    ofRectangle & cBar=test().controlBar;
    
    ofSetColor(0x33, 0x33, 0x33);
    ofRect(0, 0, ofGetWidth(), ofGetHeight());
    ofSetColor(black);
    drawHatching(0, 0, ofGetWidth(), ofGetHeight(), 15,1);
    
    test().draw(0,cBar.y+cBar.height,ofGetHeight()-(cBar.y+cBar.height),ofGetHeight()-(cBar.y+cBar.height));
    blocks->base.draw(ofGetHeight(), y);
	cfg().test=false;
	blocks->base.drawButtonArea(ofGetHeight(),y);
	cfg().test=true;
    test().drawCurrentBlock();
    
    test().drawControlBar(x, y);
  }
}