Let's use Scenic, a new Elixir UI library, to visualize processes. From there we can start to model biological behaviours such as movement, smell and sight.
of UI primitives 2. Handle input and events An app will typically contain multiple screens Is implemented as a GenServer, hence has state, can send and receive messages Provides send_graph(graph) function for rendering the scene
things to draw on the screen. Primitives can be added, removed and modified Graph.add_to_graph(graph, text("foo", id: :foo)) Graph.modify(graph, :foo, "bar") -> returns a graph Graph.delete(graph, :foo) Scenic.push_graph(graph)
primitive. • Matrix - hand specify a matrix. • Rotate - rotate around the pin. • Scale - scale larger or smaller. Centered around the pin. • Translate - move/translate horizontally and vertically. • Pin - set a pin to rotate or scale around.
another scene. You can build your own or use the built-in components: Button, Checkbox, Dropdown, RadioGroup, Slider, Textfield, Toggle Useful for reuse of UI elements across Scenes e.g Navigation, Menus etc
for use in another May be from a component (Button -> {:click, msg}) or custom from the app Handle by filter_event(event, context, state) Generate an event with send_event(scene, event) Input is data generated by drivers and sent to scenes. Limited set of input events e.g. :click, :value_changed Handled by a scene via handle_input(input, context, state)
If strength decreasing, turn. You are getting further away. If strength increasing, don't turn. Looks at delta in distance between updates. Behaviour results in the creatures spiraling inward
width and an offset from centre. If food within arc of an eye, see == true If only left, turn left. If only right, turn right. If both eyes see, don't turn. If neither, turn left.
modifies the graph Performance issues when making large numbers of modifications to the graph Separate logic and animation timers Embedding Scenic calls in creatures is memory intensive - perhaps send creature state to a dedicated module