Skip to content

Commit

Permalink
Merge pull request #1 from jonasb/master
Browse files Browse the repository at this point in the history
Tweak
  • Loading branch information
stg committed Oct 23, 2012
2 parents 57bb97d + d7a20d2 commit 3579219
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions voronoi.htm
Expand Up @@ -54,9 +54,9 @@
function render() {

// Fetch rendering parameters
var size_factor = 1.0 - (parseInt(document.getElementById("r_vertex").value) / 100);
var edge_factor = 1.0 - (parseInt(document.getElementById("r_bezier").value) / 100);
var join_factor = (parseInt(document.getElementById("r_reduce").value) / 100);
var size_factor = 1.0 - (parseIntOr(document.getElementById("r_vertex").value, 0) / 100);
var edge_factor = 1.0 - (parseIntOr(document.getElementById("r_bezier").value, 0) / 100);
var join_factor = (parseIntOr(document.getElementById("r_reduce").value, 0) / 100);

// Clear SVG
svgDocument.style.width = size_w;
Expand Down Expand Up @@ -273,16 +273,16 @@
}

function add_random() {
var count = parseInt(document.getElementById("randoms").value);
var count = parseIntOr(document.getElementById("randoms").value, 0);
for(var n = 0; n < count; n++) {
seeds[seeds.length] = {x:Math.random() * size_w, y:Math.random() * size_h};
}
}

function clear_all() {
seeds = new Array();
size_w = parseInt(document.getElementById("clear_w").value);
size_h = parseInt(document.getElementById("clear_h").value);
size_w = parseIntOr(document.getElementById("clear_w").value, 0);
size_h = parseIntOr(document.getElementById("clear_h").value, 0);
}

function save_svg() {
Expand All @@ -292,6 +292,11 @@
saveAs(blob, "document.svg");
}

function parseIntOr(v, def) {
v = parseInt(v);
return isNaN(v) ? def : v;
}

</script>
</head>
<body onload="init();" onkeydown="key_state(event);" onkeyup="key_state(event);" onmousemove="mouse_move(event);" onmousedown="mouse_click(event);" style="font-family:verdana;background:#e0e0e0;">
Expand All @@ -315,4 +320,4 @@
</td></tr></table>
</div>
</body>
</html>
</html>

0 comments on commit 3579219

Please sign in to comment.