Last active
March 30, 2018 11:56
-
-
Save RobbertWolfs/2ee5b74ba229d2024db49147964e6938 to your computer and use it in GitHub Desktop.
Pixels - Houdini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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