Using the Unsplash image API - reveal pixel by pixel.
A Pen by rachaelcodes on CodePen.
Using the Unsplash image API - reveal pixel by pixel.
A Pen by rachaelcodes on CodePen.
let img | |
let scale = 20 | |
function preload() { | |
img = loadImage('https://source.unsplash.com/random/1200x800'); | |
} | |
function setup() { | |
createCanvas(1200, 800) | |
img.loadPixels() | |
noStroke() | |
} | |
function draw() { | |
let x = int(random(img.width / scale + 1)) | |
let y = int(random(img.height / scale + 1)) | |
let col = img.get(x * scale, y * scale) | |
fill(col) | |
circle(x * scale, y * scale, scale - 1) | |
} |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.2.0/p5.min.js"></script> |
html, body { | |
margin: 0; | |
padding: 10px; | |
background: #000000; | |
} | |
canvas { | |
margin: 0 auto; | |
display: block; | |
} |