2.9 KiB
2.9 KiB
Hints
General
- Read about behaviours in the official Getting Started guide.
- Read about behaviours on elixirschool.com.
- Read about behaviours in the documentation.
- Read about
usein the official Getting Started guide. - Read about
usein the documentation.
1. Define the animation behaviour
- Use the
@callbackmodule attribute to define the desired functions. - Each callback must specify the function name, list of arguments (their types) and the return value (its type).
- Use the given custom types
dot,opts,error, andframe_numberin the callbacks' definitions. - Refresh your knowledge of typespecs to help with defining callbacks.
2. Provide a default implementation of the init/1 callback
- Define a
__using__/1macro in theDancingDots.Animationmodule. - The macros' argument can be ignored.
- The macro must return a quoted expression.
- In the quoted expression, use
@behaviourso that callinguse DancingDots.AnimationsetsDancingDots.Animationas the using module's behaviour. - In the quoted expression, implement the
init/1function. - The default implementation of the
init/1function should wrap the givenoptsargument in:oktuple. - There is a macro that can mark a function as overridable.
3. Implement the Flicker animation
- Make use of
DancingDots.Animation__using__/1macro by calling this one special macro in theDancingDots.Flickermodule. - You do not need to implement the
init/1function. Its default implementation is enough. - You need to implement the
handle_frame/3function. - To detect "every 4th frame", you can check if the remainder when dividing it by 4 is equal to 0.
4. Implement the Zoom animation
- Make use of
DancingDots.Animation__using__/1macro by calling this one special macro in theDancingDots.Zoommodule. - You need to implement both the
init/1function and thehandle_frame/3function. - Use the
Keywordmodule to work with the options keyword list. - There is a built-in guard for checking if a value is a number.