Giter VIP home page Giter VIP logo

svgpainterunity's Introduction

SVG Line Painter for Unity

Screenshot

It works like a js version of SVG line animation like "LazyLinePainter" which you can find js library link in below. https://github.com/camoconnell/lazy-line-painter

Also SVG part of code is a port of https://github.com/colinmeinke/svg-points/blob/master/src/toPoints.js

Preparing your SVG data
Create your Line art in your vector editor of choice

  • Ensure there are no fills.
  • No closed paths. i.e - Line needs a start and end.
  • No compound path. If you have compound paths, you need to release.
  • Crop Artboard nice & tight!
  • If you draw simple circle, you need to add anchor point. Othewise library will not draw circle. Export as .SVG (Default export options are fine)
    Convert SVG file to text file. e.g - You can rename like "test.svg.txt".

Screenshot
Screenshot

SetUp

Copy Assets/SVGPainterUnity directory to your Assets directory.
Add a SVGPainter component to a GameObject.
Add your SVG text file to Resources/ directory.

Screenshot

Example Code

Screenshot

Here is how to animate.

var svgPainter = GetComponent<SVGPainter> ();
svgPainter.Init ("test.svg");
svgPainter.Play (3f, PainterEasing.EaseInOutCubic);

If you want to rewind animation, here it is.

svgPainter.Play (3f, PainterEasing.EaseInOutCubic, () => {
	svgPainter.Rewind (3f, PainterEasing.EaseInOutCubic);
});

Setup line width and color.

svgPainter.Init ("test.svg",0.002f,new Color (1f, 1f, 1f));

Canvas Example Code

var svgPainter = GetComponent<SVGPainter> ();
svgPainter.InitCanvas ("test.svg");
svgPainter.Play (3f, PainterEasing.EaseInOutCubic);

Setup line width and color.

svgPainter.InitCanvas ("test.svg",1f,new Color (1f, 1f, 1f));

Compatibility

SVGLinePainter is only tested on MacOS with OpenGLCore and not sure about another platform.

License

MIT

svgpainterunity's People

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.