public void setup() {
   size(400, 400);
   background(255);
   stroke(0);
   img = loadImage("http://cseweb.ucsd.edu/~minnes/palmTrees.jpg", "jpg");
   img.resize(0, height);
   image(img, 0, 0);
 }
  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();
  }
  public void draw() {

    Date date = new Date(); // given date
    Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
    calendar.setTime(date); // assigns calendar to given date
    calendar.get(Calendar.HOUR_OF_DAY); // gets hour in 24h format
    calendar.get(Calendar.HOUR); // gets hour in 12h format
    calendar.get(Calendar.MONTH);
    backgroundImg.resize(0, height);
    image(backgroundImg, 0, 0);
    int r = 0;
    int g = 0;
    int b = 0;
    int hour = (calendar.get(Calendar.HOUR_OF_DAY));
    int second = (calendar.get(Calendar.SECOND));
    switch (second % 5) {
      case 0:
        fill(255, 0, 0);
        break;
      case 1:
        fill(0, 255, 0);
        break;
      case 2:
        fill(0, 0, 255);
        break;
      case 3:
        fill(227, 227, 0);
        break;
      case 4:
        fill(227, 0, 227);
        break;
      default:
        fill(0, 227, 227);
        break;
    }

    ellipse(width / 4, height / 6, width / 5, height / 5);
  }
  // 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);
  }
Exemple #5
0
  /** Setup processing. */
  public void setup() { // NOPMD

    receivedGestures[BLUE] = new ArrayList<String>();
    receivedGestures[GREEN] = new ArrayList<String>();

    // Create Enviroment.
    size(screen.width - 1, screen.height - 1, OPENGL);
    textMode(MODEL);
    background(255);
    noStroke();
    smooth();
    createRandomness();

    thisInteractome = new Interactome(this, MAX_SIZE, MIN_SIZE, CIRCLE_COUNT, SCREENS, splayer);
    initializeTitles(); // starting, ending
    kare = 0;
    trans = 0;

    // Initialize gestures Map.
    gestMap.put(0, "TOWhor");
    gestMap.put(1, "TOWver");
    gestMap.put(2, "TOWfor");

    for (int i = 1; i < 13; i++) {
      final PImage tmpImage =
          loadImage("eu/funinnumbers/games/sg/tow/engine/ui/visualoutput/img/TOWhor_" + i + ".gif");
      tmpImage.resize(tmpImage.width / 4, tmpImage.height / 4);
      horFrames.add(tmpImage);
    }

    for (int i = 1; i < 16; i++) {
      final PImage tmpImage =
          loadImage("eu/funinnumbers/games/sg/tow/engine/ui/visualoutput/img/TOWver_" + i + ".gif");
      tmpImage.resize(tmpImage.width / 4, tmpImage.height / 4);
      verFrames.add(tmpImage);
    }

    for (int i = 1; i < 8; i++) {
      final PImage tmpImage =
          loadImage("eu/funinnumbers/games/sg/tow/engine/ui/visualoutput/img/TOWfor_" + i + ".gif");
      tmpImage.resize(tmpImage.width / 4, tmpImage.height / 4);
      forFrames.add(tmpImage);
    }

    for (int i = 0; i < 6; i++) {
      PImage tmpImage =
          loadImage("eu/funinnumbers/games/sg/tow/engine/ui/visualoutput/img/any.gif");
      tmpImage.resize(tmpImage.width / 2, tmpImage.height / 2);
      anyFrames.add(tmpImage);

      tmpImage = loadImage("eu/funinnumbers/games/sg/tow/engine/ui/visualoutput/img/null.gif");
      tmpImage.resize(tmpImage.width / 2, tmpImage.height / 2);
      anyFrames.add(tmpImage);
    }

    imagesForGestures.put("TOWhor", horFrames);
    imagesForGestures.put("TOWver", verFrames);
    imagesForGestures.put("TOWfor", forFrames);

    team1gesA = horFrames.get(0);
    team2gesA = horFrames.get(0);

    stage1Team1width = width / 4 - team1gesA.width / 2;
    stage1Team2width = 3 * width / 4 - team2gesA.width / 2;

    stage1height = height - team1gesA.height;

    // fillImageVectors();
    timer.scheduleAtFixedRate(new ChangeCurrentImages(), 2000, IMG_REFRESHRATE);
    timer.scheduleAtFixedRate(new CheckStage(), 4000, STAGE_REFRESHRATE);

    // Set the default font
    textFont(fontCounter, 255);
    textSize(48);

    // Setup Counters
    teamWidth = width / SCREENS;

    // Counter settings
    counterBoxX[0] = 100 - 5;
    counterBoxX[1] = width - 100 - 5;
    counterBoxY = height - 95;
    counterX[0] = 100;
    counterX[1] = width - 100;
    counterY = height - 50;
  }