¡Esta es una revisión vieja del documento!
Import the generated project as “Existing code as makefile project”. You only need to add OpenFrameworks and Addons projects as references in your new project (do not forget to select “Linux GCC”).
addons.make file.ofPolyLine allows you to combine multiple points into a single vector data object that can be drawn to the screen, manipulated point by point, and combined with other ofPolyline instances.
Crear un listener de UDP:
ofxUDPManager udpConnection; udpConnection.Create(); udpConnection.Bind(5001); udpConnection.SetNonBlocking(true); char udpMessage[10000]; udpConnection.Receive(udpMessage,10000); std::string message=udpMessage;
ofxJSONElement result; std::string url = "http://127.0.0.1:5000/sketch/1"; bool parsingSuccessful = result.open(url); if (parsingSuccessful) { //ofLogNotice("ofApp::setup") << "Ok!" << endl << result.getRawString() << endl; Json::Int64 value = result["paths"][0]["start_t"].asInt64(); ofLogNotice("ofApp::setup") << value << endl; Json::ArrayIndex npoints = result["paths"][0]["points"].size(); ofLogNotice("ofApp::setup") << npoints << endl; for (unsinged int i=0; i<result["paths"][0]["points"].size(); i++) ofxJSONElement point = result["paths"][0]["points"][i]; ofxJSONElement result2; ofLogNotice("ofApp::setup") << result2.parse("{\"hola\": \"adios\"}"); ofLogNotice("ofApp::setup") << result2["hola"].asString(); } else { ofLogNotice("ofApp::setup") << "Failed to parse JSON" << endl; }
float w = ofGetWidth(); float h = ofGetHeight(); float cx = w/2; float cy = h/2; img.allocate(w,h,OF_IMAGE_COLOR); for (float y=0; y<h; y++) { for (float x=0; x<w; x++) { float angle = atan2(y-cy,x-cy)+PI; float dist = ofDist(x,y,cx,cy); float hue = angle/TWO_PI*255; float sat = ofMap(dist,0,w/4,0,255,true); float bri = ofMap(dist,w/4,w/2,255,0,true); img.setColor(x,y,ofColor::fromHsb(hue,sat,bri)); } } img.reloadTexture();
ofColor ofxGetPixelColor(ofBaseHasPixels &img, int x, int y, int w, int h, int bpp=3) { ofColor c; int i = y*w*bpp + x*bpp; c.r = img.getPixels()[i+0]; c.g = img.getPixels()[i+1]; c.b = img.getPixels()[i+2]; if (bpp==4) c.a = img.getPixels()[i+3]; return c; } ofColor ofxGetPixelColor(int x, int y) { ofImage img; img.grabScreen(x,y,1,1); return ofxGetPixelColor(img,0,0,1,1); }