Browse Source

add redraw button

master
Fr3deric 5 years ago
parent
commit
b70188ae2f
  1. 12
      baumgen.html
  2. 3
      baumgen.js

12
baumgen.html

@ -12,10 +12,13 @@ @@ -12,10 +12,13 @@
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
console.log('ready');
var el = document.getElementById('download-svg');
console.log(el);
el.addEventListener('click', function() {
draw();
document.getElementById('redraw').addEventListener('click', function() {
draw();
});
document.getElementById('download-svg').addEventListener('click', function() {
var svgdata = 'data:image/svg+xml;utf8,' + encodeURIComponent(paper.project.exportSVG({asString: true}));
var a = document.createElement('a');
a.download = 'baumgen.svg';
@ -28,6 +31,7 @@ document.addEventListener('DOMContentLoaded', function() { @@ -28,6 +31,7 @@ document.addEventListener('DOMContentLoaded', function() {
</head>
<body>
<button id="redraw">redraw</button>
<button id="download-svg">download svg</button>
<canvas id="canvas" resize></canvas>
</body>

3
baumgen.js

@ -223,7 +223,7 @@ class Branch { @@ -223,7 +223,7 @@ class Branch {
}
window.onload = function() {
function draw() {
var canvas = document.getElementById('canvas');
paper.setup(canvas);
@ -234,5 +234,4 @@ window.onload = function() { @@ -234,5 +234,4 @@ window.onload = function() {
var br = new Branch(gen_tree(new Point(50 + x*80, 150 + y*160)));
}
}
}

Loading…
Cancel
Save