4 ms·
Neat looking library, but I have a little syntax question-- what's the reason for using ugly Cish constants like Smooth.METHOD_CUBIC? Surely it would work just
by Cushman 15y ago
Neat looking library, but I have a little syntax question-- what's the reason for using ugly Cish constants like Smooth.METHOD_CUBIC? Surely it would work just as well (and be more JSish) to say something like
Smooth points,
method: 'cubic'
clip: 'periodic'
cubicTension: 'catmull-rom'
- mistercow 15y agoI can't give any really strong justification, besides to say that C-style constants make me feel warm and safe. My weak justifications are that I find having my constants declared in one place helps me to remember to handle all of them, and that it helps slightly with auto-complete. But there is a good reason in the case of the cubicTension constants: those aren't enums, but actual values. You can put any cubicTension parameter you want between 0 and 1.
- Cushman 15y agoTotally get that-- if it's the style you're comfortable with, go for it. Hope I didn't sound critical, just curious. Although if I may, there is a potential benefit to using strings there in that it lets you get rid of the switch statement entirely: unless config.clip of ClipHelpers throw new Error "No clip mode '#{config.clip}'. Available modes are #{(k for k of ClipHelpers).join(', ')}" clipHelper = ClipHelpers[config.clip] This could also make it easy for a user to add helpers at runtime. Maybe overkill for this, just something to keep in mind.