• Stars
    star
    114
  • Rank 301,884 (Top 7 %)
  • Language
    JavaScript
  • Created almost 13 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A progress indicator in HTML5 canvas

ProgressCircle.js

A progress indicator in HTML5 canvas

homepage: http://qiao.github.com/ProgressCircle.js/

Usage

Download the file and include it in your page.

<script type="text/javascript" src="ProgressCircle.js"></script>

You should first create the canvas element in either HTML or Javascript, and specify its width and height.

<canvas id="my_canvas" width="100" height="40"></canvas>

Note: you should NOT specify the size of the canvas in CSS.

Then proceed with codes like the following ones.

var myCanvas = document.getElementById('my_canvas');

var circle = new ProgressCircle({
    canvas: myCanvas,
});

circle.addEntry({
    fillColor: 'rgba(255, 255, 0, 0.5)',
    progressListener: function() {
        return THE_PROGRESS_VARIABLE_TO_LISTEN; // between 0 and 1
    },
});

You can add multiple progress indicators:

circle.addEntry({
    fillColor: 'rgba(102, 255, 0, 0.5)',
    progressListener: function() {return p1;},
}).addEntry({
    fillColor: 'rgba(255, 255, 0, 0.5)',
    progressListener: function() {return p2;},
}).addEntry({
    fillColor: 'rgba(0, 0, 255, 0.5)',
    progressListener: function() {return p3;},
});

The call start to start the animation.

circle.start(33); // 33 is the interval(ms) between each update

If you want to stop the animation, call the stop method.

circle.stop();

Optional Parameters

var circle = new ProgressCircle({
    canvas: myCanvas, 
    minRadius: 10, // Inner radius of the innermost circle
    arcWidth: 3, // Width of each circle
    gapWidth: 2, // Space between adjacent circles
    centerX: 20, // X coordinate of the circle center
    centerY: 20, // Y coordinate of the circle center
    infoLineLength: 200, // Length of the info line
    horizLineLength: 50, // Length of the horizontal info line
    infoLineBaseAngle: Math.PI / 6, // Start angle of the info line
    infoLineAngleInterval: Math.PI / 8, // Angle between info lines
});

circle.addEntry({
    fillColor: 'rgba(255, 255, 0, 0.5)',
    outlineColor: 'rgba(255, 255, 255, 0.5)' // (Optional)
    progressListener: function() {return p1;},
    infoListener: function() {return text1;},// (Optional)
});

License

MIT License

Β© 2011-2013 Xueqiao Xu <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

PathFinding.js

A comprehensive path-finding library for grid based games
JavaScript
8,327
star
2

euphony

MIDI visualizer in WebGL
JavaScript
846
star
3

difflib.js

Text diff library in JavaScript, ported from Python's difflib module.
CoffeeScript
245
star
4

sicp-solutions

My solutions to Structure and Interpretation of Computer Programs
Scheme
240
star
5

fractal-terrain-generator

A random fractal terrain generator in JavaScript
JavaScript
214
star
6

ces.js

Component-Entity-System framework for JavaScript games.
JavaScript
185
star
7

heap.js

A binary heap implementation in CoffeeScript/JavaScript.
CoffeeScript
123
star
8

coffee-box

A blog engine built upon Node.js, Express, MongoDB and CoffeeScript.
JavaScript
71
star
9

fingertree.js

Implementation of Finger Tree in JavaScript.
JavaScript
45
star
10

visual.js

JavaScript 3D library for dummies
JavaScript
33
star
11

mdwatch

Preview markdown document with live updates
JavaScript
25
star
12

vimfiles

My vim plugins and configuration
Vim Script
23
star
13

javascript-playground

A collection of my toy codes when I just started to learn javascript.
JavaScript
21
star
14

r7rs.js

R7RS compliant Scheme implementation in JavaScript (Work in Progress)
JavaScript
18
star
15

immutable-sequence.js

High performance implementation of Immutable Sequence in JavaScript, based on Finger Tree.
JavaScript
16
star
16

typedef.me

My blog at http://typedef.me in Ruby on Rails. (Deprecated)
Ruby
9
star
17

GR-JSON-Reader

Reader for exported Google Reader JSON files
Python
6
star
18

clando

A command-line todo list manager for minimalists
Common Lisp
2
star
19

scroll-progress

A small chrome extension showing the scroll progress of current page.
JavaScript
2
star