MosaiCat.

With the image from
Orange And White Cat Closeup
http://www.photos-public-domain.com/2011/01/07/orange-and-white-cat-closeup/

Description.

Made with Processing.

Yet another work using 'blendMode(DIFFERENCE)'.

You can use your own photo.
You can hard coding the path of your photo image file or you can give command line parameter like this.

/your_processing_installed_path/processing-java --force --sketch=/your_sketch_path/ --run /your_photo_file_path


Reference.

Shades of Grey.

Code.

Please feel free to use it, if you like it.
To see another works based on my code is my pleasure. And my honor.


// MosaiCat.
// @author @deconbatch
// @version 0.2
// Processing 3.2.1
// 0.1 2018.03.28
// 0.2 2018.12.23

float baseWH;

void setup() {

  size(1080, 1080);
  baseWH = 980;

  colorMode(HSB, 360, 100, 100, 100);
  smooth();
  noLoop();

}

void draw() {

  PImage img;

  if (args == null) {
    // you can use your photo in ./data/your_image.jpg
    img = loadImage("your_image.jpg");
  } else {
    // args[0] must be image path
    img = loadImage(args[0]);
  }

  // fit to canvas size
  float rateSize = baseWH / max(img.width, img.height);
  float canvasW  = img.width * rateSize;
  float canvasH  = img.height * rateSize;
  img.resize(int(canvasW), int(canvasH));
  img.loadPixels();

  // effective pale gray
  background(0, 0, 95, 100);

  // mosaic
  blendMode(DIFFERENCE);
  drawRect(canvasW, canvasH);

  // image overlay
  blendMode(SCREEN);
  image(img, (width - canvasW) / 2, (height - canvasH) / 2);

  // casing
  blendMode(BLEND);
  casing(canvasW, canvasH);
  
  // save image
  saveFrame("frames/####.png");
  exit();

}


void drawRect(float canvasW, float canvasH) {

  rectMode(CENTER);
  noFill();
  
  float spaceX = random(100);
  float spaceY = random(100);

  int rectCnt = 80;
  for (int j = 0; j < rectCnt; ++j) {

    float multi = 1.0 + noise(spaceX, spaceY) * 200;
    stroke(
           0,
           0,
           multi / 4,
           100
           );

    pushMatrix();
    translate(
              map(noise(spaceX), 0, 1, (width - canvasW) / 2, (width + canvasW) / 2),
              map(noise(spaceY), 0, 1, (height - canvasH) / 2, (height + canvasH) / 2)
              );
    strokeWeight(0.5 * multi);
    //    rotate(radians(45));
    rect(
         0,
         0,
         2 * multi,
         2 * multi
         );
    popMatrix();

    spaceX += 1.0;
    spaceY += 1.0;

  }

}


void casing(float canvasW, float canvasH) {

  rectMode(CORNER);
  fill(0, 0, 100, 0);
  strokeWeight(50);
  stroke(0, 0, 100, 100);
  rect((width - canvasW) / 2 - 25, (height - canvasH) / 2 - 25, canvasW + 50, canvasH + 50);

}

/*
Copyright (C) 2018- deconbatch

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see 
*/






No comments :

Post a Comment