Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Adding background image to existing code

$
0
0
Hello,
i am completely new to processing 

can someone please help me with this code ,

I want to add a background image to it, the background image would be placed in the processing folder/data




  1. import processing.serial.*;
  2. import processing.opengl.*;

  3. Serial serial;
  4. int serialPort = 1; 
  5.               
  6. int sen = 3; 
  7. int div = 3;
  8. Normalize n[] = new Normalize[sen];
  9. MomentumAverage cama[] = new MomentumAverage[sen];
  10. MomentumAverage axyz[] = new MomentumAverage[sen];
  11. float[] nxyz = new float[sen];
  12. int[] ixyz = new int[sen];

  13. float w = 256; // board size
  14. boolean[] flip = {
  15.   false, true, false};

  16. int player = 0;
  17. boolean moves[][][][];

  18. PFont font;

  19. void setup() {
  20.   size(800, 600, P3D);
  21.   frameRate(25);
  22.   
  23.   font = loadFont("TrebuchetMS-Italic-20.vlw");
  24.   textFont(font);
  25.   textMode(SCREEN);
  26.   
  27.   println(Serial.list());
  28.   serial = new Serial(this, Serial.list()[serialPort], 115200);
  29.   
  30.   for(int i = 0; i < sen; i++) {
  31.     n[i] = new Normalize();
  32.     cama[i] = new MomentumAverage(.01);
  33.     axyz[i] = new MomentumAverage(.15);
  34.   }
  35.   
  36.   reset();
  37. }

  38. void draw() {
  39.   updateSerial();
  40.   drawBoard();
  41. }

  42. void updateSerial() {
  43.   String cur = serial.readStringUntil('\n');
  44.   if(cur != null) {
  45.     String[] parts = split(cur, " ");
  46.     if(parts.length == sen  ) {
  47.       float[] xyz = new float[sen];
  48.       for(int i = 0; i < sen; i++)
  49.         xyz[i] = float(parts[i]);
  50.   
  51.       if(mousePressed && mouseButton == LEFT)
  52.         for(int i = 0; i < sen; i++)
  53.           n[i].note(xyz[i]);
  
     .......... the code continues 





I check online for the syntax ,even though i found them i cant seem to incorporate it into the above code.
so can someone kindly modify the above code with the right parameters for adding a background image 

any form of help would be much appreciated 

Viewing all articles
Browse latest Browse all 1768

Trending Articles