// Flat tringle mesh with texture for image warping // Written by Jarek Rossignac June 2006 import processing.opengl.*; // comment out if not using OpenGL PImage jarek; // image used as texture PImage leo; // second image used as texture int n=33; // size of grid. Must be >2! pt[][] G = new pt [n][n]; // array of vertices int pi,pj; // indices of vertex being dragged when mouse is pressed pt Mouse = new pt(0,0,0); // current mouse position boolean showVertices=true, showEdges=false, showTexture=true; // flags for rendering vertices and edges color red = color(200, 10, 10), blue = color(10, 10, 200), green = color(10, 200, 20), black = color(10, 10, 10); float w,h,ww,hh; // width, height of cell in absolute and normalized units vec offset = new vec (0,0,0); // offset vector from mouse to clicked vertex // constraints int mc = 20; // max number of constraints int[] cn = new int [10]; // number of constraints in each set int[][] I = new int [10][mc]; // i coordiantes of saved constraints int[][] J = new int [10][mc]; // j coordiantes of saved constraints pt[][] C = new pt [10][mc]; // constrainted location int m=0; // current set of constraints int t=255; // animation variable, when t=1, aniamtion stops int x=255; // amount of transparency in animation void restoreConstraints () { pinBorder(); for (int k=0; k