Generalize shapes
Generalize shapes that appear in clock elements.
-
[number, ...]
should indicate the default shape -- a line or a disc, or something like that. -
(elem, ...) => {}
should indicate a function to call to draw the shape. -
ClockShape()
objects should indicate an object to call to draw the shape. -
[shape, ...]
should indicate a list of shapes to draw. Figure out a way to replace the sel property for ticks and how to set the format for each shape. Perhaps something like[shape, format]
should be permitted anywhere a shape is specified.
Helper functions should be available:
-
shapes.rectangle(x1, y2, x2, y2)
should return a function that draws a shape.-
shapes.rectangle(w, h)
should be a shorthand for shapes.rectangle(0-w/2, 0-h/2, w/2, h/2). -
shapes.square(d)
should be a shorthand for shapes.rectangle(d, d).
-
-
shapes.arc(x1, y1, radius, start, end)
should return an arc.-
shapes.circle(x1, y1, radius)
should be a shorthand for shapes.arc(x1, y1, radius, 0, 2*Math.PI). -
shapes.circle(radius)
should be a shorthand for shapes.circle(0, 0, radius).
-
-
shapes.poly([[x,y]...], ...)
should draw a polygon with [x,y] coordinates from each list of points. -
shapes.polarpoly((angle) => distance, start?, end?, fineness?)
should draw a polygon from polar coordinates generated by the function. Fineness gives a hint about the step (initially, the step, see beloow for laters). -
shapes.line(x1, y1, x2, y2)
should draw a line.
Fineness in the polarpoly function should initially be the angle step. Later we should try to optimize the coordinates by removing coordinates that are unnecessary (essentially, when the derivative is small enough, widen the step) and fineness should say something about tolerances. Not sure how to implement this.
Helper functions for poly should be available:
-
poly.rectangle
- rectangle in polar coordinates. -
poly.squarishRound
- see clockshapes.js. -
poly.roundishSquare
- see clockshapes.js. -
poly.constant(val)
- just return the constant. -
poly.average([w1, f1], ...)
should compute a weighted average of functions.
Edited by David Byers