-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
141 lines (125 loc) · 4.04 KB
/
index.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Color Palette using WASM and K-Means</title>
<link rel="stylesheet" href="//cdn.rawgit.com/necolas/normalize.css/master/normalize.css">
<link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css">
<style>
canvas {
border: 1px solid black;
}
.colors {
display: flex;
flex-wrap: wrap;
}
.color-wrapper {
margin-right: 1em;
}
.color {
width: 200px;
height: 100px;
border: 1px solid black;
}
.color-wrapper span {
color: black;
display: flex;
justify-content: center;
}
.loader,
.loader:before,
.loader:after {
border-radius: 50%;
width: 2.5em;
height: 2.5em;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation: load7 1.8s infinite ease-in-out;
animation: load7 1.8s infinite ease-in-out;
}
.loader {
color: #9b4dca;
font-size: 10px;
margin: 80px auto;
position: relative;
text-indent: -9999em;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
}
.loader:before,
.loader:after {
content: '';
position: absolute;
top: 0;
}
.loader:before {
left: -3.5em;
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
.loader:after {
left: 3.5em;
}
@-webkit-keyframes load7 {
0%,
80%,
100% {
box-shadow: 0 2.5em 0 -1.3em;
}
40% {
box-shadow: 0 2.5em 0 0;
}
}
@keyframes load7 {
0%,
80%,
100% {
box-shadow: 0 2.5em 0 -1.3em;
}
40% {
box-shadow: 0 2.5em 0 0;
}
}
</style>
</head>
<body>
<div class="container">
<h1>Color Palette using WASM and K-Means</h1>
<p>Check out the code
<a href="https://github.com/novoselrok/color-palette-wasm">here</a>.</p>
<div id="app">
<div>
<label for="image-input"> Select an image:</label>
<input type="file" name="image-input" id="image-input" accept='image/*' :disabled="!moduleInitialized" @change="handleFileChange"
/>
<label for="numColors">Select number of colors:</label>
<select name="numColors" v-model="numColors">
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select>
</div>
<button @click="run" :disabled="!moduleInitialized || !imageLoaded">Run</button>
<div class="loader" v-if="running">Loading...</div>
<div v-else="" class="colors" @mouseleave="handleMouseLeaveColors">
<div class="color-wrapper" v-for="(color, index) in colors">
<div class="color" :style="{backgroundColor: getRgbaColor(color)}" @mouseover="() => handleMouseOverColor(index)"></div>
<span>{{getRgbaColor(color)}}</span>
</div>
</div>
<div>
<canvas id="canvas"></canvas>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="js/index.js"></script>
</body>
</html>