~jagtalon/generative-art-template

generative-art-template/index.html -rw-r--r-- 749 bytes
c37f3082Jag Talon Use /bin/sh instead of /bin/bash 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<html lang="en">
	<head>
		<style>
			html, body {
				width: 100%;
				height: 100%;
			}

			body {
				padding: 1em;
			}

			canvas {
				height: 100%;
				padding-bottom: .5em;
			}
		</style>
	</head>
	<body>
		<canvas width="3600" height="5400"></canvas>

		<div>
			<button>Save</button>
		</div>

		<script>
			let canvas = document.querySelector('canvas')
			let saveButton = document.querySelector('button')
			
			saveButton.onclick = function () {
				let link = document.createElement('a')
				link.setAttribute('download', 'Art.png')
				link.setAttribute('href', canvas.toDataURL().replace("image/png", "image/octet-stream"))
				link.click()
			} 
		</script>
		<script type="module" src="./build/art.js"></script>
	</body>
</html>