GithubHelp home page GithubHelp logo

hhy5277 / shapeshifter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexjlockwood/shapeshifter

0.0 2.0 0.0 5.89 MB

SVG path morphing animation editor

Home Page: https://alexjlockwood.github.io/ShapeShifter/

License: Apache License 2.0

TypeScript 85.73% JavaScript 0.64% HTML 5.64% CSS 7.98%

shapeshifter's Introduction

Shape Shifter

Build Status

Go to Live Version


Shape Shifter is a web-app that simplifies the process of creating SVG-based path morphing animations.

This tool currently exports to AnimatedVectorDrawable format for Android. That said, I am totally open to adding support for other export formats as well. File a feature request!

Screen capture of tool

Problem

Writing high-quality path morphing animations is a tedious and time-consuming task. In order to morph one shape into another, the SVG paths describing the two must be compatible with each other—that is, they need to have the same number and type of drawing commands. This is problematic because:

  • Design tools—such as Sketch and Illustrator—do not easily expose the order of points in a shape, making it difficult to change their order. As a result, engineers will often have to spend time tweaking the raw SVG path strings given to them by designers before they can be morphed, which can take a significant amount of time.
  • Design tools often map to shape primitives not supported in certain platforms (e.g. circles need to be represented by a sequence of curves and/or arcs, not simply by their center point and radius).
  • Design tools cannot place multiple path points in the same location, a technique that is often necessary when making two shapes compatible with each other.
  • Design tools provide no easy way to visualize the in-between states of the desired path morph animation.

Features

To address these problems, Shape Shifter provides the following features:

  • The ability to add/remove points to each path without altering their original appearance. The added points can be modified by dragging them to different positions along the path, and they can be later deleted using the keyboard as well.
  • The ability to reverse/shift the relative positions of each path's points. While reordering points won't affect whether or not two paths are compatible, it often plays a huge role in determining the appearance of the resulting animation.
  • Shape Shifter automatically converts incompatible pairs of SVG commands into a compatible format. There's no longer any need to convert Ls into Qs and As into Cs by hand in order to make your paths compatible—Shape Shifter does this for you behind-the-scenes!
  • Shape Shifter provides a useful utility called 'auto fix', which takes two incompatible paths and attempts to make them compatible in an optimal way. Depending on the complexity of the paths, auto fix may or may not generate a satisfying final result, so further modification may be necessary in order to achieve the animation you're looking for.
  • The ability to export the results to AnimatedVectorDrawable format for use in Android applications. I'm open to adding support for other export formats as well, so feel free to file a feature request!

How does it work?

Pretty much all of the graphics in this app are powered by bezier curve approximations under-the-hood. I learned most of what I needed to know from this excellent primer on bezier curves (especially sections 9 and 33, which explain how to split and project points onto bezier curves without altering their original appearance). Most of the interesting SVG-related code is located under src/app/scripts/commands.

Auto fix is powered by an adaptation of the Needleman-Wunsch algorithm, which is used in bioinformatics to align protein or nucleotide sequences. Instead of aligning DNA base-pairs, Shape Shifter aligns the individual SVG commands that make up each path instead. You can view the current implementation of the algorithm in the AutoAwesome.ts file.

Bug reports & feature requests

Let me know if you encounter any issues with the app (attach SVG files and/or screenshots if you can). Before you do, take a look at the list of known issues here and leave a comment on the existing bugs you want to see fixed in a future release!

I am open to pretty much any feature request, so don't be afraid to ask! I'll likely work on the most popular feature requests first. I'm especially curious how I can make this web app more useful for iOS and web developers.

Build instructions

If you want to contribute, you can build and serve the web app locally as follows:

  1. First install Node.js and npm.

  2. Install the Angular client with:

```
npm install -g @angular/cli
```
  1. Clone the repository and in the root directory, run:
```
npm install
```
  1. To build and serve the web app locally, run:
```
ng serve
```

Special thanks

Huge thanks to Nick Butcher and Roman Nurik for all of their help during the early stages of this project!

shapeshifter's People

Contributors

alexjlockwood avatar angular-cli avatar

Watchers

 avatar  avatar

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.