-
Notifications
You must be signed in to change notification settings - Fork 73
Value Scrubbing / Graphical Value Pickers #45
Comments
How to implement value pickers in the editor windowIf you are using a conventional text editor to edit Curv programs, then it isn't possible to implement value pickers in the editor window. The default @doug-moen said:
@s-ol replied:
|
Implementing value pickers in the viewer windowThis is my current project. I'm building an experimental proof-of-concept. The idea is to first create working code, then improve the design. A parametric shape is a shape value containing additional metadata which describe its parameters. This allows the Viewer window to display graphical sliders for modifying numeric shape parameters. The shape animates as the sliders are moved. (A primary design goal is to represent parametric shapes as first class values, rather than by placing a special interpretation on source files that contain specially formatted comments.) Right now, you can construct parametric shapes using code like this:
Parametric shapes are supported by the following language features:
Parametric RecordsA parametric record remembers how it was constructed. It remembers its construction parameters, and it allows you to selectively change those parameters and make a modified copy of the record. This metadata is stored in two record fields:
On the left of the On the right side of the Predicate PatternsA predicate is a function that returns true or false. Predicates are used to classify values. For example, there are some built in predicates like Within a function definition like this:
the phrase Value Picker PredicatesTo support parametric shapes, we are defining a set of value picker predicates. These are predicate functions that carry extra metadata that describe the type of a value picker, and additional parameters specifying the range of values supported by the value picker. The initial prototype will just support sliders: |
I would like to see logarithmic sliders on the Todo list here! If you don't want to deal with all the edge cases of UI inputs and get a lot of different input means "for free" you might want to look into dear imgui, it's a well known, robust and variable UI framework that stays out of your way and doesn't need to own or invade your data structures, which makes integrating it very easy. |
@s-ol Thanks for the recommendations. Logarithmic sliders are a good idea. I am looking into GUI toolkits. I haven't tried any yet.
|
There is now an experimental implementation of slider controls in the Viewer window.
|
The syntax is now more convenient: the old |
First public preview, plus documentation: https://github.com/doug-moen/curv/blob/master/examples/picker/README.md |
"Value Scrubbing" is the ability to modify a value in a Curv program using direct manipulation. For example, tweaking a numerical value using a graphical slider. While you drag the indicator on the slider, the shape in the Viewer window updates in real time. This is an important "live coding" feature that makes it easy to explore the effect that different parameter values have on a parametric shape.
Here are two approaches that we could take in Curv. They aren't mutually exclusive, and they serve different types of users.
Value Pickers in the Viewer Window
In one approach, you modify the source code and declare which parameters can be "scrubbed" using an interactive value picker. The declaration includes the type of value picker, and additional information like the start and end values of a numeric slider. When the program is evaluated and the shape is displayed, a collection of value pickers is displayed in the Viewer window along with the shape. This is similar to the Thingiverse customizer, the OpenSCAD customizer, and Fragmentarium.
In this approach, a developer can design a parametric shape, and create a "user interface" for tweaking the parameters. Then another user, who may not understand the code, can use the value pickers in the Viewer window to customize the shape.
Value Pickers in the Editor Window
In the other approach, you select a literal constant in the source code, and a value picker appears above the constant for scrubbing the value. Examples:
Used by developers, for writing Curv programs.
The text was updated successfully, but these errors were encountered: