Skip to main content
Participating Frequently
Jul 5, 2022 7:29 AM UTC
Question

Snap position and scale to round numbers

Hi all,
I'm trying to create a jsfl scirpt that changes the element by:

1. Rounding the scaleX and scaleY to a number with 2 decimal places (i.e. integer percent)

2. Rounding the position x and y to a integer number (i.e. snap to pixel)

 

I've tried round/ceil/floor/toFixed, but everytime I end up with a float number similar to .9978.

I'm aware by the JS limitations when working with float numbers, but everything is OK when trying to set up the values manually from the Animate's UI.

Does anyone know a proper solution for doing this through script?

 

Thank you very much.

    This topic is closed to new replies. Start a new post to keep the conversation going.

    2 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    Jul 5, 2022 11:02 AM UTC

    Hi.

     

    This is actually a bug that has been happening in recent years. The Animate team has already been made aware of the issue, but so far no solution has been given.

     

    You can let them know about this problem via this link:

    https://www.adobe.com/products/wishform.html

     

    Regards,

    JC

    Translate
    Participating Frequently
    Jul 5, 2022 2:04 PM UTC

    Hi, thank you very much!

    Translate