Skip to content

Instantly share code, notes, and snippets.

@georules
Last active August 29, 2015 14:24
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 georules/e4529ae9288919b0f080 to your computer and use it in GitHub Desktop.
Save georules/e4529ae9288919b0f080 to your computer and use it in GitHub Desktop.
fontthing
{"description":"fontthing","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.7,"thumbnail":"http://i.imgur.com/Z4ghHZY.png","fullscreen":false,"ajax-caching":true,"inline-console":false}
var svg = d3.select("svg")
model = {}
model.s = "CODESLAM"
data = s.split("")
console.log(data)
fontsize=50
var fonts = ['Arial','Arial Black','Bookman Old Style','Century Gothic','Comic Sans','Consolas','Courier','Georgia','Helvetica','Impact','Lucida','Cambria','Tahoma','Trebuchet','Verdana','Monotype Corsiva','Monotype Sorts']
svg.selectAll("text").data(data).enter().append("text")
.attr({
x: 200,
y: 184,
'font-size':fontsize,
fill: "#000000"
}).text(function(d,i){
flip=Math.floor(Math.random()*2)
return d.toLowerCase()
return flip ? d.toUpperCase() : d.toLowerCase()
});
var picked = []
d3.selectAll("text")
.attr("x", function(d,i) {
return i * fontsize * 0.66
})
.attr("font-family", function(d,i) {
i = Math.floor(Math.random()*fonts.length)
if (picked.indexOf(i)>0) {
i = Math.floor(Math.random()*fonts.length)
}
// picked.append(i)
console.log(i)
return fonts[i]
})
Object.observe(model, function(changes) {
console.log(changes)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment