Skip to content

Instantly share code, notes, and snippets.

@RobbertWolfs
Last active March 30, 2018 11:56
Show Gist options
  • Save RobbertWolfs/2ee5b74ba229d2024db49147964e6938 to your computer and use it in GitHub Desktop.
Save RobbertWolfs/2ee5b74ba229d2024db49147964e6938 to your computer and use it in GitHub Desktop.
Pixels - Houdini
registerPaint('pixels', class {
static get inputProperties() { return ['--size', '--art']; }
paint(ctx, geom, properties) {
const size = properties.get('--size').toString();
const art = JSON.parse(properties.get('--art').toString());
Object.keys(art).forEach(index => {
const row = art[index];
Object.keys(row).forEach(index2 => {
const column = row[index2];
ctx.fillStyle = column;
ctx.beginPath();
ctx.rect(index2 * size, index * size, size, size);
ctx.fill();
})
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment