Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow variables and arithmetic in option values #6

Open
doersino opened this issue Feb 16, 2022 · 3 comments
Open

Allow variables and arithmetic in option values #6

doersino opened this issue Feb 16, 2022 · 3 comments

Comments

@doersino
Copy link
Owner

I had this idea while doing the dishes today and got really excited, but the work required to implement turns out to be significant, so I'm merely keeping it as an idea for now. Would open up a host of possibilities, though (and make some sliders obsolete, but I'd keep them anyway).

My hastily-jotted-down notes, left for future me to make sense of:

// TODO allow variables and arithmetic in option values
// variables: i (iteration), s (segment number), x, y
// +, -, *, /, ^ (exponentiation (or maybe bitwise operators)), %
// (parens)
// sine, cosine, tan, etc.
// write parser or just eval? how to show errors? e.g. parse errors, div by 0
// encode permissible variables for each option in options data structure (e.g. line shape has none, color has iteration, etc.)
// could show permissible variables in popover
// display like out-of-range numbers, or greenish?
// gray out slider if value is not a number (or out of range)?, also disable increment and decrement via keyboard, provideo some ui element to reset back into bounds
// would need to have some kind of evalOpt(o, env=[i, s, x, y]) function
// challenge: serialization for url - encode alpha characters somehow? capitals? any issues with math characters?
@doersino
Copy link
Owner Author

(This would be a conceptual kinda marriage between UJI and tixyz, I suppose.)

@doersino
Copy link
Owner Author

doersino commented Feb 20, 2022

(Could use https://mathjs.org/docs/expressions/parsing.html for math parsing and evaluating, but it's pretty bulky. Or just straight eval, but, ugh. Perhaps adequate: Function, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/Function. Or: https://cdnjs.com/libraries/expr-eval)

@doersino
Copy link
Owner Author

Design idea for a "function" button (using U+0192) that would become visible when directly editing a value, it'd replace the slider with a text field.

Screen Shot 2022-02-20 at 11 00 53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant