Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created February 7, 2013 22:40
Show Gist options
  • Save roundrobin/4734875 to your computer and use it in GitHub Desktop.
Save roundrobin/4734875 to your computer and use it in GitHub Desktop.
Multiple font

[ Launch: Pattern grid - raster ] 4734875 by roundrobin
[ Launch: Pattern grid - 2 ] 4659021 by roundrobin
[ Launch: Pattern grid - stripes ] 4657513 by roundrobin
[ Launch: Pattern grid - wave ] 4647105 by roundrobin
[ Launch: Pattern grid - elector ] 4647086 by roundrobin
[ Launch: Pattern grid - elector ] 4647080 by roundrobin
[ Launch: Pattern grid - 50-50 circles ] 4647076 by roundrobin
[ Launch: Pattern grid - double quater circles ] 4647019 by roundrobin
[ Launch: Pattern grid - double quater circles ] 4646988 by roundrobin
[ Launch: Pattern grid - quater circles ] 4646984 by roundrobin
[ Launch: Pattern grid - 70ies circles ] 4646978 by roundrobin
[ Launch: Pattern grid - cross ] 4646975 by roundrobin
[ Launch: Pattern grid - hash ] 4646958 by roundrobin
[ Launch: Pattern grid - hash ] 4646953 by roundrobin
[ Launch: Tributary inlet ] 4646912 by roundrobin

{"description":"Multiple font","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},"test.svg":{"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,"fullscreen":false,"thumbnail":"http://i.imgur.com/7E7tBuD.png"}
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 pattern_size = 5;
var strokeSize = 1.5;
var defs = d3.select('svg').append('defs')
var pattern = defs.append('pattern')
.attr('id','pattern1')
.attr('patternTransform','')
.attr('height',pattern_size)
.attr('width',pattern_size)
.attr('patternUnits','userSpaceOnUse')
var attr = {
'fill':'none',
'stroke':'#73A5A5',
'stroke-width':strokeSize,
}
var path = new Path(pattern)
path.add(['M', 0,pattern_size/2]);
path.add(['L',pattern_size/2,pattern_size]);
path.add(['M', pattern_size/2,0]);
path.add(['L',pattern_size,pattern_size/2]);
path.el().attr(attr).style('stroke-linecap','square');
path.render();
path.render();
g.append('text')
.text("Lorem Ipsum")
.attr({
fill: "url(#pattern1)",
x : 0,
y: 148,
"font-size": 98,
"font-family": "Arial",
"text-anchor": "start"
});
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment