Skip to content

Instantly share code, notes, and snippets.

@TRNT7
Created October 21, 2017 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TRNT7/7bf2cc024a94797fbb6dcb8edd6bc48d to your computer and use it in GitHub Desktop.
Save TRNT7/7bf2cc024a94797fbb6dcb8edd6bc48d to your computer and use it in GitHub Desktop.
import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress destination;
int bgcolour;
ArrayList<OscMessage> positions = new ArrayList <OscMessage>();
void setup() {
fullScreen();
oscP5 = new OscP5(this, 8000);
destination = new NetAddress("127.0.0.1", 8000); // 127.0.0.1 = home
stroke(0, 70);
noCursor();
}
void draw() {
background(#F2D878);
beginShape();
for (int i =0; i < positions.size(); i++) {
fill(#5A92F0);
OscMessage click = positions.get(i);
vertex(click.get(0).intValue(), click.get(1).intValue());
}
endShape();
fill(#E03457);
ellipse(mouseX, mouseY, 100,100);
//bgcolour = (bgcolour +1) % 255; // fading effect of background
}
void keyPressed() {
if (key == 'a') {
OscMessage mymessage = new OscMessage("/Tristan"); // getting new message
mymessage.add(mouseX); //data of message
mymessage.add(mouseY);
oscP5.send(mymessage, destination); // sending message
}
if (key =='s') {
OscMessage mymessage = new OscMessage ("/jordans");
mymessage.add("1's");
oscP5.send(mymessage, destination);
//text(mymessage.toString(), random(width),random(height));
//println(mymessage);
}
if (key == 's') {
saveFrame();
// In Sketch folder you can see the screen shot
}
}
void oscEvent(OscMessage incomingMessage) {
if (incomingMessage.checkAddrPattern("/Tristan") == true) {
//positions.add(incomingMessage.get(0).intValue());
//positions.add(incomingMessage.get(1).intValue());
positions.add(incomingMessage);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment