Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import processing.serial.*;
  2. Serial porta;
  3. PImage st;
  4. //String dados = "";
  5.  
  6. void setup() {
  7. size (1200, 675, P3D);
  8. st = loadImage("rr.jpg");
  9.  
  10.  
  11. String nomedaporta = Serial.list()[0];
  12. porta = new Serial(this,nomedaporta, 9600);
  13.  
  14. }
  15. void draw() {
  16. while (porta.available() > 0) {
  17. int inByte = porta.read();
  18. println(inByte);
  19. }
  20.  
  21. //image(st, 0, 0);
  22. loadPixels();
  23. st.loadPixels();
  24. colorMode(HSB, width+height/2);
  25. for (int x=0; x < width; x++) {
  26. for (int y=0; y< height; y++) {
  27. int loc = x+y*width;
  28. float r = red(st.pixels[loc]);
  29. float g = green(st.pixels[loc]);
  30. float b = blue(st.pixels[loc]);
  31. pixels[loc] = color(r=(b-g), g=(b-r), b=(r-g));
  32. }
  33. updatePixels();
  34. }
  35. }
  36.  
  37. void serialEvent(Serial porta) {
  38. String bufString = porta.readString();
  39. float data = Float.valueOf(bufString);
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement