bitcraftlab / p5.gui

p5.gui magically generates a graphical user interface for your p5.js sketches
https://bitcraftlab.github.io/p5.gui
MIT License
354 stars 91 forks source link

set the slider boundaries with variables #1

Closed allartburns closed 7 years ago

allartburns commented 7 years ago

If they exist, use variables with the suffixes "Min", "Max", and "Step" to change the parameters of a single slider.

var releaseTime = 0.5; var releaseTimeMin = 0; var releaseTimeMax = 1.0; var releaseTimeStep = 0.01; var pitch = 0.3; var pitchMin = 20; // lower bound of human hearing var pitchMax = 7000 // super high var pitchStep = 1;

craftoid commented 7 years ago

Hey @allartburns. Thank you! this is actually a very good idea 👍 My current approach is to use sliderRange(min, max, step) which a little less magical. But I really like the idea of magic variables. I'm wondering if it makes sense to extend this to lower case as well (x, xmin, xmax, xstep ...) What do you think?

allartburns commented 7 years ago

I wrote this because I couldn't get sliderRange() to work the way I wanted. I wanted several sliders with different min/max/step values, but maybe there's a way to do that with sliderRange() that can go in the docs.

I've worked at so many companies with different style guides that I'm not attached to the capitalization. What I explain to students is just to pick a style and be consistent.

craftoid commented 7 years ago

Hello again, and a happy new year! Merging this now, but will modify it soon, it to make sure it's not case sensitive.

I should probably mention, that from now on values set via gui.sliderRange() will only affect values which have not explicitly been set via magic variables, which probably make sense.

I'll add one or two examples that document how to set the slider range to the example folder...