You may already know that you can apply a custom shape to a LiveCode stack using the windowShape property: import a bitmap image into your stack, such as a circle, diamond or ring, and set the windowShape of the stack to the id of the imported image. Presto: your stack assumes the shape of the image. But what you might not know is that you can animate the stack’s window shape using a sequence of images.
 
I posted an experimental stack that demonstrates a fun, if impractical, implementation of an animated window shape. To view the stack in LiveCode, copy the line below and execute it in your LiveCode message box.


 
The stack will launch with 4 visible “handles” — these act as drag regions for the stack since the stack is mostly transparent, thanks to the windowShape (image) assigned to the stack. Click the checkbox at the top of the stack to toggle the stack’s animation on and off. The checkbox’s looping script decrements a counter from 16 down to 1 and sets the windowShape of the stack to the id of each of 16 imported images, in sequence. The result is a stack literally changes its (visible) shape.
 
Notice that if you click inside the stack while the animation is running and you hit a transparent region, you will click through the stack and switch focus to the desktop. This is because any region that is not at least 1% opaque will not respond to mouse clicks.
 
Is this effect useful for anything? As shown in the demo stack, the effect is really just a novelty. But a practical use for a changing window shape could be a tool palette that expands and collapses to display extended options. Or a stack that morphs its shape to display a temporary process, such as downloading content, and then reverts back to its “normal” state.
 
This demo is just a basic example of an animated stack. There are possibilities yet to be explored…
 

(Visited 409 times, 1 visits today)
2