Tadaaa! The code has been implemented!
The only problem i have is that my original klas.jpg
is 1454 x 387 pixels, but in the program the klas.jpg gets loaded
364 x 98 pixels, because otherwise the image would not fit on
all screens.
Because of this, my selection
imageis taken from this 364 x 98 pixels image, and
is very pixelated.
Wich is not good, it's making the heads inrecognizable.
Does anyone know a solve to this problem?
Giles, would you run my program with a 1454 x 387 pixels
klas.jpg? You will surely notice my problem.
Cheers!
Code:int venster, start, geslacht, startX, startY; PFont lettertype1; PImage klas; PImage selectie;
void setup () {textAlign(CENTER); imageMode(CENTER); size(500,500);
lettertype1 = createFont("Verdana", 20); textFont(lettertype1); klas = loadImage("klas.jpg");}
void mousePressed(){
if((mouseButton==LEFT) && (venster == 2) && (mouseX>=68) && (mouseX<=432) &&
(mouseY>=201) && (mouseY<=299)) {start = 1; startX = mouseX; startY = mouseY;}}
void mouseReleased(){
if((mouseButton==LEFT) && (venster == 0) && (mouseX>=215) && (mouseX<=285) &&
(mouseY>=235) && (mouseY<=265)) {venster = 1;}
if((mouseButton==LEFT) && (venster > 0) && (mouseX>=30) && (mouseX<=100) &&
(mouseY>=30) && (mouseY<=60)) {start = 0; venster = venster - 1;}
if((mouseButton==LEFT) && (venster == 1) && (mouseX>=145) &&
(mouseX<=215) && (mouseY>=235) && (mouseY<=265)) {geslacht = 1; venster = 2;}
if((mouseButton==LEFT) && (venster == 1) && (mouseX>=285) &&
(mouseX<=355) && (mouseY>=235) && (mouseY<=265)) {geslacht = 2; venster = 2;}
if((mouseButton==LEFT) && (venster == 2) && (mouseX<68) ||
(mouseX>432) || (mouseY<201) || (mouseY>299) && (start == 1)) {start = 0;}
if((mouseButton==LEFT) && (venster == 2) && (mouseX>=68) &&
(mouseX<=432) && (mouseY>=201) && (mouseY<=299) &&
(start == 1)) {background (255);image (klas,250,250,364,98);
selectie=get(min(mouseX, startX), min(mouseY, startY), abs(mouseX-startX), abs(mouseY-startY));venster = 3;}}
void draw() {
if (venster > 0) {background(255);fill (255);rect(30,30,70,30);fill (0);text("<-",65,53);}
if (venster == 0) {background(255);fill (0);rect(215,235,70,30);
text("Welcome to the Body-program.",250,450);fill (255);text("Start",250,257);}
if (venster == 1) {fill (0);rect(145,235,70,30);rect(285,235,70,30);
text("First choose your gender.",250,450);fill (255);text("M",180,257);text("F",320,257);}
if (venster == 2) {fill (0);rect (0,0,0,0);
text("Now select your head.",250,450);image (klas,250,250,364,98);}
if ((venster == 2) && (start == 1)) {fill(255,50);rect(startX, startY, mouseX-startX, mouseY-startY);}
if (venster == 3) {
text("Is this the head you wanted?",250,450);image (selectie,250,250);}}