pharo-graphics / Bloc

Low-level UI infrastructure & framework for Pharo
MIT License
80 stars 40 forks source link

BlSequentialAnimation with delay stops too early #194

Open tinchodias opened 1 year ago

tinchodias commented 1 year ago

This is an infinite sequencial animation that composes 2 transform animations. The first one rotates 90º clockwise, the second comes back to 0º counter-clockwise. But pay attention to top-right corner:

https://user-images.githubusercontent.com/3044265/203199904-e860cb0d-28a5-4b8b-b873-0a7807d7e10c.mov

This is reproducible, but the angles vary. This is canvas independent.

Code:

aDuration := 0.5 seconds.
size := 200.

element :=
    BlElement new
        relocate: size @ 0;
        size: size asPoint ;
        background: Color green;
        yourself.

cwAnimation := BlTransformAnimation new
    transformDo: [ :aBuilder |
        aBuilder
            topLeftOrigin;
            rotateBy: 90 ];
    absolute;
    delay: aDuration * 2;
    duration: aDuration;
    yourself.
ccwAnimation := BlTransformAnimation new
    transformDo: [ :aBuilder |
        aBuilder
            topLeftOrigin;
            rotateBy: 0 ];
    absolute;
    delay: aDuration * 2;
    duration: aDuration;
    yourself.

element addAnimation: (BlSequentialAnimation new 
    add: cwAnimation;
    add: ccwAnimation)
    beInfinite;
    yourself.

space := BlSpace new.
space root background: Color black.
space addChild: element.
space extent: 2*size asPoint.
space show.
tinchodias commented 1 year ago

The issue's title is an hypothesis from the fact that rotation to 0º works when I add more steps to the sequence of animations (a blink):

https://user-images.githubusercontent.com/3044265/203201381-a3f71666-e459-4df8-b67c-1ad0bce1409b.mov

Code:

aDuration := 0.5 seconds.
size := 200.

element :=
    BlElement new
        relocate: size @ 0;
        size: size asPoint ;
        background: Color orange;
        yourself.

cwAnimation := BlTransformAnimation new
    transformDo: [ :aBuilder |
        aBuilder
            topLeftOrigin;
            rotateBy: 90 ];
    absolute;
    delay: aDuration * 2;
    duration: aDuration;
    yourself.
ccwAnimation := BlTransformAnimation new
    transformDo: [ :aBuilder |
        aBuilder
            topLeftOrigin;
            rotateBy: 0 ];
    absolute;
    delay: aDuration * 2;
    duration: aDuration;
    yourself.

element addAnimation: (BlSequentialAnimation new 
    add: cwAnimation;
    add: ccwAnimation;
    add: (BlOpacityAnimation new opacity: 0; duration: aDuration; yourself);
    add: (BlOpacityAnimation new opacity: 1; duration: aDuration; yourself);
    beInfinite;
    yourself).

space := BlSpace new.
space root background: Color black.
space addChild: element.
space extent: 2*size asPoint.
space show.
tinchodias commented 1 year ago

Something similar to this issue has been observed when cards disapear using a parallel animation in the tutorials card game.

Animation created in MGCardElement>>#onDisappear

@Ducasse