Beispiel #1
0
 boolean createTransition(final int frames) { // NOPMD
   boolean rtn = false;
   fill(0, 1);
   noStroke();
   rect(0, 0, width, height);
   if (trans <= 250) {
     for (int i = 0; i < 100; i++) {
       final int xPos = (int) (random(ICON_BACKGROUND.width));
       final int Pos = (int) (random(ICON_BACKGROUND.height));
       // int pix = (int)map(a.get(posX, posY), 0, 255, 0, 255-alpha);
       final int pix = ICON_BACKGROUND.get(xPos, Pos);
       fill(pix, 10);
       final int randx = (int) (random(width));
       final int randy = (int) (random(height));
       ellipse(randx, randy, i, i);
       fill(0, trans);
       ellipse(randx, randy, i, i);
     }
     if (trans <= 10) { // 1
       if (frames % 4 == 0) {
         trans += 1;
       }
     } else if (trans >= 200) {
       trans = 255;
     } else {
       trans += 1;
     }
   } else {
     fill(0, 255);
     noStroke();
     rect(0, 0, width, height);
     rtn = true;
   }
   return rtn;
 }
  public void draw() {
    background(0);

    /*    pushMatrix();
        translate(width/2,height/2);
    //    nav.doTransforms();

        translate(-vl.bb().centroid().x,-vl.bb().centroid().y);
        scale(5);
        strokeWeight(0.2f);
        noFill();

        UVertex last=null;
        for(UVertex v:vl) {
          stroke(0);
          v.pellipse(v,0.1f, 0.1f);
          if(last!=null) {
            if(v.dist(last)>15) stroke(200);
            v.pline(v,last);
          }

          last=v;
        }
        popMatrix();
    */
    //    noLights();
    noTint();
    stroke(255, 0, 0);
    //    strokeWeight(2);
    noFill();
    //    translate(100,100);
    translate(width / 2, height / 2);
    nav.doTransforms();
    translate(-img.width / 2, -img.height / 2, -5);

    fill(img.get(300, 300));
    rect(-img.width, -img.height, img.width * 3, img.height * 3);
    translate(0, 0, 5);
    image(img, 0, 0);

    UVertex last = null;
    for (UVertex v : vl) {
      UVertex res = UMapping.mercatorMapping(v, geobb, img.width, img.height);
      fill(255, 100, 0);
      noStroke();
      UMB.pellipse(res, 4);
      stroke(255, 100, 0);
      noFill();
      res.z = 20;
      UMB.pellipse(res, 12);
      //      strokeWeight(0.6f);
      point(res.x, res.y);

      if (last != null) v.pline(res, new UVertex(res.x, res.y, 0));
      last = res;
    }
  }
Beispiel #3
0
 EImage(NoKinect sce, String file) {
   parent = sce;
   position = new int[3];
   extrude = parent.loadImage(file);
   extrude.loadPixels();
   forDelta = 10;
   values = new int[extrude.width * extrude.height];
   for (int x = forDelta; x < extrude.width; x += forDelta) {
     for (int y = forDelta; y < extrude.height; y += forDelta) {
       values[(x * extrude.width) + y] = (int) (parent.brightness((int) extrude.get(x, y)));
       for (int d = 0; d < forDelta; d++) {
         values[(x * extrude.width) + y] +=
             (int) (parent.brightness((int) extrude.get(x - d, y - d)));
       }
       values[(x * extrude.width) + y] /= forDelta;
     }
   }
 }
  public void setImages(PImage i_mainImage, PImage i_gridImage) {

    mainImage = i_mainImage.get();
    gridImage = i_gridImage.get();

    if (size.x / (i_mainImage.width + 0.0) < size.y / (i_mainImage.height + 0.0)) {
      mainImage.resize((int) this.size.x, 0);
      gridImage.resize((int) this.size.x, 0);
    } else {
      mainImage.resize(0, (int) this.size.y);
      gridImage.resize(0, (int) this.size.y);
    }

    imageOffset =
        new PVector(
            this.size.x / 2.0f - mainImage.width / 2.0f,
            this.size.y / 2.0f - mainImage.height / 2.0f);
    redrawNow();
  }
