Galeria de imagenes.


   String [] s = {
    "1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"    
  };
  int indiceActual =0;
  PImage [] imgs = new PImage [s.length];
  PImage img;
  void setup() {
    size(1500, 1000);
    for (int i= 0; i<s.length; i++) {
      imgs [i] = loadImage(s[i]);
    }
    textSize(40);
    img = loadImage(s[indiceActual]);           //pocicion
 
    imageMode(CENTER);
    rectMode(CENTER);
  }
  void draw () {
    //text(s[],width/2, height/2);
    //for (int i=0; i<s.length ; i++ ){
    background(0);
    img = loadImage(s[indiceActual]);          
    image (img, width/2, height/2);
    text(s[indiceActual], width/2, height/2);
    //}
    for (int i= 0; i<imgs.length; i++) {
      image(imgs[i], i*width/imgs.length+width/imgs.length/2, height/1.12, 100, 100);
    }
    if (mouseY>height/1.12 - width/imgs.length/2 && mouseX>width/imgs.length ) {
      noFill();
      stroke(0, 255, 255);
      strokeWeight(4);
      rect(width/imgs.length+width/imgs.length/2, height/1.12, 105, 105);
   
    } else {
      noStroke();
    }
  }
  void mouseClicked() {
    if (mouseX>width/2) {
      indiceActual= indiceActual+1;
    } else if (mouseX<width/2) {
      indiceActual= indiceActual-1;
    }
    if (indiceActual > s.length-1) {
      indiceActual = 0;
    }
    if (indiceActual <  0) {
      indiceActual = s.length-1;
    }
    img = loadImage(s[indiceActual]);
  }






No hay comentarios:

Publicar un comentario