It would be useful to be able to specify a callback function that gets called when starting on a new drawing file. For example:
state = null # global variable
export onNewDrawing = -> state = [] # new proposal
export default -> ...sometimes modify state to carry data to future cells...
This could also be used as a way to (manually) implement symbol aliases (#68) within a drawing file.
Note that an alternative/workaround right now is to add data to the Context object. This is shared within each drawing but no more.
Another application: preprocessing the drawing. This is arguably a better time to modify a drawing than #69. Maybe even allow returning some global content to draw like #81? But maybe makes more sense to do such global drawing after the layout.
# Example 1: compute
export beforeDrawing = (drawing) ->
for row, i in drawing.keys
for char, j in row
# do some computation / walking through the drawing
# to detect things that will be used later
# maybe return content to draw?
# Example 2: configuration in first row of drawing
export beforeDrawing = (drawing) ->
firstRow = drawing.keys.shift() # remove first row from drawing!
# set some settings based on firstRow
For symmetry with #81, could maybe be called beforeDrawing.
Could even modify keys to be non-strings (e.g. objects), as this happens after coercion to String.
It would be useful to be able to specify a callback function that gets called when starting on a new drawing file. For example:
This could also be used as a way to (manually) implement symbol aliases (#68) within a drawing file.
Note that an alternative/workaround right now is to add data to the
Context
object. This is shared within each drawing but no more.Another application: preprocessing the drawing. This is arguably a better time to modify a drawing than #69. Maybe even allow returning some global content to draw like #81? But maybe makes more sense to do such global drawing after the layout.
For symmetry with #81, could maybe be called
beforeDrawing
.Could even modify keys to be non-strings (e.g. objects), as this happens after coercion to String.