Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created February 6, 2013 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roundrobin/4721079 to your computer and use it in GitHub Desktop.
Save roundrobin/4721079 to your computer and use it in GitHub Desktop.
SVG Path - spring
{"description":"SVG Path - spring","endpoint":"","display":"svg","public":true,"require":[{"name":"Helpers","url":"https://raw.github.com/roundrobin/svg-path-generator/master/svg-path-generator.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"fullscreen":false,"thumbnail":"http://i.imgur.com/qxlvidb.png"}
var svg = d3.select("svg");
//Uses the svg-path-generator class
//https://github.com/roundrobin/svg-path-generator
var path = new Path(svg)
path.add(['m',200,100]);
var a = 0;
var b = 0;
Math.abs(a) // the absolute value of a
Math.acos(a) // arc cosine of a
Math.asin(a) // arc sine of a
Math.atan(a) // arc tangent of a
Math.atan2(a,b) // arc tangent of a/b
Math.ceil(a) // integer closest to a and not less than a
Math.cos(a) // cosine of a
Math.exp(a) // exponent of a (Math.E to the power a)
Math.floor(a) // integer closest to a, not greater than a
Math.log(a) // log of a base e
Math.max(a,b) // the maximum of a and b
Math.min(a,b) // the minimum of a and b
Math.pow(a,b) // a to the power b
Math.random() // pseudorandom number 0 to 1 (see examples)
Math.round(a) // integer closest to a (see rounding examples)
Math.sin(a) // sine of a
Math.sqrt(a) // square root of a
Math.tan(a) // tangent of a
var l = 14;
var x,y;
for(var i=0; i < 9;i++){
x = Math.abs(i)*l;
y = 10*Math.sin(i/0.00000000001)*l;
path.add(['l',x,y]);
}
path.render();
path.showPoints()
path.hidePoints()
path.scale(3)
console.log(path.el().node().pathSegList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment