Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

New in processing, constructor problem.

$
0
0

Hello, I'm new on processing. I'm trying to put my sketch in a class, so I can later on build more stuff on top. But a the very beginning of that I get an error on : cam = new Capture(this, 320, 240, 30); "the constructor doesn't exist". But it does, it's in the library. Any idea how to solve that ? Thanks

import processing.video.*;
Pixi myPixi;

void setup() {

  size(1200, 1200);
  myPixi = new Pixi();
}


void draw() {

  myPixi.trans();
}


class Pixi {

  int pointillize = 36;
  int Lx[] = {1, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300};
  int Ly[] = {1, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220};

  Pixi() {

    Capture cam;
    cam = new Capture(this, 320, 240, 30);
    cam.start();
    background(0);
    rectMode(CENTER);
  }



  void trans() {

    cam.read();
    int x = Lx[ (int) random(Lx.length) ];
    int y = Ly[ (int) random(Ly.length) ];
    int loc = x + y*cam.width;
    loadPixels();
    float r = red(cam.pixels[loc]);
    float g = green(cam.pixels[loc]);
    float b = blue(cam.pixels[loc]);
    noStroke();
    fill(r, g, b, 255);
    rect(((x+150)*2), ((y+150)*2), pointillize, pointillize);
  }
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles