decompose an image into squares and then animate each part with a tween

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By patatra

Hye evetone,
Is it possible with a shader to decompose an image into several pieces and then animate them with tween?

Good day,

Animating with tween is not a valid idea, but perhaps You could animate it all using shader ? What Do You want to happen with partialized image ?

Inces | 2022-04-12 19:46

:bust_in_silhouette: Reply From: jgodfrey

I’m no shader expert, but I don’t think your request is possible - at least the animate them with a tween part. However, you could dynamically create a set of new images that are each some smaller portion of an original source image. Then, those new images could be assigned to some appropriate node (maybe a Sprite) which could then be animated via a tween.

The main thing you’d need is the ability to create a new image from a piece of an original image. That’s what the Image.blit_rect(...) function does.

So, you’d basically need to:

  • Loop over the original image and extract small pieces into new Image objects via blit_rect().
  • Assign each image to an appropriate node for animation (Sprite for instance)
  • Build a tween to animate the resulting nodes as necessary

Thank you, I will try. But you get lost pretty quickly with the concepts of Texture, Imagre, TextureImage.

patatra | 2022-04-13 08:20