cake
April 18, 2020, 9:26pm
1
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
If you copy p5.Vector.js
/**
* @module Math
* @submodule Vector
* @requires constants
*/
import p5 from '../core/main';
import * as constants from '../core/constants';
/**
* A class to describe a two or three dimensional vector, specifically
* a Euclidean (also known as geometric) vector. A vector is an entity
* that has both magnitude and direction. The datatype, however, stores
* the components of the vector (x, y for 2D, and x, y, z for 3D). The magnitude
* and direction can be accessed via the methods <a href="#/p5/mag">mag()</a> and <a href="#/p5/heading">heading()</a>.
* <br><br>
* In many of the p5.js examples, you will see <a href="#/p5.Vector">p5.Vector</a> used to describe a
* position, velocity, or acceleration. For example, if you consider a rectangle
* moving across the screen, at any given instant it has a position (a vector
* that points from the origin to its location), a velocity (the rate at which
This file has been truncated. show original
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.
opened 07:17PM - 17 Sep 17 UTC
closed 01:26AM - 17 Nov 18 UTC
Unit Testing
Help Wanted
For information, see https://github.com/ariya/phantomjs/issues/15105
This is … just an issue to note that testing should probably be moved over to headless chrome (Probably puppeteer: https://github.com/GoogleChrome/puppeteer ) when the ecosystem is a bit better (I can't see a way to integrate it in the grunt file easily yet)
Possibly see also:
cake
April 18, 2020, 10:34pm
5
Both of these are great resources thank you!