title: Optimizing code to generate static
body: <p>I am learning p5.js and wanted to generate a "static/noise texture" like so:</p>
  
  <p><a href="https://i.stack.imgur.com/FgqRR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FgqRR.jpg" alt="enter image description here"></a></p>
  
  <p>This is the code:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>for (let y = 0; y &lt; height; y++) {
    for (let x = 0; x &lt; width; x++) {
      noiseVal = random(0,1);
      stroke(255, noiseVal*255);
      point(x,y);
    }
  }
  </code></pre>
  
  <p>This produces the desired outcome but it's obviously pretty slow since it has to iterate over every single pixel. What would be a more efficient way of doing this?</p>