Jump to content
Search Community

Position value accuracy svg

Baret test
Moderator Tag

Recommended Posts

Hi
By using TweenMax with the _gsTransform.x instruction I get a precision of at least 6 digits after the 
comma but by using gsap.getProperty ("# id", "x") I only have 4 digits after the comma . 
How can I get better accuracy with gsap.getProperty?

 

Jean-Michel

Link to comment
Share on other sites

We intentionally round values to avoid various other problems that can occur, and to improve performance. Can you help me understand WHY you would need more precision? 

 

If you really need to, you could use a proxy, sort of like this: 

var proxy = {factor: 1000,
       realX: 0,
       x: function(value) {
         if (!arguments.length) {
           return proxy.realX * proxy.factor;
         }
         proxy.realX = value / proxy.factor;
       }
    };

gsap.to(proxy, {x: 100 * proxy.factor, duration: 10, onUpdate: () => console.log("realX:", proxy.realX)});

It's very unusual that you'd need more than 4 decimal places. Again, I'm curious about what drove your question. 

  • Like 1
Link to comment
Share on other sites

Hello,

Thank you for your response and I am responding to yours.

I designed a vernier caliper and I created a vernier drag to help learn how to read the measure (see attached Capture.png).

One of the important points in reading is to identify the two graduations which are opposite and which I wish to display in red (see attached Capture4.png).

For this I added a snap function whose value corresponds to the offset to have successive alignments.

In this case the value of the snap is 1.984375 (see attached Capture5.png).

To display the two graduations in red I make the correspondence between the position of the vernier and the graduations opposite.

This value is therefore a multiple of 1.984375 .

Have I been clear ?

Do not hesitate to ask me for more information

Capture.PNG

Capture4.PNG

Capture5.PNG

 

image.png

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...