Beispiel #5
0
 public static PImage invert(Matrix H, PImage img, Point dstDimension) {
   PImage res = new PImage(dstDimension.x, dstDimension.y);
   //		PImage res = new PImage(img.width, img.height);
   for (int x = 0; x < img.width; x++) {
     for (int y = 0; y < img.height; y++) {
       // Point inverse theorique (x0,y0) ?
       double[][] q_array = {{x}, {y}, {1}};
       Matrix P = H.times(new Matrix(q_array));
       double x0 = P.get(0, 0) / P.get(2, 0);
       double y0 = P.get(1, 0) / P.get(2, 0);
       // S'il est hors de l'image originale, on rend le pixel transparant.
       if (x0 < 0 || x0 >= img.width || y0 < 0 || y0 >= img.height) res.set(x, y, 0x00000000);
       else res.set(x, y, img.get((int) x0, (int) y0));
     }
   }
   return res;
 }
Beispiel #6
0
  public BFont(PApplet pa, String filename) {
    this.pa = pa;
    PImage fontImage = pa.loadImage(filename);
    int rows = (int) Math.floor(fontImage.height / GameConstants.TILE_H);
    int columns = (int) Math.floor(fontImage.width / GameConstants.TILE_W);

    characters = rows * columns;
    font = new PImage[characters];

    for (int j = 0; j < rows; j++) {
      for (int i = 0; i < columns; i++) {
        font[(j * columns) + i] =
            fontImage.get(
                i * GameConstants.TILE_W,
                j * GameConstants.TILE_H,
                GameConstants.TILE_W,
                GameConstants.TILE_H);
      }
    }
  }
  // FUNCTION THAT WILL BE CALLED IN PARENT CLASS
  public void createbg() {

    PImage canvas;
    // addational value
    float r = 1;

    // MASKE erstellen (Vignette)
    // begindraw and endraw are needed for pgraphics to work properly
    mask.beginDraw();
    // make a black background
    mask.background(0);
    // center the anchorpoint
    mask.shapeMode(PConstants.CENTER);
    // make a white ellipse half as large as the canvas
    mask.fill(255);
    mask.ellipse(width / 2, height / 2, width / 1.3f, height / 1.3f);
    // resize for better blur compability (prevent crashes)
    mask.resize(width / 5, height / 5);
    mask.filter(PConstants.BLUR, 19);
    // restire full size. this will blur the image even further
    mask.resize(width / 2, height / 2);
    mask.endDraw();

    // CREATE Picture
    pimg.beginDraw();
    // make a black background
    pimg.background(0);

    // this will generate bubbles specified by the image (NOT FINISHED)
    for (int i = 0; i < img.width; i += parent.random(200)) {
      for (int j = 0; j < img.height; j += parent.random(200)) {
        pimg.fill(img.get(i, j));
        pimg.noStroke();
        pimg.shapeMode(PConstants.CENTER);
        pimg.ellipse(i + 1, j + 1, r, r);
        r = parent.random(0.2f, 200);
      }
      r = parent.random(0.2f, 200);
    }

    // resize for better blur compability (prevent crashes)
    pimg.resize(width / 5, height / 5);
    pimg.filter(PConstants.BLUR, 9);

    // create a temp canvas to use te mask
    canvas = pimg.get();
    canvas.filter(PConstants.BLUR, 15);
    canvas.resize(width / 2, height / 2);

    // apply mask on the generated image
    pimg.resize(width / 2, height / 2);
    pimg.image(canvas, 0, 0);
    pimg.mask(mask.get());
    pimg.endDraw();

    // set the transparent image on a black background
    // save the vignetted image
    stage.beginDraw();
    stage.image(pimg.get(), 0, 0);
    stage.endDraw();
    stage.save(output_path + output_data);
  }
Beispiel #8
0
 public PImage copyImage(PImage img) {
   // A more efficient method may be possible - e.g. TimeDisplacement example P5 sketch.
   return img.get();
 }