Skip to content

Instantly share code, notes, and snippets.

@MAKIO135
Last active March 27, 2019 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MAKIO135/95eec47639c16a0dc6e13ebe7bcd5dd6 to your computer and use it in GitHub Desktop.
Save MAKIO135/95eec47639c16a0dc6e13ebe7bcd5dd6 to your computer and use it in GitHub Desktop.
canvas-sketch x akai-lpd8
const canvasSketch = require('canvas-sketch')
const p5 = require('p5')
const LPD8 = require('akai-lpd8')
new p5()
const settings = {
dimensions: [600, 600],
p5: true,
animate: true
}
window.preload = () => {
}
window.mousePressed = () => {
print({mouseX, mouseY})
}
const sketch = async () => {
const lpd8 = new LPD8()
await lpd8.init()
// event mode:
lpd8.PAD1.noteOn(vel => background(0))
lpd8.K4.on('change', vel => fill(vel * 2))
background(0)
return ({width, height}) => {
// direct mode:
ellipse(map(lpd8.K1.velocity, 0, 127, 0, width), map(lpd8.K2.velocity, 0, 127, 0, width), 5 + lpd8.K3.velocity)
}
}
canvasSketch(sketch, settings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment