Skip to content

Instantly share code, notes, and snippets.

@slapec
Created February 26, 2015 19:48
Show Gist options
  • Select an option

  • Save slapec/533f9a7fef8ad041a3fb to your computer and use it in GitHub Desktop.

Select an option

Save slapec/533f9a7fef8ad041a3fb to your computer and use it in GitHub Desktop.
Tech circle generator
<html>
<head>
</head>
<canvas id="c" width="800", height="600" style="display: none"></canvas>
<img id="kep">
<button id="f5">F5</button>
<script>
function newCircle(ctx){
ctx.beginPath();
ctx.lineWidth = Math.random()*20;
alpha = parseInt(Math.random()*2, 10) == 0 ? 0.1 : 1;
ctx.strokeStyle = 'rgba(1, 1, 1, '+alpha+')';
ctx.arc(w/2, h/2, Math.random()*100+30, Math.random()*Math.PI*2, Math.random()*Math.PI*2);
ctx.stroke();
}
var c = document.getElementById("c");
var h = c.height;
var w = c.width;
var ctx=c.getContext("2d");
for(i=15; i--;){
newCircle(ctx);
}
var kep = document.getElementById("kep");
png = c.toDataURL();
kep.src = png;
button = document.getElementById("f5");
button.onclick = function(){
ctx.clearRect(0, 0, w, h);
for(i=15; i--;){
newCircle(ctx);
}
png = c.toDataURL();
kep.src = png;
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment