Kinrany / vue-p5

Vue component for p5.js
125 stars 16 forks source link

Usability: Common Constants #33

Open LoganPress opened 3 years ago

LoganPress commented 3 years ago

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?

Kinrany commented 3 years ago

Interesting, not sure why they're accessible on the library object. I will look into it, thanks for the tip 🙂

LoganPress commented 3 years ago

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.

Kinrany commented 3 years ago

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'.

sniperadmin commented 3 years ago

Yes, this is a WIP solution that we are into.. with the next update, we will be able to use all p5 constants

Kinrany commented 3 years ago

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.