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

Re : Blend video cam with background image

$
0
0

second attempt with SimpleOpenNI - unsuccessfully


  1. import processing.opengl.*;
  2. import codeanticode.glgraphics.*;
  3. import SimpleOpenNI.*;

  4. GLTexture bottomLayer, topLayer, resultLayer;
  5. GLTextureFilter blendFilter;
  6. ScalarParam opacity;
  7. SimpleOpenNI  context;
  8. PImage img;

  9. void setup()
  10. {
  11.   size(640, 480, GLConstants.GLGRAPHICS);
  12.   context = new SimpleOpenNI(this);
  13.   // mirror is by default enabled
  14.   context.setMirror(true);
  15.   //context.enableRGB(640,480,30);
  16.   //context.enableRGB(1280,1024,15); 
  17.  
  18.   if(context.enableRGB() == false)
  19.   {
  20.      println("Can't open the rgbMap, maybe the camera is not connected or there is no rgbSensor!");
  21.      exit();
  22.      return;
  23.   }
  24.  
  25.   blendFilter = new GLTextureFilter(this, "BlendDifference.xml");
  26.   opacity = new ScalarParam(1.0,0.0,1.0,0.01);
  27.   bottomLayer = new GLTexture(this, "background.jpg");
  28.   topLayer = new GLTexture(this);    
  29.   resultLayer = new GLTexture(this, topLayer.width,topLayer.height);
  30. }

  31. void draw()
  32. {
  33.   background(0);
  34.   noStroke();
  35.   context.update();
  36.   img = context.rgbImage();
  37.   topLayer.putImage(img);
  38.   blendFilter.setParameterValue("Opacity", opacity.value);
  39.   blendFilter.apply(new GLTexture[] {bottomLayer, topLayer}, resultLayer);
  40.   resultLayer.render(0, 0);
  41.   println(frameRate);
  42. }

  43. void keyPressed()
  44. {
  45.   if (key == CODED) {
  46.     if (keyCode == UP) opacity.Increment();
  47.     else if (keyCode == DOWN) opacity.Decrement();
  48.   }
  49. }

  50. class ScalarParam {
  51.   float value;
  52.   float minValue;
  53.   float maxValue;
  54.   float step;
  55.   ScalarParam(float v,float mn, float mx, float s) {
  56.     value = v;
  57.     minValue = mn;
  58.     maxValue = mx;
  59.     step = s;
  60.   }
  61.   void Increment() {
  62.     value += step;
  63.     if (value > maxValue) value=maxValue;
  64.   }
  65.   void Decrement() {
  66.     value -= step;
  67.     if (value < minValue) value=minValue;
  68.   }
  69. }

Re : SOLVED - Blend video cam with background image

$
0
0

Here it is how to apply filters to a video cam:


  1. import processing.opengl.*;
  2. import codeanticode.glgraphics.*;
  3. import codeanticode.gsvideo.*;
  4. GSCapture cam;
  5. GLTexture texSrc, texFiltered;
  6. GLTextureFilter blur, emboss, edges, poster, pixelate, invert;
  7. GLTextureFilter currentFilter;
  8. String filterStr;
  9. PFont font;

  10. void setup() {
  11.   size(640, 480, GLConstants.GLGRAPHICS);
  12.   texSrc = new GLTexture(this);  
  13.   texFiltered = new GLTexture(this);   
  14.   cam = new GSCapture(this, 640, 480);
  15.   cam.setPixelDest(texSrc);
  16.   cam.start();
  17.   blur = new GLTextureFilter(this, "Blur.xml");
  18.   emboss = new GLTextureFilter(this, "Emboss.xml");
  19.   edges = new GLTextureFilter(this, "Edges.xml");
  20.   poster = new GLTextureFilter(this, "Posterize.xml");
  21.   pixelate = new GLTextureFilter(this, "Pixelate.xml");
  22.   invert = new GLTextureFilter(this, "Invert.xml");
  23.   font = loadFont("EstrangeloEdessa-24.vlw");
  24.   textFont(font, 24);     
  25.   currentFilter = edges;
  26.   filterStr = "edges";
  27. }

  28. void captureEvent(GSCapture cam) {
  29.   cam.read();
  30. }

  31. void draw() {
  32.   if (cam.ready()) {
  33.     if (texSrc.putPixelsIntoTexture()) {
  34.       // Calculating height to keep aspect ratio.     
  35.       float h = width * texSrc.height / texSrc.width;
  36.       float b = 0.5 * (height - h);
  37.       if (currentFilter == null) image(texSrc, 0, b, width, h);
  38.       else {
  39.         if (currentFilter == pixelate) {
  40.           currentFilter.setParameterValue("pixel_size", map(mouseX, 0, width, 1, 30));
  41.         }
  42.         if (currentFilter == invert) {
  43.           float x = map(mouseX, 0, width, 0, texSrc.width);
  44.           float y = map(mouseY, 0, height, 0, texSrc.height);
  45.           currentFilter.setParameterValue("mpos", new float[]{x, y});
  46.           currentFilter.setParameterValue("mdist", 50.0);             
  47.         }
  48.         texSrc.filter(currentFilter, texFiltered);
  49.         image(texFiltered, 0, b, width, h);           
  50.       }
  51.       fill(50, 200, 50);
  52.       if (currentFilter == null) text("Selected filter: none (1-6 to change, 0 to disable)", 10, 30);
  53.       else text("Selected filter: " + currentFilter.getName() + " (1-6 to change, 0 to disable)", 10, 30);
  54.     }    
  55.   }
  56. }

  57. void keyPressed() {
  58.   if ((key == '1')) { currentFilter = blur; }
  59.   else if ((key == '2')) { currentFilter = emboss; }
  60.   else if ((key == '3')) { currentFilter = edges; } 
  61.   else if ((key == '4')) { currentFilter = poster; }
  62.   else if ((key == '5')) { currentFilter = pixelate; } 
  63.   else if ((key == '6')) { currentFilter = invert; }
  64.   else if ((key == '0')) { currentFilter = null; }
  65. }

No library found for cc.arduino

$
0
0
Hello everyone.

I've a problem, i followed all the steps from this link http://playground.arduino.cc/interfacing/processing. I've downloaded  processing-arduinomega.zip because i'm using arduino Mega2560 and i descompressed this folder into my subfolder "libraries" of my Processing Sketchbook... and when i run the sketch apear this error:

No library found for cc.arduino

Anyone know how solve this problem? 

Arduino 1.0.3
Processing 2.0b7

Thanks

I'm trying to add sound..

$
0
0
hello everybody,

i'm trying to add sound to my game but it's saying:

Null pointer exception

i don't know what's wrong with it. can someone help me?

thanks in advance.

this is my game:



int knopX = 510;
int knopY = 420;
int breedte = 100;  //beginscherm
int hoogte = 100;
boolean schakel;  
boolean over;

int score =0;
PFont lettertype;

PImage background2;
PImage start;

import ddf.minim.*;

Minim minim;
AudioPlayer player;

buster buster1;
Enemies spook1;
Enemies spook2;
Enemies spook3;
Enemies spook4;
Enemies spook5;
Enemies spook6;
Enemies spook7;

void setup () {
  size(900, 800);
  buster1 = new buster(30, 540, 4);
  spook1 = new Enemies(random(0, width), 0, 3);
  spook1 = new Enemies(random(0, width), 0, 2);
  spook2 = new Enemies(random(0, width), 0, 5);
  spook3 = new Enemies(random(0, width), 0, 2);
  spook4 = new Enemies(random(0, width), 0, 6);
  spook5 = new Enemies(random(0, width), 0, 4);
  spook6 = new Enemies(random(0, width), 0, 6);
  spook7 = new Enemies(random(0, width), 0, 4);
  background2 = loadImage("background4.png");
  start = loadImage("beginscherm.png");
  lettertype = loadFont("AbadiMT-CondensedLight-48.vlw");
  
  player = minim.loadFile("GhostBusters.mp3");
  minim = new Minim("GhostBusters.mp3");
  player.play();

}

void draw() {
  image(start, 0, 0);

  fill(0, 0, 0, 0);
  stroke(0, 0, 0, 0);
  rect(knopX, knopY, breedte, hoogte);
  
  
  
  if (mouseX > knopX && mouseX < knopX + breedte && mouseY > knopY && mouseY < knopY + hoogte) {
    fill(0, 0, 0, 0);
    rect(knopX, knopY, breedte, hoogte); 
    over = true ;
  }

  else { 
    over = false;
  }

  if (schakel == true) {
    image(background2, 0, 0);
    textFont(lettertype,25);
    fill(0,255);
    text(score+" ghosts caught",50,50);


    buster1.tekenBuster();
    buster1.beweegBuster();

    spook1.tekenEnemies();
    spook1.beweegEnemies();
    spook1.checkEnemies();

    spook2.tekenEnemies();
    spook2.beweegEnemies();
    spook2.checkEnemies();

    spook3.tekenEnemies();
    spook3.beweegEnemies();
    spook3.checkEnemies();

    spook4.tekenEnemies();
    spook4.beweegEnemies();
    spook4.checkEnemies();

    spook5.tekenEnemies();
    spook5.beweegEnemies();
    spook5.checkEnemies();
  }
}


void mousePressed() {
  if (over==true) {
    schakel = !schakel;
  }

  if (over==false) {
  }
}

void stop()
{
  player.close();
  minim.stop();
  super.stop();
}

Save PDF on keypress

$
0
0
Hi,

Question,

How can I record with a keypress an another keypress to stop recording (the recording has to be a pdf or png but without the background).

This is what I already have.


                  float x,y,px,py;
                  float zachter = 0.01;

                  float diameter = 30;
                  int  weight;

                  /**
                   * changing colors and size by moving the mouse
                   *    
                   * MOUSE
                   * position x          : size
                   * position y          : color
                    * 
                   * KEYS
                   * s                   : save png
                   * p                   : save pdf
                   */
                        import java.util.Calendar;
                        import processing.pdf.*;
                        boolean savePDF = false;

                        void setup(){
                          size(800,800);
                          smooth();
                          color(225,223);
  
  
                              }


                        void draw() {
  
                          float targetX = mouseX;
                              float targetY = mouseY;
  

                          float targerY = mouseY;

                              y = y + (targetY - y) * zachter;
                                x = x + (targetX - x) * zachter;
                                strokeWeight(weight);
  
                                line(x, y , px, py);
  
                                px=y;
                                py=x;

                               // end of pdf recording
                                if (savePDF) {
                                  savePDF = false;
                                  endRecord();
                                }
                              }


                                    void keyPressed() {
                                      if (key=='s' || key=='S') saveFrame(timestamp()+"_##.png");
                                      if (key=='p' || key=='P') savePDF = true;
                                          }

      
                                      String timestamp() {
                                      Calendar now = Calendar.getInstance();
                                      return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);

                              }

Re : I'm trying to add sound..

$
0
0
  player = minim.loadFile("GhostBusters.mp3");
  minim = new Minim("GhostBusters.mp3");

So, you init minim after you started to use it...
Invert these two lines.
Beside, the Minim constructor must be called with a this parameter, not with the file name.

Re : Save PDF on keypress

NullPointerException PFont.addGlyph

$
0
0
I periodically get this error.  Any suggestions how I could handle it?
java.lang.NullPointerException
    at processing.core.PFont.addGlyph(PFont.java:462)
    at processing.core.PFont.index(PFont.java:584)
    at processing.core.PFont.width(PFont.java:664)
    at processing.core.PGraphics.textWidthImpl(PGraphics.java:3270)
    at processing.core.PGraphics.textWidth(PGraphics.java:3246)
    at myapp.myappCore.trimText(myappCore.java:17697)
    at myapp.myappCore.linkmap(myappCore.java:11731)
    at myapp.core.thread.RunAnalysis.run(RunAnalysis.java:25)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)

java.lang.NullPointerException
java.lang.NullPointerException
    at processing.core.PFont.addGlyph(PFont.java:462)
    at processing.core.PFont.index(PFont.java:584)
    at processing.core.PFont.getGlyph(PFont.java:567)
    at processing.core.PGraphics.textCharImpl(PGraphics.java:3728)
    at processing.opengl.PGraphicsOpenGL.textCharImpl(PGraphicsOpenGL.java:1598)
    at processing.core.PGraphics.textLineImpl(PGraphics.java:3716)
    at processing.core.PGraphics.textLineAlignImpl(PGraphics.java:3706)
    at processing.core.PGraphics.text(PGraphics.java:3405)
    at processing.core.PGraphics.text(PGraphics.java:3360)
    at processing.core.PApplet.text(PApplet.java:8931)
    at myapp.myappCore.drawloader(myappCore.java:13805)
    at myapp.myappCore.drawloader(myappCore.java:13744)
    at myapp.myappCore.programloader(myappCore.java:12931)
    at myapp.myappCore.draw(myappCore.java:836)
    at processing.core.PApplet.handleDraw(PApplet.java:1631)
    at processing.core.PApplet.run(PApplet.java:1530)
    at java.lang.Thread.run(Thread.java:680)




Re : HELP! pdf/ high res images

How to get work a uEye cam in processing?

$
0
0
Hello guys, 
I was trying to make a tracking with a IR cam, but the problem is that processing doesn't recognize my cam. 

I'm working with a Asus Eee PC 1000H and I've tested this little script with three cam's. First with the internal cam from my Netbook. Secondly with a Logitech C310 and at last with the IDS uEye UI-1555LE-C-GL. Which is my IR cam.

My result was that the first and second cam works, but the third not. I have all the drivers and progs installed that I could find for this cam, but it only works with the own programs. Of course I've Quick Time Player and VDig installed. 

I try this script also in to different processing Versions. First the 1.5.1 and secondly the 2.0b7. In the first Version nothing works and in the second only the first and the second cam. 

This is the script that I found here in the processing Website, which I've used for trying:
  1. import processing.video.*;

  2. Capture cam;

  3. void setup() {
  4.   size(640, 480);

  5.   String[] cameras = Capture.list();
  6.   
  7.   if (cameras.length == 0) {
  8.     println("There are no cameras available for capture.");
  9.     exit();
  10.   } else {
  11.     println("Available cameras:");
  12.     for (int i = 0; i < cameras.length; i++) {
  13.       println(cameras[i]);
  14.     }
  15.     
  16.     // The camera can be initialized directly using an 
  17.     // element from the array returned by list():
  18.     cam = new Capture(this, cameras[0]);
  19.     cam.start();     
  20.   }      
  21. }

  22. void draw() {
  23.   if (cam.available() == true) {
  24.     cam.read();
  25.   }
  26.   image(cam, 0, 0);
  27.   // The following does the same, and is faster when just drawing the image
  28.   // without any additional resizing, transformations, or tint.
  29.   //set(0, 0, cam);
  30. }

I don't know if this example doesn't work with IR cams. 
I was also trying to solve it with the other processing Video examples and also with OpenCV, but it doesn't works at all. Only with this example. 

Maybe you have an idea for my solution. Thanks for your time. 

 

MovieMaker using save frame function. Error code java.lang.NullPointerException

$
0
0
HI

I'm an absolute beginner trying to mix Processing with moving images edited on Premiere Pro. I'm just trying to do very simple sketches and then want to export as video clip to layer with traditional video on Premiere. I use the save frame function as in;

