so I sat down to find a good way to import pngs with transparence in pharo
and animate them and I ended up to this code

morph:= AlphaImageMorph new.
morph openInWorld .
form1 :=Form fromFileNamed:'/Users/kilon/Pictures/box.png'.
form2 :=Form fromFileNamed:'/Users/kilon/Pictures/box2.png'.
[(1 to: 100) do: [  :index|
morph image: form1 .
(Delay forMilliseconds: 2) wait.
morph image: form2 .
(Delay forMilliseconds: 2) wait.
]]fork.

gave me a basic animation then I did the proper thing and I created my own
class subclassing AlphaImageMorphing and used stepping every 40
milliseconds (25 fps) to create an animation of 2 frames , frame 1 is image
box.png and frame 2 is image box2.png.

Both images are 600x600 and contain transparency.

Now one morph is fine , seems to work ok and does not raise my cpu much.
However when I kept adding instances of the class I found out that after 3
the animation was considerably slow down, pharo also slow down with slow
response to my command , when I reached 6 instance I saw failed redrawing
of the moprh which was like it was cutting pieces out of the image for a
second or so and pharo interaction was quite slow.

The cpu one of the four cores were up to 50%. CPU consumption is not bad at
all , I compared with playing a youtube FULL HD video which was the same
resolution and it was consuming 30% of the cpu.

However I wonder if this the best way to do this. Its clear that there is
no way with my current solution I can fully animate a big pharo window that
is more than 1200x1200 without serious flickering and ideally I should not
animate more than 1000x1000 for smooth animation.

So is this all ? Are there any improvements I may apply ?

Would Athens be faster in this case ? I did not try because Athens is using
Morphic anyway so it should be same if not worse.

Reply via email to