GithubHelp home page GithubHelp logo

Comments (4)

Fuzzyma avatar Fuzzyma commented on June 13, 2024 1

I just realized that all you basically want is to disable affine transformation.
This is not possible via the scale api but you can just use transform directly:

poly.animate(1000).ease('<>')
        .transform({scale: -0.5, origin: [cx, cy]}, true, false)
        .loop(true, true, 1000)

https://jsfiddle.net/ykns86re/

This should unblock you

from svg.js.

VincentSinel avatar VincentSinel commented on June 13, 2024 1

Thanks for your quick reply, I don't think I will be able to help , I'm only a hobby programmer (without to much knowledge in JS) and use this library for my own website. But thank's a lot for your solution that just work great !

By the way this library is amazing !

from svg.js.

Fuzzyma avatar Fuzzyma commented on June 13, 2024

I debugged into this and the following is happening:

Since you use scale, an affine transformation is done.
Because of how the system works, the transformation is converted to a matrix which is later decomposed back into the affine transformations.
However, decomposition will always favor rotation over flipping and therefore the new affine transforms have a rotation instead of a negative scale.

But hey, why is it not rotating then?
Thats because at some point we set the rotation of the target transform back to its original value which is 0 because you bever specified a rotation. So it gets totally lost.

Whats left is the scale which is then animated.

So now to "how do we fix this?"
We probably need a check to make sure that decomposition has a flag that lets it favor flip instead of rotation.
We could check if the target transform contains any flip or negative scale and set the flag accordingly.

This needs more work and i am not sure if i have the time to fix this.
If you feel you can tackle this yourself, the code in question is in Runner.js

transform(transforms, relative, affine) {

The decomposition which would need a flag is in Matrix.js

decompose(cx = 0, cy = 0) {

from svg.js.

davelnewton avatar davelnewton commented on June 13, 2024

Wondering if this is related to using a negative scale value, e.g., -1 to flip x coordinates not rendering the SVG correctly--comes out as 1 instead of negative one.

from svg.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.