long initialTime;

void setup(){
size(600,200);
strokeWeight (5);
initialTime = millis();
}
void draw() {
float x = 10;
float y = 50;                              //set the multiplier to adjust speed
line(x,y+50,x+(millis()-initialTime)*0.05, y+50);  
saveFrame ("frames/####/png");
 }

When I click on 'create movie' I get the error message: 'QuickTime Movie failed. java.lang.NullPointerException.

I'm so frustrated as I don't have the experience to try to work around the issue. So please.....can anyone help? Please?

Apalou

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 

Re : Adding background image to existing code

$
0
0
Have you looked at background() this is probably the easiest way to do it especially since you are using a 3D renderer.

Re : Adding background image to existing code

$
0
0
i tried stuffs like 
  1. PImage b;
  2. void setup(){
  3. ...
  4. b = loadImage("fondo_fade.png");
  5. ...
  6. }
  7. void draw(){
  8. image(b, 0, 0);
  9. ...
  10. }
but i keep getting errors , like i said i am new to processing
could u be more specific

Re : Adding background image to existing code

$
0
0
Change draw() to

  1. void draw(){
  2.       background(b);
  3.       // ...
  4. }

The only restriction is that the image MUST be the same size as the skecth canvas (as speciified in the size() method call)

Re : Adding background image to existing code

$
0
0
I tried what you suggested but i got the error " it looks like you'r e mixing active with static modes" and the "background(b);" gets highlighted at line 51 .

