Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PImage imgMod, imgOrg;
- int num = 50;
- void setup() {
- imgMod = loadImage("psycho_mod.jpg");
- imgOrg = loadImage("psycho_original.jpg");
- size(imgMod.width, imgMod.height);
- image(imgMod, 0, 0);
- createStuff();
- }
- void draw() {
- }
- void mouseClicked() {
- createStuff();
- }
- void keyPressed() {
- if (key=='d') {
- num += 20;
- println(num);
- }
- if (key=='n') {
- tint(255, 255);
- image(imgMod, 0, 0);
- }
- if (key=='s') saveFrame("image-###.jpg");
- }
- void createStuff() {
- //image(imgMod, 0, 0);
- for (int i=0; i<num; i++) {
- int x = (int) random(380, 880);
- int y = (int) random(0, 420);
- int szX = (int) random(10, 150);
- int szY = (int) random(10, 150);
- float rx = 0;
- if (x<630) {
- rx = random(-width/2,0);
- } else {
- rx = random(0, width/2);
- }
- float ry = random(-50, 20);
- PImage imgTemp = createImage(szX, szY, RGB);
- imgTemp.loadPixels();
- int j=0;
- for (int py=y; py<y+szY; py++) {
- for (int px=x; px<x+szX; px++) {
- imgTemp.pixels[j]=imgOrg.get(px, py);
- j++;
- }
- }
- imgTemp.updatePixels();
- float distance = dist(x+rx, y+ry, width/2, 210);
- println(distance);
- float alpha = map(distance, 0, width/2, 150, 0);
- tint(255, alpha);
- image(imgTemp, x+rx, y+ry);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement