Skip to content

Instantly share code, notes, and snippets.

@nick3499
Created April 19, 2016 15:12
Show Gist options
  • Select an option

  • Save nick3499/1de6f156f8a3225b107802363c41ea89 to your computer and use it in GitHub Desktop.

Select an option

Save nick3499/1de6f156f8a3225b107802363c41ea89 to your computer and use it in GitHub Desktop.
Load Pixels. Using p5.js library.
function setup () {
createCanvas(1152, 648);
background(0);
}
function draw () {
loadPixels();
var d = pixelDensity();
var t = 4 * (width * d) * (height * d);
for (var i = 0; i < t; i += 4) {
pixels[i + 0] = random(85, 255); // red
pixels[i + 1] = 0; // green
pixels[i + 2] = 0; // blue
pixels[i + 3] = 255; // alpha
}
updatePixels();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment