Giter VIP home page Giter VIP logo

arctween.js's Introduction

ArcTween.js

A simple widget that turns a canvas into a Arc vizualizer.

  • Arc.js is a "static" version without any dependencies

  • ArcTween.js is the animated version, using TweenLite to handle animation stuff.

See the examples on this page

Usage - Static version

  1. Include Arc.js in your HTML page.

     <script src="Arc.js"></script>
    
  2. Add a canvas

     <canvas id="arc1" width="120" height="120"></canvas>
    
  3. Create an Arc

     var canvas = document.getElementById("arc1");
     var startValue = 0.1;
     var arc1 = new Arc( canvas, startValue );
    

You can later change the arc value using the setValue method. The value should be normalized, so keep it between 0 and 1.

	arc1.setValue(.73);

Usage - Animated

  1. Include TweenLite.js and ArcTween.js in your HTML page.

     <script src="TweenLite.min.js"></script>
     <script src="ArcTween.js"></script>
    
  2. Create a canvas in your page. Try to make a square one, or the outcome might be erratic :)

     <canvas id="arc1" width="120" height="120"></canvas>
    
  3. Now, you can create arcs. Feed them with the reference to your canvas, and a value to display. The value should be normalized, so keep it between 0 and 1.

     var canvas = document.getElementById("arc1");
     var startValue = 0.1;
     var arc1 = new Arc( canvas, startValue );
    
  4. Animate the arc to suit your needs, using the tween method

     var newValue = 0.85; // normalized value, between 0 and 1
     var animationTime = 1; // in seconds
     var animationDelay = 0; // in seconds too
     arc1.tween( value, animationTime, animationDelay );
    

That's it.

Reference

  • new Arc( canvas, value ) : constructor

Methods

  • setValue( value ) : stores the value, and calls draw()
  • draw() : redraws the arc
  • tween( value, animationTime, animationDelay ) : animate the arc to a given value (Tween version only)

Properties

There are several properties that can allow a better control of your Arc, but you have to be aware that you can break things while having fun.

  • strokeColor
  • strokeBgColor
  • value
  • radius
  • strokeWidth

Browser support

It should run on every browser supporting the <canvas> element, so you're fine.

Credits

Created by @boblemarin in Namur (be).

arctween.js's People

Contributors

boblemarin avatar

Stargazers

 avatar Gonçalo Dias da Silva avatar Michael Anthony avatar Nikos M. avatar Mark Coleman avatar

Watchers

 avatar James Cloos avatar Michael Anthony 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.