Skip to content

A set of tools for speedometer-needle-like animations with javascript

License

Notifications You must be signed in to change notification settings

gbezyuk/needlex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Needlex

A set of tools for speedometer-needle-like animations with javascript Build Status

How to use

Needlex = require('Needlex');
Needlex.getAngle(50); // Math.PI/2
Needlex.getAngle(40, 120); // Math.PI/3

API

getAngle(value=0, max=100, min=0, oveflow=false, degrees=false)

Returns angle value (in radians or in degrees) for the value and meter limits provided. Both plain arguments and params object approaches allowed.

Examples:

Needlex.getAngle(); // 0
Needlex.getAngle(50); // Math.PI/2
Needlex.getAngle(40, 120); // Math.PI/3
Needlex.getAngle({val: 150, overflow: true, degrees: true}); // 270.0

See test/getAngle.js for more examples.

getCoordinates(angle=0, r=100, x0=100, y0=100, degrees=false)

Returns {x,y} coordinates for the angle, coordinates and measures provided. Both plain arguments and params object approaches allowed.

Examples:

Needlex.getCoordinates(0); // {x: 0, y: 100}
Needlex.getCoordinates(Math.PI); // {x: 200, y: 100}
Needlex.getCoordinates(Math.PI*.5); // {x: 100, y: 0}

See test/getCoordinates.js for more examples.

About

A set of tools for speedometer-needle-like animations with javascript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages