image not working

hi, for my image, i want to be able to click on it and then have a white fill like an eraser PLEASE help below is my script as well as this keeps showing up, how to get rid of that?

The file "Capture.PNG" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.


void setup(){
  size(800,600);
  background(255);
  noStroke();
  drawControls();
  fill(0); //black
}

{
  loadImage("Capture.PNG");
}

void draw() {

  if (mousePressed == true && mouseY < 500) {
    ellipse (mouseX, mouseY, 20,20);
  }
  if (mousePressed == true && mouseY > 500) {
    checkButtons();//run our function
  }
}

void drawControls() {
  fill (127);//grey
  rect(0,500,800,100);//bottom part of screen
  fill (255,0,0);//red
  rect (0,550,50,50);//botton left
  fill (0);//black
  rect (50,550,50,50);//botton 2nd left
  fill(0,255,0);//green
  rect (0,500,50,50);//top left
  fill(0,50,255);//blue
  rect (50,500,50,50);//top 2nd left
  fill(150,16,95); //Purple  
  rect(100,550,50,50); //purple
  fill(23,300,135); 
  rect(100,500,50,50); //light green
  image(loadImage("Capture.PNG"), 300,500);
  fill(0); //black
  rect (700,550,50,50);//reset button
  fill(255); //white
  rect (750,550,50,50);//reset button
}


void checkButtons(){

  if(mouseX < 50 && mouseY > 550) {
    fill(255,0,0);
  }

  if(mouseX > 0 && mouseX < 50 && mouseY < 550) {
    fill(0,255,0);
  }

  if(mouseX > 50 && mouseX < 100 && mouseY < 550  ) {
    fill(0,50,255);
  }

  if(mouseX > 50 && mouseY > 550 && mouseX < 100) {
    fill(0);
  }

  if(mouseX > 700 && mouseY > 550 && mouseX < 750) { 
    fill(0);
    rect(0,0,800,500);
  }

  if(mouseX > 750 && mouseY > 550 && mouseX < 800) { 
    fill(255);
    rect(0,0,800,500);
  }

  if (mouseX < 150 && mouseX > 100 && mouseY < 550) { //clicked on light green
    fill (23,300,135); // light green
  }

  if (mouseX==300 && mouseY == 500) 
    fill (255); // white

  if (mouseX < 150 && mouseX > 100 && mouseY > 550) { //clicked on light blue
    fill (150,16,95); // purple
  }
} 
Tagged:

Answers

  • edited March 2015

    OK. First, place PImage myImage = loadImage("Capture.PNG"); inside your setup(). you need to have a PImage variable to store your image. Second, ensure that your file is titled exactly "Capture.PNG" (it is case-sensitive! .PNG and .png - different names!) and is added to your sketch via Sketch -> Add File. Third this image(loadImage("Capture.PNG"), 300,500); replace with image(myImage, 300,500);.

  • properly indented, it's obvious you have a dubious block on lines 12-14...

  • Why is this in Developing Processing category? Obviously, you don't compile / modify Processing yourself... I move this topic.

  • Beside, your loadImage() line is outside any function, so it is called before setup() is called itself. But the path to data folder is only known after setup() started.

    See also What are setup() and draw()?

Sign In or Register to comment.