Inherit/Use p5.Vector methods in NodeJS

Hello! I’d like to inherit & use p5.Vector & its methods in a class I’m writing. / Use p5.Vector without a window.

This is backend code, I’ve seen that p5 cannot ‘run’ without a ‘window’ object. As it gives me ‘window’ is not defined.

The answer that I’m leaning towards is just having to write my own vector class. Not too bad of a solution, just wondered if anyone else wondered this?

With the p5.Vector class as an example I’ll probably just make my own :slight_smile:

If you copy p5.Vector.js

and remove the line

import p5 from '../core/main';

…what breaks?

1 Like

Another option – use headless chrome, the way (I believe?) the project does for CI testing through mocha on Node.js 12.x.

Possibly see also:

2 Likes

Both of these are great resources thank you! :slight_smile: