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

How to find the solution (transitions)

$
0
0

I've download and modify this program, I have a problem when I run this sketch, Processing says to me "impossible to / by zero" but I've charged a list. why the list as zero ?

This is my code :

import com.bric.image.transition.Transition;
import com.bric.image.transition.ScribbleTransition2D;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

Transition t;
ArrayList<String> images = new ArrayList<String>(); // list of images to load
PImage[] img;
int currentImage = 0;
int nextImage;
BufferedImage[] buf;
BufferedImage out;
Graphics2D g2;
int frames = 100; // number of frames per transition

void setup(String path) {
  File folder = new File(path);
  File[] listOfFiles = folder.listFiles();

  for (File file : listOfFiles) {
    if (file.isFile() && (file.getName().contains(".jpg") || file.getName().contains(".png"))) {
      images.add(file.getName());
    }
  }

  size(600, 300);
  // create pimage array
  img = new PImage[images.size()];
  // create buffered image array
  buf = new BufferedImage[images.size()];
    for (int h = 0 ; h < images.size() ; h++) {
      img[h] = loadImage(images.get(h));
      buf[h] = (BufferedImage)img[h].getNative();
    }
  t = new ScribbleTransition2D(true);
  // all the images should be the same size
  out = new BufferedImage(img[0].width, img[0].height, BufferedImage.TYPE_INT_ARGB);
  g2 = out.createGraphics();
}

void draw() {

    if ((frameCount % frames) == 0) {
    // bump images
    currentImage = nextImage;
    }
  nextImage = (currentImage + 1) % images.size();
  // draw transition into graphic
  t.paint(g2, buf[currentImage], buf[nextImage], (frameCount % frames) / (float)frames);
  // copy graphic to screen
  image(new PImage(out), 0, 0);
}

Please I want help ! :)


Viewing all articles
Browse latest Browse all 2896

Trending Articles