vector<ofColor> ofxColourTheory::createRangeFromAnalogous(ofColor src){ vector<ofVec2f> tones; tones.push_back(ofVec2f(1, 2.2f)); tones.push_back(ofVec2f(2, 1)); tones.push_back(ofVec2f(-1, -0.5f)); tones.push_back(ofVec2f(-2, 1)); float contrast = 0.25f; float theta = 10 *PI / 180.0; contrast = clipNormalized(contrast); vector<ofColor> colList; colList.push_back(src); for (int i=0;i<tones.size();i++) { ofColor c = rotateRYB(src,(int) (theta * tones[i].x)); float t = 0.44f - tones[i].y * 0.1f; if ((float) src.getBrightness()/255.0 - contrast * tones[i].y < t) { c.setBrightness(t*255.0); } else { c.setBrightness(src.getBrightness() - (contrast * tones[i].y)*255.0); } c.setSaturation(c.getSaturation()-0.05f*255.0); colList.push_back(c); } return colList; }
void resetDrawSettings() { m_inSetup = false; fill(m_defaultFillColor.getHex()); stroke(m_defaultStrokeColor.getHex()); strokeWeight(m_defaultStrokeWeight); m_hasFill = m_defaultHasFill; m_hasStroke = m_defaultHasStroke; ofEnableBlendMode(OF_BLENDMODE_ALPHA); smooth(2); width = ofGetWidth(); height = ofGetHeight(); pmouseX = ofGetPreviousMouseX(); pmouseY = ofGetPreviousMouseY(); keyPressed = ofGetKeyPressed(); mousePressed = ofGetMousePressed(); mouseButton = NONE; if( ofGetMousePressed(0) ) mouseButton = LEFT; else if(ofGetMousePressed(1)) mouseButton = RIGHT; ofSetCircleResolution(100); ofSetCurveResolution(100); }
void GamePanel::intializeBackground() { last = ofGetElapsedTimeMillis(); col.setHsb(0,255,255); col2.setHsb(0,255,255); col3.setHsb(0,255,255); col4.setHsb(0,255,255); counter = 0; }
void GamePanel::backgroundUpdate() { if(ofGetElapsedTimeMillis() - last > 50) { col.setHue(counter % 256); col2.setHue((counter + 60) % 256); col3.setHue((counter + 120) % 256); col4.setHue((counter + 180) % 256); counter += 1; last = ofGetElapsedTimeMillis(); } }
void fill(int rgb, float alpha) { m_hasFill = true; if( rgb > 255 ) m_fillColor.setHex(rgb, alpha); else m_fillColor.set(rgb, alpha); if( m_inSetup ) m_defaultFillColor = m_fillColor; }
ofColor rotateRYB(ofColor col,int theta) { float h = (float) col.getHue()/255.0 * 360; vector<float> hsb; hsb.push_back((float) col.getHue()/255.0) ; hsb.push_back((float) col.getSaturation()/255.0) ; hsb.push_back((float) col.getBrightness()/255.0) ; theta %= 360; float resultHue = 0; vector<ofVec2f> RYB_WHEEL = getRYB_WHEEL(); for (int i = 0; i < RYB_WHEEL.size() - 1; i++) { ofVec2f p = RYB_WHEEL[i]; ofVec2f q = RYB_WHEEL[i + 1]; if (q.y < p.y) { q.y += 360; } if (p.y <= h && h <= q.y) { resultHue = p.x + (q.x - p.x) * (h - p.y) / (q.y - p.y); break; } } //fmod = %, ie remainder // And the user-given angle (e.g. complement). resultHue = fmod((resultHue + theta),360); // For the given angle, find out what hue is // located there on the artistic color wheel. for (int i = 0; i < RYB_WHEEL.size() - 1; i++) { ofVec2f p = RYB_WHEEL[i]; ofVec2f q = RYB_WHEEL[i + 1]; if (q.y < p.y) { q.y += 360; } if (p.x <= resultHue && resultHue <= q.x) { h = p.y + (q.y - p.y) * (resultHue - p.x) / (q.x - p.x); break; } } hsb[0] = fmod(h, 360) / 360.0f; ofColor newCol; newCol.setHsb(hsb[0]*255, hsb[1]*255, hsb[2]*255); return newCol; }
//-------------------------------------------------------------- void DevicePacket::computeColor(const ofColor& deviceColor, bool isColor, bool isInvert) { float volume = isInvert ? 1.0f-m_volume : m_volume; if (isColor) { m_color.setHue(deviceColor.getHue()); m_color.setSaturation(deviceColor.getSaturation()); m_color.setBrightness(volume*255.0f); } else { m_color.set(volume*255.0f,volume*255.0f,volume*255.0f); } }
void parseHsb(ofColor & color, string attribute) { double h = m_settings.getAttribute(attribute, "hue", 0.0); double s = m_settings.getAttribute(attribute, "saturation", 0.0); double b = m_settings.getAttribute(attribute, "brightness", 0.0); double a = m_settings.getAttribute(attribute, "alpha", 1.0); color.setHsb(h * 255.f, s * 255.f, b * 255.f, a * 255.f); }
void stroke(int rgb, float alpha) { m_strokeColor.setHex(rgb, alpha); m_hasStroke = true; if( m_inSetup ) m_defaultStrokeColor = m_strokeColor; }
//-------------------------------------------------------------- ofColor ColorUtil::getNoiseAround( ofColor c, float radius, float seedValue ) { float hue, saturation, brightness; c.getHsb(hue, saturation, brightness); float noise = (ofNoise(seedValue) * (radius * 2)) - radius; hue = hue + noise; if (hue < 0) hue = 255.0f + hue; if (hue > 255.0) hue = hue - 255.0f; c.setHsb(hue, saturation, brightness); return (c); }
void stroke(float gray, float alpha) { m_strokeColor.set(gray, gray, gray, alpha); m_hasStroke = true; if( m_inSetup ) m_defaultStrokeColor = m_strokeColor; }
void fill(float gray, float alpha) { m_hasFill = true; m_fillColor.set(gray,alpha); if( m_inSetup ) m_defaultFillColor = m_fillColor; }
//-------------------------------------------------------------- ofColor ColorUtil::getNoiseAroundMax( ofColor c, float radius ) { float hue, saturation, brightness; c.getHsb(hue, saturation, brightness); hue = hue + radius; if (hue < 0) hue = 255.0f + hue; if (hue > 255.0) hue = hue - 255.0f; c.setHsb(hue, saturation, brightness); return (c); }
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())); } }
//-------------------------------------------------------------- // create a visual representation of the simulation void Rd::getImage(ofImage & image, const ofColor & c1, const ofColor & c2){ unsigned char * pixels = image.getPixels(); for(int indexImg = 0, indexA = 0; indexA < A.size(); indexImg += 3, indexA++){ ofColor c = c1.getLerped(c2, A[indexA] * A[indexA]); pixels[indexImg] = c.r; pixels[indexImg + 1] = c.b; pixels[indexImg + 2] = c.g; } image.update(); }
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); } }
float distanceBetween(ofColor a,ofColor b) { float hue = a.getHue()/255.0f *TWO_PI; float hue2 = b.getHue()/255.0f * TWO_PI; ofVec3f v1((cos(hue) * a.getSaturation()/255.0f), (sin(hue) * a.getSaturation()/255.0f), a.getBrightness()/255.0f); ofVec3f v2((cos(hue2) * b.getSaturation()/255.0f), (sin(hue2) * b.getSaturation()/255.0f), b.getBrightness()/255.0f); return v1.distance(v2); }
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(); }
void ofPixels::setColor(int x, int y, ofColor color) { int index = getPixelIndex(x, y); if( bytesPerPixel == 1 ){ pixels[index] = color.getBrightness(); }else if( bytesPerPixel == 3 ){ pixels[index] = color.r; pixels[index+1] = color.g; pixels[index+2] = color.b; }else if( bytesPerPixel == 4 ){ pixels[index] = color.r; pixels[index+1] = color.g; pixels[index+2] = color.b; pixels[index+3] = color.a; } }
void parseXml() { m_settings.pushTag("AppConfig"); // parse output values m_settings.pushTag("output"); m_output_projector_width = m_settings.getValue("projector_width", 0); m_output_projector_height = m_settings.getValue("projector_height", 0); m_output_buffer_width = m_settings.getValue("buffer_width", 0); m_output_buffer_height = m_settings.getValue("buffer_height", 0); m_settings.popTag(); // parse Kinect values m_settings.pushTag("kinect"); m_kinect_crop_buffer_width = m_settings.getValue("crop_buffer_width", 0); m_kinect_crop_buffer_height = m_settings.getValue("crop_buffer_height", 0); m_settings.popTag(); // parse vector field values m_settings.pushTag("vector_field"); m_vector_field_subdivision_x = m_settings.getValue("subdivision_x", 0); m_vector_field_subdivision_y = m_settings.getValue("subdivision_y", 0); m_settings.popTag(); // parse particle system values m_settings.pushTag("particle_system"); m_particle_system_count = m_settings.getValue("count", 0); m_particle_system_min_radius = m_settings.getValue("min_radius", 0); m_particle_system_max_radius = m_settings.getValue("max_radius", 0.0); m_settings.popTag(); // parse marching squares values m_settings.pushTag("marching_squares"); m_marching_squares_columns = m_settings.getValue("columns", 0); m_marching_squares_rows = m_settings.getValue("rows", 0); m_settings.popTag(); m_settings.pushTag("colors"); parseHsb(m_background_color, "background"); parseHsb(m_metaballs_color, "metaballs"); m_background_clear_color.set(m_background_color); m_background_clear_color.a = 0.f; m_settings.popTag(); m_settings.popTag(); }
void EffectPipeOrganLines :: makeParticleForPipe(int pipeindex, ofColor col) { if(pipeOrganData == NULL) return; ParticleSystemManager& psm = *(ParticleSystemManager::instance()); ParticleSystem &ps = *psm.getParticleSystem(); ParticleSystemSettings pss; pss.emitLifeTime = 0.1; pss.emitMode = PARTICLE_EMIT_BURST; pss.emitCount = 1; pss.renderer = new ParticleRendererLaser(); pss.speedMin = 600 ; pss.speedMax = 650; pss.drag = 0.9; //pss.gravity.set(0,500,0); pss.sizeStartMin = pss.sizeStartMax = 1; pss.sizeChangeRatio = 0.1; //pss.emitShape = &explodeMesh; pss.directionYVar = pss.directionZVar = 0; pss.directionY = 0; pss.directionX = -35; pss.hueStartMin = pss.hueStartMax = col.getHue(); pss.hueChange = 0; pss.saturationMin = pss.saturationMax = 255; pss.saturationEnd = 255; pss.brightnessStartMin = pss.brightnessStartMax =pss.brightnessEnd = 255; pss.lifeMin = pss.lifeMax = 0.5; pss.shimmerMin = 0; pss.timeSpeed = 0.7; //pss.doNotScale = true; ps.pos = pipeOrganData->pipes[pipeindex].top; ps.init(pss); }
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); } } }
//-------------------------------------------------------------- ofMesh pen::createCircle(float x, float y, float radius, ofColor color){ float sides = 30; ofMesh mesh; mesh.setMode(OF_PRIMITIVE_TRIANGLE_FAN); color.setBrightness(ofRandom(100,250)); for(int i=0; i<=sides; i++){ float pointRatio = i/sides; float xSteps = cos(pointRatio*2*PI); float ySteps = sin(pointRatio*2*PI); float pointX = x + xSteps * radius; float pointY = y + ySteps * radius; mesh.addVertex(ofPoint(pointX, pointY)); mesh.addColor(color); } return mesh; }
void ofApp::setup() { ofEnableSmoothing(); ofEnableAlphaBlending(); ofSetFrameRate(60); ofSetVerticalSync(true); ofEnableDepthTest(); ofEnableAntiAliasing(); memset( dmxData_, 0, DMX_DATA_LENGTH ); //open the device dmxInterface_ = ofxGenericDmx::createDevice(DmxDevice::DMX_DEVICE_RAW); bool opened = dmxInterface_->open(); if ( dmxInterface_ == 0 || !opened ) { printf( "No FTDI Device Found\n" ); } else { printf( "isOpen: %i\n", dmxInterface_->isOpen() ); } printf("ofxGenericDmx addon version: %s.%s\n", ofxGenericDmx::VERSION_MAJOR, ofxGenericDmx::VERSION_MINOR); std::string file = "Lightweave_loops2.json"; std::string columnsFile = "Lightweave_columns2.json"; std::string facesFile = "Lightweave_faces2.json"; bool parsingSuccessful = result.open(file); bool parsingSuccessfulColumn = columnGeometry.open(columnsFile); bool parsingSuccessfulFaces = faceGeometry.open(facesFile); for (int region = 0; region < 6; region++) { string blah = "region" + ofToString(region); for (int rings = 0; rings < result[blah].size(); rings++) { string ring = "ring" + ofToString(rings); for (int pointPos = 0; pointPos < 3; pointPos++) { string point = "point" + ofToString(pointPos); } } } //setupUDP(); camWidth = 320; camHeight = 240; vector<ofVideoDevice> devices = vidGrabber.listDevices(); for (int i = 0; i < devices.size(); i++) { if (devices[i].bAvailable) { ofLogNotice() << devices[i].id << ": " << devices[i].deviceName; } else { ofLogNotice() << devices[i].id << ": " << devices[i].deviceName << " - unavailable "; } } for (int i = 0; i < devices.size(); i++) { if (!devices[i].deviceName.find("USB")) { cout << devices[i].id << endl; pcCams.push_back(devices[i].id); } } vidGrabber.setDeviceID(pcCams[0]); // vidGrabber.setDeviceID(0); vidGrabber.initGrabber(320,240); vidGrabber1.setDeviceID(pcCams[1]); // vidGrabber1.setDeviceID(0); vidGrabber1.initGrabber(320,240); colorImg1.allocate(320,240); grayImage1.allocate(320,240); grayBg1.allocate(320,240); grayDiff1.allocate(320,240); colorImg.allocate(320,240); grayImage.allocate(320,240); grayBg.allocate(320,240); grayDiff.allocate(320,240); bLearnBackground = true; bLearnBackground1 = true; threshold = 80; drawOne = false; bottomSwarm.a = 1.1f; bottomSwarm.b = (curWidth/4.0); bottomSwarm.c = 100.0; bottomSwarm.bVel = 1.0; xPos = 0; yPos = 0; zPos = 0; cam.setPosition(result["region0"]["ring0"]["point0"][0].asFloat(),result["region0"]["ring0"]["point0"][1].asFloat(),result["region0"]["ring0"]["point0"][2].asFloat()); cam.lookAt(ofVec3f(result["region0"]["ring1"]["point0"][0].asFloat(),result["region0"]["ring1"]["point0"][1].asFloat(),result["region0"]["ring1"]["point0"][2].asFloat())); cam.rotate(ofRadToDeg(PI/2), 1.0, 0.0, 0.0); cam.setFov(32.0); sphereZPos = 25.9297; sphereXPos = 364.928; for (int i = 0; i < 20; i++) { spheresXPos[i] = ofRandom(result["region0"]["ring0"]["point0"][0].asFloat()-500, result["region0"]["ring0"]["point0"][0].asFloat()+500.0); spheresZPos[i] = ofRandom(result["region0"]["ring0"]["point0"][2].asFloat()-100.0, result["region0"]["ring0"]["point0"][2].asFloat()+100.0); } /* LIGHTING */ ofSetSmoothLighting(true); pointLight.setDiffuseColor( ofColor(0.f, 255.f, 0.f)); pointLight.setSpecularColor( ofColor(255.f, 255.f, 255.f)); pointLight.setPosition(result["region0"]["ring0"]["point0"][0].asFloat(),result["region0"]["ring0"]["point0"][1].asFloat(),result["region0"]["ring0"]["point0"][2].asFloat()); material.setShininess( 64 ); colorHue = ofRandom(0, 250); colorHue2 = ofRandom(0, 250); lightColor.setBrightness( 180.f ); lightColor.set(250,250,210); materialColor.setBrightness(250.f); materialColor.set(100,100,100); lightColor.setHue(colorHue); pointLight.setDiffuseColor(lightColor); materialColor.setHue(colorHue); material.setSpecularColor(materialColor); materialColor.set(255.0,0.0,0.0); columnMaterial.setSpecularColor(materialColor); materialColor.set(55.0,55.0,55.0); peopleMaterial.setSpecularColor(materialColor); cameraColor1.set(0.0, 0.0, 255.0); cameraColor2.set(0.0, 0.0, 255.0); columnColor.set(255, 0, 0); activeColor.set(0.0,0.0,255.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); } }
//-------------------------------------------------------------- ofMesh pen::lineToMesh(ofPolyline line,ofColor color, float thicknessOffset, ofVec2f positionOffset){ ofMesh mesh; mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); vector<ofPoint> points = line.getVertices(); int brightness = 255; for(int i = 1; i < points.size(); i++){ ofVec2f thisPoint = ofVec2f(points[i-1].x,points[i-1].y); ofVec2f nextPoint = ofVec2f(points[i].x,points[i].y); ofVec2f direction = (nextPoint - thisPoint); float distance = direction.length(); ofVec2f unitDirection = direction.normalized(); ofVec2f toTheLeft = unitDirection.getRotated(-90); ofVec2f toTheRight = unitDirection.getRotated(90); float thickness = ofMap(thisPoint.y, 0, ofGetScreenHeight(), 5, 40); thickness += thicknessOffset; if (thicknessOffset == 0) color.setBrightness(ofMap(i, 0, points.size(), 250, 200)); ofVec2f leftPoint = thisPoint+toTheLeft*thickness; ofVec2f rightPoint = thisPoint+toTheRight*thickness; if (thicknessOffset > 0 && i == 1){ ofVec2f tempLeftPoint = leftPoint; ofVec2f tempRightPoint = rightPoint; tempLeftPoint -= unitDirection * (thickness/2); tempRightPoint -= unitDirection * (thickness/2); mesh.addVertex(ofVec2f(tempLeftPoint.x + positionOffset.x, tempLeftPoint.y + positionOffset.y)); mesh.addColor(color); mesh.addVertex(ofVec2f(tempRightPoint.x + positionOffset.x, tempRightPoint.y + positionOffset.y)); mesh.addColor(color); } mesh.addVertex(ofVec2f(leftPoint.x, leftPoint.y + positionOffset.y)); mesh.addColor(color); mesh.addVertex(ofVec2f(rightPoint.x, rightPoint.y + positionOffset.y)); mesh.addColor(color); if (thicknessOffset > 0 && i == points.size()-1){ leftPoint += unitDirection * (thickness/3) + positionOffset; rightPoint += unitDirection * (thickness/3) + positionOffset; mesh.addVertex(leftPoint); mesh.addColor(color); mesh.addVertex(rightPoint); mesh.addColor(color); } //Add arrow if (i == points.size()-1 ){ leftPoint = thisPoint+toTheLeft*thickness*1.5; rightPoint = thisPoint+toTheRight*thickness*1.5; mesh.addVertex(leftPoint); mesh.addColor(color); mesh.addVertex(rightPoint); mesh.addColor(color); mesh.addVertex(nextPoint + unitDirection * thickness*2.5); mesh.addColor(color); } } return mesh; }
//-------------------------------------------------------------- // sort by hue function bool sortHue( ofColor a, ofColor b){ return( a.getHue() < b.getHue() ); }
//-------------------------------------------------------------- // sort by brightness function bool sortBrightness( ofColor a, ofColor b){ return( a.getBrightness() < b.getBrightness() ); }
//-------------------------------------------------------------- // sort by saturation function bool sortSaturation( ofColor a, ofColor b){ return( a.getSaturation() < b.getSaturation() ); }
//-------------------------------------------------------------- //Sort function for stl::sort http://www.cplusplus.com/reference/algorithm/sort/ bool sortColorFunction (ofColor i,ofColor j) { return (i.getBrightness()<j.getBrightness()); }