Skip to content

Instantly share code, notes, and snippets.

@quentint
Created June 28, 2014 17:21
Show Gist options
  • Save quentint/6194d41c88d790df326f to your computer and use it in GitHub Desktop.
Save quentint/6194d41c88d790df326f to your computer and use it in GitHub Desktop.
Gros caca kilométrique
/**
* Gros caca kilométrique
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
<!-- content to be placed inside <body>…</body> -->
// Gros caca
var min=12, max=120;
var currentTotal=0;
var lines=[];
function kmToVal(km) {
return .491*km;
}
function addKm(km) {
currentTotal+=km;
lines.push({km:km, val:kmToVal(km)});
}
function grosCaca(total) {
console.log('—');
while (currentTotal<total) {
var currentVal=min+max*Math.random();
if (currentTotal+currentVal>total) {
addKm(total-currentTotal);
break;
}
addKm(currentVal);
}
}
grosCaca(450);
console.table(lines);
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"javascript"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment