[ Launch: French Name Generator ] 5964714 by biovisualize
-
-
Save biovisualize/5964714 to your computer and use it in GitHub Desktop.
French Name Generator
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":"French Name Generator","endpoint":"","display":"div","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}},"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/tVxXiV6.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 start = ['peu', 'prou', 'fil', 'né', 'che', 'mir', 'tré', | |
'cor', 'fèri', 'mol', 'fente', 'chon', 'plume', 'mériè', | |
'mis', 'motte', 'saint-', 'bi', 'glu']; | |
var middle = ['an', 'fouin', 'fu', 'mer', 'tran', 'chon', 'né', | |
'nal', 'pan', '-en-', ' de ', 'mu', '-sur-', ' ', '-', | |
'os', 'flu', 'sou', 'poin', 'ral', 'cli', 'moule']; | |
var end = ['net', 'pou', 'fru', 'patte', 'potte', | |
'tru', 'dié', 'pel', 'let', 'bru', 'tulle', 'mine', | |
'ac', 'oy', 'foute', 'puy', 'bran', 'ière', '-les-bains', | |
'gnolles', 'diou', 'ouet', 'erie', 'flet', 'tandre', 'dieu', | |
'ouille', 'onde', 'el', 'aille']; | |
function rnd(d){ return d[~~(Math.random()*d.length)]; } | |
function rndRepeat(d){ | |
var n = ~~(Math.random()*3); | |
console.log(n); | |
return d3.range(n).map(function(){ | |
return d[~~(Math.random()*d.length)];}).join(''); | |
} | |
var display = d3.select('#display'); | |
display.append('button').text('generate') | |
.style({ | |
position: 'relative', | |
top: '10px' | |
}) | |
.on('click', generate); | |
var wordContainer = display.append('div') | |
.style({ | |
position: 'relative', | |
left: '10px', | |
top: '10px', | |
'text-transform': 'capitalize' | |
}); | |
generate(); | |
function generate(){ | |
var word = rnd(start)+''+rndRepeat(middle)+''+rnd(end); | |
wordContainer.html(word); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment