-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_storage.html
75 lines (56 loc) · 1.52 KB
/
file_storage.html
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="taptapir/taptapir.css">
</head>
<body>
<div id="game">
<div id="loading_text">
loading...<br><br><br><br><br><br><br>
powered by taptapir
</div>
</div>
</body>
<script src="taptapir.js"></script>
<script>
</script>
<script type='text/sunsnake'>
var canvas = document.createElement("canvas");
document.body.appendChild(canvas)
canvas.width = 128;
canvas.height = 128;
var ctx = canvas.getContext("2d");
# localStorage.removeItem('saved_image')
var dataImage = localStorage.getItem('saved_image');
# helper = Entity(color="blue", scale=.3, y=.4)
# helper.texture = dataImage;
# bannerImg = document.getElementById('tableBanner');
var image = new Image();
image.id = "pic";
image.src = dataImage;
ctx.drawImage(image, 0, 0)
if not image:
ctx.fillStyle = "#000000";
ctx.fillRect(0, 0, 32, 32);
ctx.fillStyle = "#FF0000";
ctx.fillRect(5, 5, 10, 10);
# print('a')
opt_a = Button(text='a_', x=-.15)
opt_a.on_click = def():
ctx.fillStyle = "green"
ctx.fillRect(0,0,canvas.width,canvas.width)
save()
opt_b = Button(text='b_', x=.15)
opt_b.on_click = def():
ctx.fillStyle = "red"
ctx.fillRect(0,0,canvas.width,canvas.width)
save()
def save():
var dataURL = canvas.toDataURL("mycanvasimage");
window.localStorage.setItem("saved_image", dataURL);
console.log('yay!', dataURL)
print('done')
</script>
<script src="sunsnake_compiler.js"></script>
</html>