w8r/martinez

Using the martinez package for p5.js art projects

Closed this issue · 3 comments

I really want to be able to use this amazing package to create generative art in p5.js! However p5 does not allow packages to be loaded using the import or require() methods. Instead I need to define all functions of a library in a javascript file and specify this as a script to load in the index.html file.

I've been looking into webpack as an option to bundle all the code into a single file. And I found the martinez/dist/martinez.min.js (https://github.com/w8r/martinez/blob/v0.6.2/dist/martinez.min.js) file that looks to already be bundled.

However how can I use the martinez.min.js file? What would be the function calling convention (function name, methods and inputs)?

My apologies for lack on knowledge using javascript packages, I've tried googling how to solve this problem but I'm stuck.

Thanks a lot!

w8r commented

If you just use it via the <script> tag, it will be exposed in the global space as martinez, then you can call the methods on it, such as martinez.intersection(...) etc.

Thanks, I feel rather silly but that worked well.

Do you have a bundled script for the latest version?

I could only find for version v0.6.2 and I'm getting some weird results when trying to recreate your demo.