Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
230 lines (230 loc) · 7.72 KB
/
Copy pathindex.html
File metadata and controls
230 lines (230 loc) · 7.72 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!--
/*microCHSys
* index.html
*===================================================================
* Copyright (c) 2023-2025 Yuji SODE <yuji.sode@gmail.com>
*
* This software is released under the MIT License.
* See LICENSE or http://opensource.org/licenses/mit-license.php
*===================================================================
*
* this `index.html` is based on `threeCellContour [v1.0.1]/index.html` (Sode,2021-2022; the MIT License: http://opensource.org/licenses/mit-license.php)
*/
-->
<!DOCTYPE html><html lang='en'>
<head>
<meta charset='utf-8'>
<meta name='description' content="GUI for microCHSys, which is tool to extract contour from a image using micro Convex Hull System (microCHSys).">
<title>microCHSys</title>
<style type='text/css'>
canvas{
border:1px solid #000f;
position:absolute;
top:0vh;
left:0vw;
}
#formDiv{
position:fixed;
right:0;
top:5vh;
width:40vw;
resize:none;
overflow:scroll;
background:#ddd;
z-index:1000;
}
textarea{
width:35vw;
height:20vh;
resize:none;
overflow-y:scroll;
background:#000;
color:#fff;
}
.divRight{
right:0;
}
.divLeft{
left:0;
}
</style>
<script type='text/javascript' src='microCHSys.js'></script>
<!-- -->
</head>
<body>
<div>
<h1><img width=160 src='logoIMG/mCHSys_logo.png' alt='logo of microCHSys_10%'></h1>
<p>GUI for microCHSys, which is tool to extract contour from a image using micro Convex Hull System (microCHSys).</p>
</div>
<div id='formDiv' class='divRight'>
<div id='buttonsDiv'>
<!-- buttons to change form position -->
<button id='leftB' type='button'>Left</button>
<button id='rightB' type='button'>Right</button>
<br>
<button id='scanB' type='button'>Scan</button>
<button id='scanB_colored' type='button'>Scan_colored</button>
<!-- -->
<!-- download and comment -->
<button id='linkB' type='button'>Generate download link</button>
<button id='commentB' type='button'>Add comment</button>
</div>
<form id='control'>
<!-- source image and size of canvas -->
<fieldset id='CANVAS'>
<legend><b>Canvas</b></legend>
<ul>
<li><label>image file<input type='file' id='inputImg' accept='image/*'></label></li>
<p><b>Canvas size</b><br><code>2000 x 2000 is recommended as max canvas size.</code></p>
<li><label>width<input type='number' id='inputWidth' value=100 min=100 step=10 required></label></li>
<li><label>height<input type='number' id='inputHeight' value=100 min=100 step=10 required></label></li>
</ul>
<!-- size of source image -->
<p id='imgInfo'>Image size = <i>width</i> x <i>height</i> pixels</p>
</fieldset>
<!-- options -->
<fieldset id='options'>
<legend><b>Options</b></legend>
<details>
<summary>Details of options</summary>
<!-- standard value -->
<div><label>Standard value<input type='number' id='standardValue' value=0.05 min=0.00 max=1.00 step=0.01 required></label></div>
<!-- output color -->
<div><label>Color<input type='color' id='inputColor' value='#000' required></label></div>
</details>
</fieldset>
<!-- log -->
<fieldset id='textLog'>
<legend><b>Text log</b></legend>
<details>
<summary>Details of log</summary>
<textarea id='txtLog' readonly='readonly'></textarea>
<button id='selectB' type='button'>Select log</button>
</details>
</fieldset>
<p>Download link:<a id='downloadPNG' href='#' download='#' style='display:none;'></a></p>
</form>
</div>
<footer>
<p>Copyright (c) 2023-2025 Yuji SODE</p>
<a href='https://github.com/YujiSODE/microCHSys'>GitHub</a>
</footer>
<div style='position:relative;'><canvas id='microCHSysCvs' width=100 height=100></canvas></div>
<img id='imgForCvs' src='#' style='display:none;'>
<script type='text/javascript'>
(function(){
let slf=window,
C=slf.document.getElementById('microCHSysCvs'),
reader=new FileReader(),
log=slf.document.getElementById('txtLog'),
A=slf.document.getElementById('downloadPNG'),
fileName='',
/* === buttons === */
LeftB=slf.document.getElementById('leftB'),
RightB=slf.document.getElementById('rightB'),
/* ========================================== */
ScanB=slf.document.getElementById('scanB'),
ScanB_colored=slf.document.getElementById('scanB_colored'),
/* --- */
LinkB=slf.document.getElementById('linkB'),
CommentB=slf.document.getElementById('commentB'),
SelectB=slf.document.getElementById('selectB'),
/* === form inputs === */
img=slf.document.getElementById('inputImg'),
imgLength=0,
_IMG=slf.document.getElementById('imgForCvs'),
_IMGInfo=slf.document.getElementById('imgInfo'),
Width=slf.document.getElementById('inputWidth'),
Height=slf.document.getElementById('inputHeight'),
Std=slf.document.getElementById('standardValue'),
Color=slf.document.getElementById('inputColor');
//
//### file reader event ###
_IMG.addEventListener('load',()=>{
let ctx=C.getContext('2d');
ctx.drawImage(_IMG,0,0);
ctx=null;
_IMGInfo.textContent='Image\u0020size\u0020=\u0020'+_IMG.width+'\u0020x\u0020'+_IMG.height+'\u0020pixels';
},false);
reader.addEventListener('load',()=>{
C.width=Width.value;
C.height=Height.value;
_IMG.src=reader.result;
},false);
//
//### form change event ###
slf.document.getElementById('control').addEventListener('change',()=>{
imgLength=img.files.length;
if(imgLength>0){
reader.readAsDataURL(img.files[0]);
//
//it adds filename to log when loaded file is a new one
log.value+=fileName!==img.files[0].name?`${!log.value?'':'\n'}#---\n#${img.files[0].name}`:'';
fileName=img.files[0].name;
}else{
C.width=Width.value,C.height=Height.value;
}
},false);
//
//### button event ###
//
LeftB.addEventListener('click',()=>{
slf.document.getElementById('formDiv').className='divLeft';
},false);
//
RightB.addEventListener('click',()=>{
slf.document.getElementById('formDiv').className='divRight';
},false);
//
ScanB.addEventListener('click',()=>{
microCHSys.getContour('microCHSysCvs',Std.value);
//
//to add scan log
log.value+=`${!log.value?'':'\n'}time:${(new Date()).toJSON()},standard:${Std.value},color:${Color.value},target:${Width.value}x${Height.value},colored:none`;
},false);
//
ScanB_colored.addEventListener('click',()=>{
microCHSys.getContour('microCHSysCvs',Std.value,Color.value);
//
//to add scan log
log.value+=`${!log.value?'':'\n'}time:${(new Date()).toJSON()},standard:${Std.value},color:${Color.value},target:${Width.value}x${Height.value},colored:${Color.value}`;
},false);
//
//--- download and comment ---
LinkB.addEventListener('click',()=>{
let outputCvs=slf.document.getElementById('microCHSysCvs_OUTPUT'),url;
if(!!outputCvs){
//reset download link
A.href='#';
A.download='#';
A.style='display:none;';
//
url=async ()=>await outputCvs.toDataURL();
//
setTimeout(()=>{
//set download link
url().then((v)=>{
A.href=v;
}).then(()=>{
A.textContent=(new Date()).toTimeString();
A.download=`mCHSys_${(new Date()).getTime()}.png`;
A.style='display:inline;';
});
},2000);
}
},false);
//
CommentB.addEventListener('click',()=>{
let note=window.prompt('Add comment:');
log.value+=!note?'':`${!log.value?'':'\n'}#${note}`;
note=null;
},false);
//
SelectB.addEventListener('click',()=>{
log.focus();
log.select();
},false);
}());
</script>
</body>
</html>