Programmatic and Direct Manipulation, Together at Last
Paper and Supplementary Appendix, November 2015
To help set the context for evaluating our artifacts, we quote some descriptions from our submitted paper:
You can try Sketch-n-Sketch right away by selecting an example using the dropdown menu and then directly manipulating the visual output. To edit the program directly, click Edit Code, type some changes, and then click Run Code to re-evaluate the program. (Removing the need to click Edit Code is a feature that has long been on our TODO list.)
The examples depicted in Figure 3 are named Wave Boxes, Logo, Botanic Garden Logo, Active Trans Logo, Lillicon P, Chicago Flag, and Hilbert Curve Animation. The examples depicted in Figure 3 are named Widgets, Rounded Rect, and Tile Pattern. The three tasks depicted in the user study videos are named Ferris Task (Before/After), Keyboard Task (Before/After), and Tessellation Task (Before/After). The Survey Results example implements the histograms in Figure 4. The examples depicted in the Appendix are named 3 Boxes, Elm Logo, and Ferris Wheel.
To do more than directly manipulate examples that have already been written, you will need to learn a bit about the syntax of Little and the features and options in the Sketch-n-Sketch editor. We provide the following resources, along with rough estimates of how long you may decide to spend with them.
Parts 1, 2, 3, and 4 (approximately 20 minutes in total) provide a high-level overview of Little and Sketch-n-Sketch.
Part 5 shows the tasks we developed for our user study; the survey questions can be found in the Appendix to our paper.
The syntax guide defines the grammar for Little as well as the encoding of SVG values. To see a variety of Little programs, you may view the source code for prelude.little (automatically included in every program) and the examples.
This multi-part tutorial constitutes the most thorough introduction to Sketch-n-Sketch as well as some more advanced uses.
Our implementation provides two kinds of zones beyond the basic SVG zones described in our paper, namely, color zones and rotation zones. A simple example that uses both:
(def [x y w h] [76 118 127 131]) (def [cx cy] [(+ x (/ w 2!)) (+ y (/ h 2!))]) (def color 216) (def rotation 45) (def myShape (rect color x y w h)) (svg [(rotate myShape rotation cx cy)])
When toggling the Zones button to display Extra zones, a slider will be displayed to manipulate the color and a circle will be displayed to manipulate the rotation angle.
Our tool currently does not report helpful error messages. When there is a parse error, the caption "PARSE ERROR!" is displayed under the output canvas without any additional information.
When there is a run-time error, usually the output canvas usually displays the string "[Little Error]" (sometimes with the line and column numbers of the offending expression) but sometimes a JavaScript exception is raised (visible in the brower's Web Console). In the latter case, reload the application.
There are several aspects of our implementation that would benefit from optimizations: the evaluation of Little programs, re-evaluation of Little programs during live mode, and the data structures computed and maintained by the editor to make heuristic choices and compute triggers. Our current approach for each of these is naive, leading to some known performance issues:
When a "(def x e1) e2" expression appears anywhere but the top-level scope of the program, the unparser currently inserts extra, unwanted whitespace. The workaround is to use the equivalent let-expression form "(let x e1 e2)", which can appear anywhere without sufferring this issue.
The pane separating the code and canvas can be resized. If you stop dragging (by releasing the mouse) before the position of the pane has caught up to the mouse position, the editor may get stuck in a state where it resizes the panes upon each successive click. In such situations, reload the application.
Our implementation is open source, but we have not yet made an effort to organize and document it in a way that would make it easy for others to extend. If one wants to poke around anyway, here are a few pointers: