-
-
Save roundrobin/4471204 to your computer and use it in GitHub Desktop.
path generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"path generator","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}},"tab":"edit","display_percent":0.5773437499999999,"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,"hidepanel":false} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var start = Date.now() | |
, n = 2 //number of rings | |
, radius = 232 //radius interval | |
, deg = 472 //angle (in degrees) we will split | |
, width = 48 //width of each box | |
, t = 415 //"time' | |
, a = 1 | |
, ntheta = 0.31104 | |
, speed_factor = 0 | |
, opacity = 0.364 | |
, stroke_opacity = 0.14 | |
, stroke_width = 3 | |
, fill_color = "#C55F5F" | |
, stroke_colors = ["#505499", "#313464"] | |
, corners = -7; | |
function Path(canvas){ | |
this.dataPoints = []; | |
this.path = canvas.append('svg:path') | |
.attr("stroke","black") | |
.attr("stroke-width",3) | |
.attr("fill","none") | |
} | |
Path.prototype.el = function(wayPoint){ | |
return this.path; | |
} | |
Path.prototype.add = function(wayPoint){ | |
this.dataPoints.push(wayPoint); | |
this.render(); | |
} | |
Path.prototype.render = function(){ | |
this.path.attr("d",this.pathWay()); | |
} | |
Path.prototype.pathWay = function(){ | |
console.log('Hello') | |
var way = ''; | |
for(var i=0;i < this.dataPoints.length;i++){ | |
var elem = this.dataPoints[i]; | |
way += elem.join(' '); | |
} | |
return way; | |
} | |
var colors = [ | |
'#0900E2' | |
, '#4881A3' | |
, '#5AC505' | |
, '#253FA5' | |
] | |
var k, color_scale; | |
//interpolate over multiple colors | |
var sw = tributary.sw; | |
//make the sin waves extend past the width a little | |
sw += .1 * sw | |
var sh = tributary.sh | |
var svg = d3.select("svg") | |
svg.append("rect") | |
.attr("width", sw) | |
.attr("height", sh) | |
.attr("fill", "#F1F1F1") | |
var path = new Path(svg) | |
path.el() | |
.attr("transform","translate("+[302,307]+")") | |
.attr('fill','#20708A') | |
.attr('stroke','#2E5A83') | |
.attr('stroke-width',29) | |
var r = 146; | |
path.add(['M',r,0]); | |
var cx = 200; | |
var cy = 200; | |
var n = 8; | |
for(var i = 0; i < n;i++){ | |
var cx = r * Math.cos(2 * Math.PI * i / n); | |
var cy = r * Math.sin(2 * Math.PI * i / n); | |
path.add(['L',cx,cy]) | |
} | |
path.add(['z']); | |
var path = new Path(svg) | |
path.el() | |
.attr("transform","translate("+[302,307]+")") | |
.attr('fill','#2DBDA6') | |
.attr('stroke','#FFE6FF') | |
.attr('stroke-width',8) | |
var r = r - (r/4); | |
path.add(['M',r,0]); | |
var cx = 200; | |
var cy = 200; | |
var n = 8; | |
for(var i = 0; i < n;i++){ | |
var cx = r * Math.cos(2 * Math.PI * i / n); | |
var cy = r * Math.sin(2 * Math.PI * i / n); | |
path.add(['L',cx,cy]) | |
} | |
path.add(['z']); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment