¡Esta es una revisión vieja del documento!
You only need to add OpenFrameworks and Addons projects as references in your new project.
addons.make file.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();