Search code examples
smalltalksqueakpharomorphicmarching-ants

HowTo make a marching ants border in Morphic?


I am looking for a marching ants border or line in Morphic:

Marching Ants sample

Wikipedia describes a possbile algorithm:

The easiest way to achieve this animation is by drawing the selection using a pen pattern that contains diagonal lines. If the selection outline is only one pixel thick, the slices out of the pattern will then look like a dashed line, and the animation can easily be achieved by simply shifting the pattern one pixel sideways and redrawing the outline.

As there is probably none readymade, has anybody a hint for me how to create such a border or line?

(The marching ants pattern as a GIF animation is licensed under CC by Uli Kusterer)


Solution

  • Actually, Morphic does have it:

    (PolygonMorph
        vertices: Rectangle fromUser corners
        color: Color transparent
        borderWidth: 2
        borderColor: Color black)
                dashedBorder: {10. 10. Color white. 0. 1};
                openInHand
    

    Since this is polygon-based it can not only be a rectangle but any shape.