i did resize the image to 800x600


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

  3. Serial serial;
  4. int serialPort = 1;   // << Set this to be the serial port of your Arduino - ie if you have 3 ports : COM1, COM2, COM3 
  5.                       // and your Arduino is on COM2 you should set this to '1' - since the array is 0 based
  6.               
  7. int sen = 3; // sensors
  8. int div = 3; // board sub divisions

  9. Normalize n[] = new Normalize[sen];
  10. MomentumAverage cama[] = new MomentumAverage[sen];
  11. MomentumAverage axyz[] = new MomentumAverage[sen];
  12. float[] nxyz = new float[sen];
  13. int[] ixyz = new int[sen];

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

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

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

  40. void draw() {
  41.   updateSerial();
  42.   drawBoard();
  43. }
  44. background(b);
  45. void updateSerial() {
  46.   String cur = serial.readStringUntil('\n');
  47.   if(cur != null) {
  48.     String[] parts = split(cur, " ");
  49.     if(parts.length == sen  ) {
  50.       float[] xyz = new float[sen];
  51.       for(int i = 0; i < sen; i++)
  52.         xyz[i] = float(parts[i]);
  53.   
  54.       if(mousePressed && mouseButton == LEFT)
  55.         for(int i = 0; i < sen; i++)
  56.           n[i].note(xyz[i]);
  57.   
  58.       nxyz = new float[sen];
  59.       for(int i = 0; i < sen; i++) {
  60.         float raw = n[i].choose(xyz[i]);
  61.         nxyz[i] = flip[i] ? 1 - raw : raw;
  62.         cama[i].note(nxyz[i]);
  63.         axyz[i].note(nxyz[i]);
  64.         ixyz[i] = getPosition(axyz[i].avg);
  65.       }
  66.     }
  67.   }
  68. }
  69. }
  70. float cutoff = .2;
  71. int getPosition(float x) {
  72.   if(div == 3) {
  73.     if(x < cutoff)
  74.       return 0;
  75.     if(x < 1 - cutoff)
  76.       return 1;
  77.     else
  78.       return 2;
  79.   } 
  80.   else {
  81.     return x == 1 ? div - 1 : (int) x * div;
  82.   }
  83. }

  84. void drawBoard() {
  85.   background(255);

  86.   float h = w / 2;
  87.   camera(
  88.     h + (cama[0].avg - cama[2].avg) * h,
  89.     h + (cama[1].avg - 1) * height / 2,
  90.     w * 2,
  91.     h, h, h,
  92.     0, 1, 0);

  93.   pushMatrix();
  94.   noStroke();
  95.   fill(0, 40);
  96.   translate(w/2, w/2, w/2);
  97.   rotateY(-HALF_PI/2);
  98.   box(w);
  99.   popMatrix();

  100.   float sw = w / div;
  101.   translate(h, sw / 2, 0);
  102.   rotateY(-HALF_PI/2);

  103.   pushMatrix();
  104.   float sd = sw * (div - 1);
  105.   translate(
  106.     axyz[0].avg * sd,
  107.     axyz[1].avg * sd,
  108.     axyz[2].avg * sd);
  109.   fill(255, 160, 0);
  110.   noStroke();
  111.   sphere(18);
  112.   popMatrix();

  113.   for(int z = 0; z < div; z++) {
  114.     for(int y = 0; y < div; y++) {
  115.       for(int x = 0; x < div; x++) {
  116.         pushMatrix();
  117.         translate(x * sw, y * sw, z * sw);

  118.         noStroke();
  119.         if(moves[0][x][y][z])
  120.           fill(255, 0, 0, 200);
  121.         else if(moves[1][x][y][z])
  122.           fill(0, 0, 255, 200);
  123.         else if(
  124.         x == ixyz[0] &&
  125.           y == ixyz[1] &&
  126.           z == ixyz[2])
  127.           if(player == 0)
  128.             fill(255, 0, 0, 200);
  129.           else
  130.             fill(0, 0, 255, 200);
  131.         else
  132.           fill(0, 100);
  133.         box(sw / 3);

  134.         popMatrix();
  135.       }
  136.     }
  137.   }
  138.   
  139.   fill(0);
  140.   if(mousePressed && mouseButton == LEFT)
  141.     msg("defining boundaries");
  142. }

  143. void keyPressed() {
  144.   if(key == TAB) {
  145.     moves[player][ixyz[0]][ixyz[1]][ixyz[2]] = true;
  146.     player = player == 0 ? 1 : 0;
  147.   }
  148. }

  149. void mousePressed() {
  150.   if(mouseButton == RIGHT)
  151.     reset();
  152. }

  153. void reset() {
  154.   moves = new boolean[2][div][div][div];
  155.   for(int i = 0; i < sen; i++) {
  156.     n[i].reset();
  157.     cama[i].reset();
  158.     axyz[i].reset();
  159.   }
  160. }

  161. void msg(String msg) {
  162.   text(msg, 10, height - 10);
  163. }
could you please help me out here ? 
I am new to these, we are using it for our semester project 

Re : Adding background image to existing code

$
0
0
Line 50 is the end of your draw() function. Your call to background() on line 51 is not inside any function!
You should replace line 93 with line 50, and then remove line 50.

Re : Adding background image to existing code

$
0
0
It seems @ line # 51 -> background(b);
it is outside of any function scope.

AFAIK, it shoulda been the 1st thing inside function draw()!

P.S.: In these posts:
http://forum.processing.org/topic/deleted-forum-processing-org-topic-traffic-light-functions-help
http://forum.processing.org/topic/animation-erasing-and-keeping-method

There are some tricks there to turn a loaded image scaled to canvas dimensions in setup(),
then, ready to be used for background() within draw()!

That would be useful if you hadn't pre-scaled your background image outside Processing.  

Re : Adding background image to existing code

$
0
0
In your code above line 51 is in the wrong place it should be in the draw() method so move it so it looks like this

  1. void draw() {
  2.   background(b);
  3.   updateSerial();
  4.   drawBoard();
  5. }
Also you should remove the following line (93) from the drawBoard() method
  background(255);

since it will set the background to white, replacing your image.

Re : Adding background image to existing code

Viewing all 1768 articles
Browse latest View live