How to scroll back & forth/up & down thru a series [array?] of images using mouseDragged?

edited October 2013 in How To...

Hi everyone,

I'm a beginner.

I need to enable scrolling through 2 series of identically sized jpegs (31 per series) in the same frame. Across & back thru one series, up & down thru the other series. They are snapshots of a 3D object in horizontal and vertical rotation, and share a common middle image. The objective is to simulate QTVR interaction with a 3D object (I realize this will be very chunky).

I'm guessing that PImage[] would the array declaration,

I would need to loadImage for every file regardless of naming convention in the data folder, that I could somehow replace 'int' w/ an image file in an 'if' statement, and that the mouseDragged function will be exported in Jscript as a swipe function for an iPad…?

Any advice is welcome.

Thanks for yr time, John

Answers

  • edited October 2013

    I can give some starting tips: %%-

    • You're gonna need a 2D structure to store your PImage objects.
      1st dimension for up/down series change (row change) and 2nd 1 for left/right image change (column change).
      Are any of those dimensions of fixed quantity? Like you got 10 series rows? That would make syntax less convoluted.
      For fixed # of elements, we use regular arrays; otherwise an ArrayList.
      For the "worst" case scenario (both dimensions are of unknown # of elements) use something like:
      final ArrayList<ArrayList<PImage>> imgs = new ArrayList();

    • A snippet to load all images from a folder:

    =====================================================================================================

    import java.io.FilenameFilter;
    
    final static String[] exts = {
      ".gif", ".png", ".jpeg", ".jpg"
    };
    
    final static FilenameFilter pictsFilter = new FilenameFilter() {
      boolean accept(File dir, String name) {
        name = name.toLowerCase();
        for (int i = exts.length; i-- != 0;)  if (name.endsWith(exts[i]))  return true;
        return false;
      }
    };
    
    final static File[] getFolderContent(File dir) {
      return dir.listFiles(pictsFilter);
    }
    
  • Look at the Categories descriptions. Not a question about code (you don't show any) but an obvious How To question...
    Moved.

Sign In or Register to comment.