Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final int len=25;
- final float thresh=170;
- boolean newDesign=false;
- PImage pic;
- ArrayList<PImage> imgContainer;
- int n=3;
- void setup() {
- size(800, 800, P2D);
- colorMode(RGB, 255);
- background(250, 250, 250);
- rectMode(CENTER);
- //imageMode(CENTER);
- pic=loadImage("hand.jpg");
- pic.resize(width, height);
- color c1 = color(200,25,25);
- color c2 = color(25, 255, 200);
- imgContainer=new ArrayList<PImage>();
- PImage pimg1=loadImage("test2.jpg_0.png");
- pimg1.resize(50, 50);
- imgContainer.add(pimg1);
- PImage pimg2=loadImage("test2.jpg_1.png");
- pimg2.resize(50, 50);
- imgContainer.add(pimg2);
- PImage pimg3=loadImage("test2.jpg_2.png");
- pimg1.resize(50, 50);
- imgContainer.add(pimg3);
- noLoop();
- noStroke();
- }
- void draw() {
- if (newDesign==false) {
- return;
- }
- pic.loadPixels();
- for (int y = 0; y < height; y+=18) {
- for (int x = 0; x < width; x+=18) {
- // Get the color stored in the pixel
- int index=y*width+x;
- color pixelValue = pic.pixels[index];
- // Determine the brightness of the pixel
- float pixelBrightness = brightness(pixelValue);
- float imgPicked=constrain(pixelBrightness/thresh, 0, n-1);
- image(imgContainer.get((int)imgPicked),x,y);
- }
- }
- }
- void mouseReleased() {
- newDesign=!newDesign;
- redraw();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement