Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created February 15, 2013 21:11
Show Gist options
  • Save roundrobin/4963577 to your computer and use it in GitHub Desktop.
Save roundrobin/4963577 to your computer and use it in GitHub Desktop.
Normal Distribution
{"description":"Normal Distribution","endpoint":"","display":"svg","public":true,"require":[],"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}},"fullscreen":false,"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,"thumbnail":"http://i.imgur.com/ihXyhVG.png"}
Math.nrand = function() {
var x1, x2, rad;
do {
x1 = 2 * this.random() - 1;
x2 = 2 * this.random() - 1;
rad = x1 * x1 + x2 * x2;
} while(rad >= 1 || rad == 0);
var c = this.sqrt(-2 * Math.log(rad) / rad);
return x1 * c;
};
var offetX = 570;
var m = 150;
for(var i=0;i < 21;i++){
g.append("circle")
.attr({
r: 16,
cx: Math.nrand()*m+ offetX,
cy: 300,
fill: "#FF00FF",
opacity: 0.2
});
}
for(var i=0;i < 21;i++){
g.append("circle")
.attr({
r: 16,
cx: Math.random()*m+ offetX,
cy: 300,
fill: "#00FF0A",
opacity: 0.2
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment