Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created January 9, 2013 07:22
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/4491303 to your computer and use it in GitHub Desktop.
Save roundrobin/4491303 to your computer and use it in GitHub Desktop.
pattern
{"description":"pattern","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.6304687500000006,"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}
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(){
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 n = 4;
var cx = 200;
var cy = 200;
var opacity = 1;
var iterations = 7;
var stepSize = 1 / iterations * 2;
var toggle = 1;
for(var j = 0; j < iterations; j++){
var path = new Path(svg)
var strokeWidth = (toggle == 1 ? 15 : 220)
path.el()
.attr("transform","translate("+[376,262]+")rotate("+(0)+")")
.attr('fill','none')
.attr('stroke','#566D96')
.attr('stroke-width',strokeWidth)
.attr('stroke-opacity', 0.5)
var r = 36 + (j * 20);
path.add(['M',r,0]);
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']);
console.log(toggle);
toggle *= -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment