-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using MorhpSVG plugin without animation #118
Comments
When you do For that you can try and import any of the two morph components and try to "emulate" what KUTE.js does to create tween object SVGMorph.Util.getInterpolationPoints(path1, path2, precision) or SVGCubicMorph.Util.equalizeSegments(path1, path2). In the future I'm considering a merger of the two components but for now this is what we've got. |
equalizeSegments was exactly what i was looking for since i want the interpolation to be done by React Spring. I was hoping it was more useful for my case though. It still doesn't work if i morph from one path to the same path transformed by SVGPathCommander with optimization on. But what i really need it for that would be morphing from a path to another one composed of 2 times the first path half sized. Basically I would like to morph from one logo to 2 or 4 smaller logos but that's certainly some complicated graphics behaviour that I still need to study on. |
You can't optimize the result of equalizeSegments, you should only round them to 2-3 decimals. Optimization might remove segments and morph animation requires to have 2 paths of same amount of segments. |
Hoping to hijack this thread for what I believe is a similar use case. I'm pretty new to SVG manipulation, but have managed to make an in-browser visualizer project: https://collectionofatoms.github.io/sprialator/ I have implemented a smooth morphing between basic shapes using D3s morphing function, but am highly limited, as it doesn't look good morphing between shapes of different kinds of paths like circle-to-triangle, or shapes with different numbers of points. To achieve what I already have, I precompute all morphs between all possible shapes and then pick out the correct in-between shape during my morphing window. This all seems very similar to what Tween is doing. But I don't think I can use the Tween's animation functions play well with what I'm doing here. Or at the very least I don't understand them well :P If I can find a way to precompute morphs using KUTE, I think that I could use more complex shapes which would make it a lot more interesting to look at :) Is there a way to leverage KUTE to do this? How would I access the 'd' property of the intermediate SVG paths? Thank you for your time and attention. KUTE is an amazing library and morphing is a haaaaaaard problem! Very grateful you put this out there. |
If I'm understanding this right, you;re looking for intermediate values? Check this out |
Thanks for sending me that. I was looking at it, but it seemed like maybe it was still sending its own requestAnimationFrame() calls within it when the tween is playing. I ended up doing a pretty hacky workaround. I initialize tweens for every path that I use and then once right on page load, I manually update the tween with a value and then read the path off of the element like this. `function getMorphStepsFromTween(tween, numMorphSteps, tweenElementId, duration=1000){
}` It seems like that value that gets passed in needs to go well beyond the duration set in the fromTo() call, but also pretty sure this isn't intended to be used this way. I think I could probably do the same with a ProgressBar but honestly I'm pretty new to this stuff and don't understand what's going on. Thank you for your help. Do you have any advice for morphing very unlike paths? Loving using KUTE though it's really improved my visualizer. |
I'm working on a React Component animated Transform that uses SVGPathCommander under the hood:
transformPath is a wrapper for SVGPathCommander basic methods:
while getMorph is a function that uses React Spring to get the interpolated d attribute that gets the path to morph from what it was before the transform to what it was after.
It's working for simple transforms, but it won't work for complex paths that gets transformed too much (ofc it won't work with path optimisation as well). I was wondering if there's any way to still use React Spring for physics animations and SVGPathCommnader to make the transforms but have some sort of utility function from KUTE.js that prepare the before and after path string so that it animates correctly from one to the other.
And by the way thanks again to all the amazing work you did in the SVG field. It's really appreciated!
The text was updated successfully, but these errors were encountered: