title: How can I clear the canvas using one click in processing?
body: <p>I was trying to make a very simple game but I'm having trouble with mouse events. I want to only click once and the whole canvas will be cleared but what happen is it keeps on coming back to its original canvas if I'm not clicking anymore.</p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>if((mouseX &gt;= 100) &amp;&amp; (mouseX &lt;= 235) &amp;&amp;
     (mouseY &gt;= 490) &amp;&amp; (mouseY &lt;= 540) &amp;&amp;
     (mousePressed))
  {
    clear ();
    slide1 ();
  }
  </code></pre>
  
  <p>This is the second tab:</p>
  
  <pre class="lang-java prettyprint-override"><code>void slide1()
  {
    clear ();
    background (30);`enter code here`
    slide1 = loadImage ("slide1.jpg");
    image (slide1,100,0,400,300);
  }
  </code></pre>