[ Launch: pattern ] 4647186 by roundrobin
[ Launch: pattern ] 4647178 by roundrobin
[ Launch Inlet ]
Gist #4490867 [ Launch Inlet ]
Gist #4471204 [ Launch Inlet ]
Gist #4466334 [ Launch Inlet ]
Gist #2958639
-
-
Save roundrobin/4647186 to your computer and use it in GitHub Desktop.
pattern - magic eye
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":"pattern - magic eye","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}},"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,"tab":"edit","display_percent":0.6304687500000006,"hidepanel":false,"fullscreen":false,"thumbnail":"http://i.imgur.com/yaEbvXg.png"} |
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
function Path(canvas, path){ | |
this.dataPoints = []; | |
if(path != undefined){ | |
this.path = path; | |
} else { | |
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); | |
} | |
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 defs = d3.select('svg').append('defs') | |
var pattern = defs.append('pattern') | |
.attr('id','pattern1') | |
.attr('patternTransform','') | |
.attr('height',100) | |
.attr('width',100) | |
.attr('patternUnits','userSpaceOnUse') | |
var n = 3; | |
var cx = 200; | |
var cy = 200; | |
var opacity = 1; | |
var iterations = 3.84; | |
var stepSize = 1 / iterations * 2; | |
var toggle = 1; | |
for(var j = 0; j < iterations; j++){ | |
var path = new Path(pattern) | |
var strokeWidth = (toggle == 1 ? 6 : 4) | |
path.el() | |
.attr('fill','none') | |
.attr('stroke','#2A1C1C') | |
.attr('stroke-width',strokeWidth) | |
.attr('stroke-opacity', 1) | |
.attr("transform","translate("+[51,60]+")rotate("+30+")") | |
var r = -9 + (j * 38); | |
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; | |
path.render(); | |
} | |
d3.select('svg').append('rect') | |
.attr('height',tributary.sh) | |
.attr('width',tributary.sw) | |
.attr('fill','url(#pattern1)') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment