Last active
March 27, 2019 16:28
-
-
Save MAKIO135/95eec47639c16a0dc6e13ebe7bcd5dd6 to your computer and use it in GitHub Desktop.
canvas-sketch x akai-lpd8
This file contains hidden or 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
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