Shape Drawing

The following program example demonstrates how various shapes can be drawn by a behavior, without the behavior knowing the specific types of shapes, essentially polymorphism.

The Object-Oriented equivalent found herearrow-up-right was the inspiration for this example.

`Declare the contexts of the application.`

App State: context
{
    Should Draw: Bool [true];
}.

Draw Plane: context { `Data defining a plane that can be drawn to.` }.

Drawable: contract
{
    X: Int;
    Y: Int;
    Height: Int [1];
    Width: Int [1];
}

Shape [Drawable]: context
{
    X: Int;
    Y: Int;
    Height: Int [1];
    Width: Int [1];
}.

Circle [Drawable]: context Shape.
Rectangle [Drawable]: context Shape.
Triangle [Drawable]: context Shape.

Last updated