Last active
August 29, 2015 14:06
-
-
Save 0b5vr/0b03a48cee9f4c9c0d01 to your computer and use it in GitHub Desktop.
Basic of Projection Mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// you must prepare image | |
PImage image; | |
int[] x=new int[4]; | |
int[] y=new int[4]; | |
void setup() | |
{ | |
size(displayWidth,displayHeight,P2D); | |
image=loadImage("image.png"); | |
} | |
void draw() | |
{ | |
background(0); | |
fill(0); | |
stroke(255); | |
strokeWeight(8); | |
textureMode(NORMAL); | |
beginShape(); | |
texture(image); | |
vertex(x[0],y[0],0,0); | |
vertex(x[1],y[1],1,0); | |
vertex(x[2],y[2],1,1); | |
vertex(x[3],y[3],0,1); | |
endShape(CLOSE); | |
} | |
void keyPressed() | |
{ | |
if(key=='0') | |
{ | |
x[0]=mouseX; | |
y[0]=mouseY; | |
} | |
if(key=='1') | |
{ | |
x[1]=mouseX; | |
y[1]=mouseY; | |
} | |
if(key=='2') | |
{ | |
x[2]=mouseX; | |
y[2]=mouseY; | |
} | |
if(key=='3') | |
{ | |
x[3]=mouseX; | |
y[3]=mouseY; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment