p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

How to add p5.dom to p5.js in instance mode

Open fcin opened this issue 9 years ago • 1 comments

I'm using requirejs to bundle my files. I've used p5.js for some time, but I need to add p5.dom now. The problem is I don't know how to do it with my requirejs. I couldn't find any information how to do it with bundling. I tried many combinations, but p5.dom is always undefined This is what I have so far:

require(['lib/p5js/lib/p5', 'lib/p5js/lib/addons/lib/p5.dom'], function (p5) {
    var myp5 = new p5(function (_sketch) {
        _sketch.setup = function() {
           _sketch.createButton('click me'); // _sketch doesn't have createButton function
       }
    });
});

fcin avatar Jun 10 '17 18:06 fcin

Hi! What exactly are you trying to do? when working with p5.dom your working with not only your sketch but the whole dom tree. My suggestion would be to just use something like this in the header of your html page.

<script type='text/javascript' src='relative/path/to/your/p5.dom.js'>

This is a good link to check out for a overview of working w/ the dom + p5. also Daniel Shiffman has some great videos explaining it as well. (https://github.com/processing/p5.js/wiki/Beyond-the-canvas)

jmandel1027 avatar Jul 20 '17 01:07 jmandel1027