Open CrazyPyroEagle opened 4 years ago
My current idea for this is something like the following:
<anm-program>
<!--
Declare variables. anm-newvar will set up the necessary templates for inclusion with `anm-var`.
anm-newvar otherwise has no visual output.
-->
<anm-newvar id="counter" type="upa"></anm-newvar>
<anm-newvar id="output" type="musubi"></amn-newvar>
<!-- Set the counter variable to 1. -->
<anm-setvar name="counter"><anm-expression>1<anm-expression></anm-setvar>
<!-- Output the value of the counter variable. -->
<anm-say><anm-expression><anm-var name="counter"></anm-var></anm-expression></anm-say>
</anm-program>
(An earlier example I had used anm-define-var
instead of anm-newvar
and anm-declaration
instead of anm-setvar
. And maybe we should shorten anm-expression
to anm-expr
.)
anm-newvar
will set up at least three templates: one full size and one quarter-size for inclusion in Chika quarters for anm-setvar
, and one small square size for anm-var
. These templates would have IDs like counter_full
and counter_small
for the various sizes. These templates can be referred to by their IDs. The templates for use with anm-setvar
will have an unnamed slot for where the text will go.
The id
attribute of anm-newvar
is the name of the variable, and the type determines the image.
The values that type
can take on is currently a set of known values (the specific values are TBD, but at they're at least the ones in the original FizzBuzz image). The values are associated with a config that contains the location of the images for each template (or perhaps a single image for all three and crop and size values for each of the templates) and the coordinates for where the text should be centered on. We might look to allow arbitrary types in the future as long as a config is given, perhaps with an anm-vartemplate
that contains a config.
anm-setvar
is a statement for variable assignment. Examples in the original FizzBuzz image are the first image (for full size) and the Chika positive quarters (quarter size). It will use the template set up by anm-newvar
and pass its children to the default slot (i.e. the children become value of the variable to set). I'm hoping there's a way we can automatically determine the size needed based on context, but if not, we can have an attribute like size
that sets the size to use.
anm-var
renders the square size for use in expressions. Unlike the original image, I don't think we need two sizes: one size should be good enough. All usages of anm-var
represent reading the contents variable.
It would be useful to have an easy way of assigning to and using variables, instead of needing to manually write the necessary boilerplate.