ComponentsWithWick.wick (57.9 KB)
The main interest of the attached animation is to show a way to create reusable and configurable Wick components.
Using the animation
The purpose was to illustrate the basic functioning of business organizations, from customer order to goods delivery.
To run it, click on PLAY ALL, wait that the various warehouses start getting filled, PLAY ALL again to trigger the next flows, until the whole chain can play.
Each flow can be started and stopped individually.
Component-based design
The animation defines and uses 3 components:
- The Container Component models a warehouse (or any tank, or anything that can be filled in and emptied). It has;
** one property: .$defaultColor
** several custom methods:
- $fill()
- $clear()
- $addToContent(quantity)
- $setContent(ratio)
- $getContent()
In addition,
-
project.$initContainer(contClip, defaultColor = “DarkGreen”, defaultContent = 0) initializes Containers components.
-
The Flow component will empty some containers, and fill some others.
Here are its properties and methods:
- Properties
$sourcesList // List of source Containers, and quantities to substract;
$targetsList // List of target Containers, and quantities to add; - Methods
$areSourcesOK // Checks sources Containers not empty
$areTargetsOK // Checks target Containers not full
$okToStart // Source and target Containers both ok
$updateContainersContent // Adds or substract quantities to Containers if okToStart.
$setColor // Color of flow, unless is an image
In addition,
-
project.$initFlow(flowClip, sourcesList, targetsList, color = “DarkGrey”) initializes Flow Components.
-
The ON/OFF component starts and stops a given flow.
How to setup the layers
The code defining each component is in a specific layer, prefixed by Code.
There are dependencies, so the order of layers must be respected.
The last layer, CodeConfiguration, contains the code that is specific to this animation: it initializes and configures all components instances used by this animation.
Using the components in a new animation
To use the components in a new animation, copy anyone of them in the animation layer, and give it a meaningful name.
In addition, each CodeXXX layer, except the last one, CodeConfiguration, should be copied and left unchanged.
The CodeConfiguration layer has to be present as well, but its content is specific to each animation. Its purpose is to initialize each animation components using the project.$initXXX() functions.