Git Product home page Git Product logo

Comments (13)

veltman avatar veltman commented on June 20, 2024 1

@alexjlockwood it currently just merges into the first neighbor by arc order so it's rather arbitrary (but deterministic). I did experiment with some alternative merging strategies but didn't see any real improvement in the look of the results. I may try to modify the triangulation to produce more regular triangles, since the current approach produces a lot of very long skinny ones (#1).

from flubber.

dalisoft avatar dalisoft commented on June 20, 2024

@alexjlockwood I have too multi-shape handling (published, then removed repo), i split paths, tweening each and combine while tweening.

from flubber.

alexjlockwood avatar alexjlockwood commented on June 20, 2024

Just wondering... how do you determine where to split the paths?

from flubber.

dalisoft avatar dalisoft commented on June 20, 2024

Split by moveto command. But flubber does same thing plus triangulation matches where to split. I tried implement flubber way, works with full flubber library, but slower

from flubber.

alexjlockwood avatar alexjlockwood commented on June 20, 2024

ah-ha! triangulation sounds super useful. in fact, I think I may have found a demo you wrote in the past that might explain it. https://bl.ocks.org/veltman/218a162265c772f86bc26c1bc91fe58b

thanks for the tip, i'm definitely going to explore this further. :)

from flubber.

dalisoft avatar dalisoft commented on June 20, 2024

@alexjlockwood I looked to your code, looks amazing, but i never understand Angular (learned React, Vue, etc...) but not understand Angular. Is you have basic/es6 js version?

from flubber.

veltman avatar veltman commented on June 20, 2024

The general approach is as follows, to morph a shape into N shapes:

  1. Triangulate the polygon using earcut.
  2. Put those triangles into a TopoJSON topology.
  3. Merge the smallest triangle into one of its neighbors.
  4. Repeat step 3 until only N shapes are left.

from flubber.

dalisoft avatar dalisoft commented on June 20, 2024

@veltman I've using your app (requires flubber.min.js for minimal size) to improve visually morphing, but very slow comparing to my tools (visually best is your). And earcut+topojson very high size. Maybe there we reduce size, improve performance together?

from flubber.

veltman avatar veltman commented on June 20, 2024

Oops, submitted too early.

  1. Match the resulting pieces with the destination shapes by finding the permutation that minimizes the distance between the centroid of each piece and the centroid of its destination shape. (Flubber skips this optimization if there are too many shapes, it would take forever otherwise)
  2. Morph each pair.

from flubber.

dalisoft avatar dalisoft commented on June 20, 2024

@veltman Triangulation is bit slow and has some cons, it creates unexcepted line as you see in some case

from flubber.

alexjlockwood avatar alexjlockwood commented on June 20, 2024

@veltman For step 3:

Merge the smallest triangle into one of its neighbors.

How do you determine which neighbor to merge with? My best guess is that you would pick the neighbor with the smallest total area?

I am also wondering if flubber does any special handling for shapes that contain holes?

from flubber.

alexjlockwood avatar alexjlockwood commented on June 20, 2024

@dalisoft Most of the math for ShapeShifter is contained in these two directories:

https://github.com/alexjlockwood/ShapeShifter/blob/master/src/app/scripts/algorithms/AutoAwesome.ts (Needleman-Wunsch algorithm for aligning SVGs)

https://github.com/alexjlockwood/ShapeShifter/tree/master/src/app/model/paths (a bunch of Path-related math for splitting/reversing/shifting/winding/etc. SVG paths)

from flubber.

dalisoft avatar dalisoft commented on June 20, 2024

@veltman I try your solution triangulation but slow, also i am tried to decurve my points and then after triangulation recurve, not works. Can you have solution curves? Without getPointAtLength solution, because it is slower

from flubber.

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.