canvas = {
const w = 35, h = 35
let index = 0
const canvas = DOM.canvas(width, 2 * h)
const context = canvas.getContext("2d")
const scale = 1
const cols = Math.floor(width / w)
const rows = Math.floor(height / h)
context.fillStyle = 'transparent'
context.fillRect(0, 0, width, height)
const delta = 16.6667
const idleAnimation = {
duration: 1000,
animate: (context, sprite, t) => {
idlyLookAround(sprite, t)
drawEyeball(context, sprite)
}
}
const blinkAnimation = {
duration: 800,
animate: (context, sprite, t) => {
updateBlink(sprite, t)
drawBlink(context, sprite)
}
}
const animations = [ idleAnimation, blinkAnimation ]
for (let animation of animations) {
const s = sprite(16)
for (let t = 0; t < animation.duration; t += delta) {
context.save();
const col = index % cols
const row = Math.floor(index / cols)
context.translate(col * w, row * h)
context.translate(w / 2, h / 2)
context.scale(scale, scale)
animation.animate(context, s, t)
context.restore()
t += delta
index++
}
}
yield canvas
}