/* Mirror image in several ways, works well on rectangular images * there are 24 modes for rectangular and 12 in square * Author: Tomasz Sulej, generateme.blog@gmail.com, 2015, * Thanks Gus Holiday for inspiration */ // Configure // - set image filename // - put list of actions // Actions (hard to explain, just experiment): // UL - mirror upper left triangle onto down right // UR - ^ upper right -> down left // DL, DR - similar // L - mirror left part to right // R, U, D - similar (right, up, down) // version 2 - copy (flip and flop) // S* - versions for rectangle, choose the right or down side of the image // R* - use rectangles diagonals to copy // Usage: // click to do one more actions on current result // ENTER/RETURN to reset // SPACE to save // filename here: String filename = "test"; String fileext = ".jpg"; String foldername = "./"; int max_display_size = 800; // viewing window size (regardless image size) // actions here (comma separated in curly braces): int[] order = { UL, L, DL }; // do you want order of operations choosen by machine? If true, script ignores what you set up boolean automatic = true; // mirror final static int UL = 0; final static int UR = 1; final static int DL = 2; final static int DR = 3; final static int U = 4; final static int D = 5; final static int L = 6; final static int R = 7; // mirror 2 final static int UL2 = 8; final static int UR2 = 9; final static int DL2 = 10; final static int DR2 = 11; // shift mirror final static int SUL = 12; final static int SUR = 13; final static int SDL = 14; final static int SDR = 15; // shift mirror2 final static int SUL2 = 16; final static int SUR2 = 17; final static int SDL2 = 18; final static int SDR2 = 19; // rectangle mirror2 final static int RUL = 20; final static int RUR = 21; final static int RDL = 22; final static int RDR = 23; int size; int tx,ty; PImage img; // working buffer PGraphics buffer; String sessionid; void setup() { sessionid = hex((int)random(0xffff),4); img = loadImage(foldername+filename+fileext); buffer = createGraphics(img.width, img.height); buffer.beginDraw(); buffer.image(img,0,0); buffer.noStroke(); buffer.endDraw(); // calculate window size float ratio = (float)img.width/(float)img.height; int neww, newh; if(ratio < 1.0) { neww = (int)(max_display_size * ratio); newh = max_display_size; } else { neww = max_display_size; newh = (int)(max_display_size / ratio); } size(neww,newh); //<>// size = img.widthsize) tx = img.width-size; if(img.height>size) ty = img.height-size; image(buffer,0,0,width,height); } void draw() {} void mouseClicked() { buffer.beginDraw(); if(automatic) { int n = (int)random(1,16); order = new int[n]; for(int i=0;i=size-y-1;x--) switch(type) { case 0: drawPoint(x,y,size-y-1,size-x-1,shift); break; case 1: drawPoint(size-y-1,size-x-1,x,y,shift); break; case 2: drawPoint(x,y,size-x-1,size-y-1,shift); break; case 3: drawPoint(size-x-1,size-y-1,x,y,shift); break; default: break; } } void doHorizontal(boolean type) { for(int y=0;y