Open LoganPress opened 3 years ago
Interesting, not sure why they're accessible on the library object. I will look into it, thanks for the tip 🙂
No problem. I'm pretty new to this library, is there a reason that you wouldn't want constants accessible on the library object? It seems that because these constants aren't specific to any specific sketch, they should be globally accessible.
Only general considerations of keeping the API simple.
I do see the point that in the context of a Vue app, vue-p5 acts as a replacement for p5, and it would make sense to import constants from 'vue-p5'
instead of having a separate import { PI } from 'p5'
.
Yes, this is a WIP solution that we are into.. with the next update, we will be able to use all p5 constants
Right now p5 is reexported, so all p5 exports are available globally that way and there's no need to have p5 as a separate dependency. I'll wait for more feedback to see if there is another problem to be solved here.
Some constants, such as PI, can only be accessed as properties of the sketch object. However, other enum values such as CLOSE (ie for endShape) can be accessed either as a direct property of the sketch object, or as a property of the VueP5 library. Doesn't it make sense to wrap other, non-sketch-specific constants to be accessible through the top-level VueP5?