Enkrypton
Enkrypton

Reputation: 49

JavaFX: ScaleTransition, Scale down

How do I scale down an image using ScaleTransition? I have this right now and it only scales up. I not if I'm misunderstanding the method, but I have it scaling From 1 to 0.8. For some reason this still scales up.

ScaleTransition st = new ScaleTransition(Duration.millis(900), iv2);
        st.setFromX(1);
        st.setFromY(1);
        st.setByX(0.8);
        st.setByY(0.8);
        st.play();

If I reverse the values like so, it shows up small but snaps bigger and scales up again.

ScaleTransition st = new ScaleTransition(Duration.millis(900), iv2);
        st.setFromX(0.8);
        st.setFromY(0.8);
        st.setByX(1);
        st.setByY(1);
        st.play();

Is there a way I can just get the ScaleTransition to scale down?

Upvotes: 0

Views: 2242

Answers (1)

yyater97
yyater97

Reputation: 2983

ScaleTransition st = new ScaleTransition(Duration.millis(900), iv2);
        st.setFromX(1);
        st.setFromY(1);
        st.setToX(0.8);
        st.setToY(0.8);
        st.play();

This can scale down, the size of component scale from 100% down to 80%, you can scale up with this code, change 0.8 to a number bigger than 1, sorry my English so bad

Upvotes: 1

Related Questions