[ Launch: Triangle Pattern ] 4749241 by roundrobin
[ Launch: PathLib & Pattern ] 4749218 by roundrobin
[ Launch: Variable Stroke width ] 4735469 by roundrobin
[ Launch: SVG Path Test 1 ] 4721138 by roundrobin
[ Launch: SVG Path Element ] 4721053 by roundrobin
[ Launch: Bootstrap Trib ] 4711978 by roundrobin
[ Launch: Tributary inlet ] 4711690 by roundrobin
-
-
Save roundrobin/4749241 to your computer and use it in GitHub Desktop.
Triangle Pattern
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":"Triangle Pattern","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}},"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/mZoOsyS.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
var svg = d3.select("svg"); | |
var pattern_size = 218; | |
var defs = d3.select('svg').append('defs') | |
var pattern = defs.append('pattern') | |
.attr('id','pattern1') | |
.attr('pattermTransform','') | |
.attr('height',pattern_size) | |
.attr('width',pattern_size) | |
.attr('patternUnits','userSpaceOnUse') | |
function r(min, max) { | |
return Math.random() * (max - min) + min; | |
} | |
var size = 15; | |
var trianleSize = pattern_size/size; | |
var x=0,y=0; | |
for(var i=0; i < size;i++){ | |
for(var j=0; j < size;j++){ | |
var path = new Path(pattern) | |
path.el().attr | |
({'stroke-width':0, | |
'fill':'#'+Math.floor(Math.random()*(670530)*Math.PI).toString(16), | |
opacity: r(1,1)}) | |
var xPos = trianleSize * j; | |
path.add(['M',xPos,y]); | |
path.add(['L',xPos+trianleSize,y+trianleSize]); | |
path.add(['H',x]); | |
path.add(['Z']); | |
path.render(); | |
path.hidePoints() | |
var path = new Path(pattern) | |
path.el().attr | |
({'stroke-width':0, | |
'fill':'#'+Math.floor(Math.random()*(670530)*Math.PI).toString(16), | |
opacity: r(1,1)}) | |
var xPos = trianleSize * j; | |
path.add(['M', xPos,y]); | |
path.add(['H', xPos+trianleSize]); | |
path.add(['L', xPos+trianleSize,y+trianleSize]); | |
path.add(['Z']); | |
path.render(); | |
path.hidePoints(); | |
x+=trianleSize; | |
} | |
x = 0; | |
y+=trianleSize; | |
} | |
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