forked from situx/SemanticDictionary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
showcase.html
525 lines (517 loc) · 22.3 KB
/
showcase.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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
<html>
<head>
<script src="https://barionleg.github.io/hongru/proj/canvas2image/canvas2image.js"></script>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="js/tablesorter.js"></script>
<script src="js/canvas2svg.js"></script>
<script>
function to_image(){
var canvas = document.getElementById("myCanvas");
document.getElementById("canvasImg").src = canvas.toDataURL();
Canvas2Image.saveAsSVG(canvas);
document.getElementById("canvasImg").style.visibility = 'hidden';
}
var curposx=30;
var curposy=30;
var strokelength=30;
var wedgelength=10;
var multiplier=1.5;
var smallermultiplier=0.5
var rotmultiplier=5;
var smaller=false;
var mirror=false;
var halfangle=false;
var rot=0;
//var canvasSVGContext = new CanvasSVG.Deferred();
//canvasSVGContext.wrapCanvas(document.getElementById("myCanvas"));
function strokeParser(input){
clearCanvas(true);
smaller=false;
mirror=false;
halfangle=false;
curposx=10;
curposy=10;
for (var i = 0; i < input.length; i++) {
switch(input.charAt(i)){
case "a":
drawVerticalLine(curposx,curposy,"myCanvas",true,false);
rot=0;
break;
case "A":
drawVerticalLine(curposx,curposy,"myCanvas",true,true);
rot=0;
break;
case "b":
drawHorizontalLine(curposx,curposy,"myCanvas",true,false);
rot=0;
break;
case "B":
drawHorizontalLine(curposx,curposy,"myCanvas",true,true);
rot=0;
break;
case "c":
drawDiagonalLine1(curposx,curposy,"myCanvas",false);
rot=0;
break;
case "C":
drawDiagonalLine1(curposx,curposy,"myCanvas",true);
rot=0;
break;
case "d":
drawDiagonalLine2(curposx,curposy,"myCanvas",false);
rot=0;
break;
case "D":
drawDiagonalLine2(curposx,curposy,"myCanvas",true);
rot=0;
break;
case "e":
drawDiagonalLine3(curposx,curposy,"myCanvas",false);
rot=0;
break;
case "E":
drawDiagonalLine3(curposx,curposy,"myCanvas",true);
rot=0;
break;
case "f":
drawDiagonalLine4(curposx,curposy,"myCanvas",false);
rot=0;
break;
case "F":
drawDiagonalLine4(curposx,curposy,"myCanvas",true);
rot=0;
break;
case "s":
smaller=true;
break;
case "w":
drawWedge2(curposx,curposy,"myCanvas",false);
rot=0;
break;
case "W":
drawWedge2(curposx,curposy,"myCanvas",true);
rot=0;
break;
case "w2":
drawWedge(curposx,curposy,"myCanvas");
rot=0;
break;
case "-":
curposx+=10;
curposy=10;
break;
case "#":
curposx+=5;
curposy=10;
break;
case ":": curposy+=7;
break;
case "!": //mirror character
mirror=true;
break;
case "'": curposy=10;
break;
case "\"": curposy=0;
break;
case "~": curposx-=10;
curposy=10;
break;
case "/": curposy+=3.5;
break;
case "|": halfangle=true;
break;
case ";": curposy+=strokelength;
break;
case ".": curposy+=7;
curposx+=7;
break;
case "<":
rot--;
break;
case ">":
rot++;
break;
case "\\": curposy+=7;
curposx-=7;
break;
case ",": curposy-=7;
curposx-=7;
break;
case "_": curposx+=strokelength;
curposy=10;
break;
case " ": curposx+=1.5*strokelength;
break;
default:
}
//console.log(input.charAt(i));
}
}
function drawVerticalLine(start,starty,canvas,strokeparse,big){
if(strokeparse==false)
curposx+=10
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
if(big){
length=multiplier*strokelength;
if(mirror){
ctx.moveTo(start-5, starty+10+length); // start at top left corner of canvas
ctx.lineTo(start+5, starty+10+length); // go 200px to right (x), straight line from 0 to 0
ctx.lineTo(start, starty+length); // go to horizontal 100 (x) and vertical 200 (y)
}else{
ctx.moveTo(start-5, starty+10); // start at top left corner of canvas
ctx.lineTo(start+5, starty+10); // go 200px to right (x), straight line from 0 to 0
ctx.lineTo(start, starty+20); // go to horizontal 100 (x) and vertical 200 (y)
}
ctx.fill();
}else if(smaller){
length=0.5*strokelength;
smaller=false;
if(mirror){
ctx.moveTo(start-5, starty+5+length); // start at top left corner of canvas
ctx.lineTo(start+5, starty+5+length); // go 200px to right (x), straight line from 0 to 0
ctx.lineTo(start, starty+length); // go to horizontal 100 (x) and vertical 200 (y)
}else{
ctx.moveTo(start-5, starty+15); // start at top left corner of canvas
ctx.lineTo(start+5, starty+15); // go 200px to right (x), straight line from 0 to 0
ctx.lineTo(start, starty+20); // go to horizontal 100 (x) and vertical 200 (y)
}
ctx.fill();
}else{
length=strokelength;
if(mirror){
ctx.moveTo(start-5, starty+10+length); // start at top left corner of canvas
ctx.lineTo(start+5, starty+10+length); // go 200px to right (x), straight line from 0 to 0
ctx.lineTo(start, starty+length); // go to horizontal 100 (x) and vertical 200 (y)
}else{
ctx.moveTo(start-5, starty+10); // start at top left corner of canvas
ctx.lineTo(start+5, starty+10); // go 200px to right (x), straight line from 0 to 0
ctx.lineTo(start, starty+20); // go to horizontal 100 (x) and vertical 200 (y)
}
ctx.fill();
}
if(mirror){
ctx.moveTo(start,starty);
ctx.lineTo(start,starty+length);
ctx.stroke();
mirror=false;
}else{
ctx.moveTo(start,starty+20);
ctx.lineTo(start,starty+20+length);
ctx.stroke();
}
}
function drawHorizontalLine(start,starty,canvas,strokeparse,big){
if(strokeparse==false)
curposy+=10
//alert(rot+" - "+start+" - "+starty)
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
if(big){
length=multiplier*strokelength;
if(mirror){
ctx.moveTo(start+10+length, starty+15); // pick up "pen," reposition at 300 (horiz), 0 (vert)
ctx.lineTo(start+10+length, starty+25); // draw straight down (from 300,0) to 200px
ctx.lineTo(start+length, starty+20); // draw up toward right (100 half of 200)
}else{
ctx.moveTo(start-10, starty+15); // pick up "pen," reposition at 300 (horiz), 0 (vert)
ctx.lineTo(start-10, starty+25); // draw straight down (from 300,0) to 200px
ctx.lineTo(start, starty+20); // draw up toward right (100 half of 200)
}
ctx.fill(); // connect and fill
}else if(smaller){
length=smallermultiplier*strokelength;
smaller=false;
if(mirror){
ctx.moveTo(start+5+length, starty+15); // pick up "pen," reposition at 300 (horiz), 0 (vert)
ctx.lineTo(start+5+length, starty+25); // draw straight down (from 300,0) to 200px
ctx.lineTo(start+length, starty+20); // draw up toward right (100 half of 200)
}else{
ctx.moveTo(start-5, starty+15); // pick up "pen," reposition at 300 (horiz), 0 (vert)
ctx.lineTo(start-5, starty+25); // draw straight down (from 300,0) to 200px
ctx.lineTo(start, starty+20); // draw up toward right (100 half of 200)
}
ctx.fill(); // connect and fill
}else{
length=strokelength;
if(mirror){
ctx.moveTo(start+10+length, starty+15); // pick up "pen," reposition at 300 (horiz), 0 (vert)
ctx.lineTo(start+10+length, starty+25); // draw straight down (from 300,0) to 200px
ctx.lineTo(start+length, starty+20); // draw up toward right (100 half of 200)
}else{
if(rot>0){
start2=Math.cos(rot)*length+10;
starty2=Math.sin(rot)*length+10;
ctx.moveTo(start+start2-10, starty+starty2+15); // pick up "pen," reposition at 300 (horiz), 0 (vert)
ctx.lineTo(start+start2-10, starty+starty2+25); // draw straight down (from 300,0) to 200px
ctx.lineTo(start+start2, starty+starty2+20); // draw up toward right (100 half of 200)
}else{
ctx.moveTo(start-10, starty+15); // pick up "pen," reposition at 300 (horiz), 0 (vert)
ctx.lineTo(start-10, starty+25); // draw straight down (from 300,0) to 200px
ctx.lineTo(start, starty+20); // draw up toward right (100 half of 200)
}
}
ctx.fill(); // connect and fill
}
if(mirror){
ctx.moveTo(start+length,starty+20);
ctx.lineTo(start,starty+20);
ctx.stroke();
mirror=false;
}else if(rot>0){
console.log(rot)
start2=Math.cos(Math.PI/2+rot)*length;
starty2=Math.sin(Math.PI/2+rot)*length;
ctx.moveTo(start+start2,starty+20);
ctx.lineTo(start+length,starty+starty2+20);
ctx.stroke();
}else{
ctx.moveTo(start,starty+20);
ctx.lineTo(start+length,starty+20);
ctx.stroke();
}
}
function drawDiagonalLine1(start,starty,canvas,big){
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
if(big){
wlength=wedgelength
if(halfangle)
length=0.6*length
length=multiplier*strokelength;
ctx.moveTo(start+wlength-10, starty+wlength-10);
ctx.lineTo(start+wlength-10, starty-10);
ctx.lineTo(start-10, starty+wlength-10);
ctx.fill(); // connect and fill
}else if(smaller){
length=smallermultiplier*strokelength;
wlength=wedgelength-5
ctx.moveTo(start+wlength-5, starty+wlength-5);
ctx.lineTo(start+wlength-5, starty-5);
ctx.lineTo(start-5, starty+wlength-5);
ctx.fill(); // connect and fill
smaller=false;
}else{
length=strokelength;
wlength=wedgelength
ctx.moveTo(start, starty);
ctx.lineTo(start-wedgelength, starty);
ctx.lineTo(start, starty-wedgelength);
ctx.fill(); // connect and fill
}
ctx.moveTo(start,starty);
if(halfangle){
ctx.lineTo(start+length,starty+0.6*length);
}else{
ctx.lineTo(start+length,starty+length);
}
ctx.stroke();
}
function drawDiagonalLine2(start,starty,canvas,big){
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
if(big){
length=multiplier*strokelength;
if(halfangle)
length=0.6*length
ctx.moveTo(start, starty+length);
ctx.lineTo(start, starty+length+10);
ctx.lineTo(start-10, starty+length);
ctx.fill(); // connect and fill
}else if(smaller){
length=smallermultiplier*strokelength;
if(halfangle)
length=0.6*length
ctx.moveTo(start, starty+length);
ctx.lineTo(start, starty+length+5);
ctx.lineTo(start-5, starty+length);
ctx.fill(); // connect and fill
smaller=false;
}else{
length=strokelength;
if(halfangle)
length=0.6*length
ctx.moveTo(start, starty+length);
ctx.lineTo(start, starty+length+10);
ctx.lineTo(start-10, starty+length);
ctx.fill(); // connect and fill
}
ctx.moveTo(start+length,starty);
ctx.lineTo(start,starty+length);
ctx.stroke();
}
function drawDiagonalLine3(start,starty,canvas,big){
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
if(big){
length=multiplier*strokelength;
ctx.moveTo(start+length,starty+length);
ctx.lineTo(start+length+wedgelength, starty+length);
ctx.lineTo(start+length, starty+length+wedgelength);
ctx.fill();
}else if(smaller){
length=smallermultiplier*strokelength;
ctx.moveTo(start+length,starty+length);
ctx.lineTo(start+length+wedgelength-5, starty+length);
ctx.lineTo(start+length, starty+length+wedgelength-5);
ctx.fill();
smaller=false;
}else{
length=strokelength;
ctx.moveTo(start+length,starty+length);
ctx.lineTo(start+length+wedgelength, starty+length);
ctx.lineTo(start+length, starty+length+wedgelength);
ctx.fill();
}
ctx.moveTo(start,starty);
ctx.lineTo(start+length,starty+length);
ctx.stroke();
}
function drawDiagonalLine4(start,starty,canvas,big){
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
if(big){
length=multiplier*strokelength;
ctx.moveTo(start+length,starty);
ctx.lineTo(start+length, starty-wedgelength);
ctx.lineTo(start+length+wedgelength, starty);
ctx.fill();
}else if(smaller){
length=smallermultiplier*strokelength;
ctx.moveTo(start+length,starty);
ctx.lineTo(start+length, starty-wedgelength+5);
ctx.lineTo(start+length+wedgelength-5, starty);
ctx.fill();
smaller=false;
}else{
length=strokelength;
ctx.moveTo(start+length,starty);
ctx.lineTo(start+length, starty-wedgelength);
ctx.lineTo(start+length+wedgelength, starty);
ctx.fill();
}
ctx.moveTo(start+length,starty);
ctx.lineTo(start,starty+length);
ctx.stroke();
}
function clearCanvas(strokeParser){
var c=document.getElementById("myCanvas");
c.width = c.width;
if(!strokeParser)
document.getElementById('canvasinput').value=""
}
function drawWedge(start,starty,canvas){
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.moveTo(start-10, starty+15); // pick up "pen," reposition at 300 (horiz), 0 (vert)
ctx.lineTo(start-10, starty+25); // draw straight down (from 300,0) to 200px
ctx.lineTo(start, starty+20); // draw up toward right (100 half of 200)
ctx.fill(); // connect and fill
}
function drawWedge2(start,starty,canvas,big){
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
if(big){
ctx.moveTo(start+10, starty+15); // pick up "pen," reposition at 300 (horiz), 200 (vert)
ctx.lineTo(start+10, starty+30); // draw straight down by 200px (200 + 200)
ctx.lineTo(start, starty+25); // draw up toward left (100 less than 300, so left)
ctx.fill(); // connect and fill
}else{
ctx.moveTo(start+10, starty+15); // pick up "pen," reposition at 300 (horiz), 200 (vert)
ctx.lineTo(start+10, starty+25); // draw straight down by 200px (200 + 200)
ctx.lineTo(start, starty+20); // draw up toward left (100 less than 300, so left)
ctx.fill(); // connect and fill
}
}
function showCharacter(character){
strokeParser(character)
document.getElementById('canvasinput').value=character
}
</script>
<style>
.table-wrapper-scroll-y {
display: block;
max-height: 500px;
max-width: 100%;
overflow-y: visible;
overflow-x: scrool;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
</style>
</head>
<body>
<p> at higher image enlage height of canvas at row 451</p>
<table><tr><td valign="top">
<canvas id="myCanvas" width="500" height="200" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<img id="canvasImg"/>
<br/>
Stroke Order Input: <input type="text" id="canvasinput" onKeyUp="strokeParser(document.getElementById('canvasinput').value)"/><button id="clearcanvas" onClick="clearCanvas(false)">Clear Canvas</button><button id="downloadImage" onClick="to_image()">Download Image</button><br/>
<br/>
Tutorial:
<ul>
<li><b>a</b> <button id="vertical" onClick="showCharacter('a')">Vertical Stroke (a)</button><button id="D" onClick="showCharacter('A')">Big (A)</button>
<button id="sa" onClick="showCharacter('sa')">Small (sa)</button></li>
<li><b>b</b> <button id="horizontal" onClick="showCharacter('b')">Horizontal Stroke (b)</button>
<button id="D" onClick="showCharacter('B')">Big (B)</button><button id="sb" onClick="showCharacter('sb')">Small (sb)</button></li>
<li><b>c</b> <button id="diagonal1" onClick="showCharacter('c')">Diagonal Stroke1 (c)</button>
<button id="C" onClick="showCharacter('C')">Big (C)</button><button id="sc" onClick="showCharacter('sc')">Small (sc)</button></li>
<li><b>d</b> <button id="diagonal2" onClick="showCharacter('d')">Diagonal Stroke2 (d)</button>
<button id="D" onClick="showCharacter('D')">Big (D)</button><button id="sd" onClick="showCharacter('sd')">Small (sd)</button></li>
<li><b>e</b> <button id="diagonal3" onClick="showCharacter('e')">Diagonal Stroke3 (e)</button>
<button id="E" onClick="showCharacter('E')">Big (E)</button><button id="se" onClick="showCharacter('se')">Small (se)</button></li>
<li><b>f</b> <button id="diagonal4" onClick="showCharacter('f')">Diagonal Stroke4 (f)</button>
<button id="F" onClick="showCharacter('F')">Big (F)</button><button id="sf" onClick="showCharacter('sf')">Small (sf)</button></li>
<li><b>w</b> <button id="wedge" onClick="showCharacter('w')">Winkelhaken (w)</button><button id="F" onClick="showCharacter('W')">Big (W)</button></li><li><b>-</b> right of the current stroke passing through other strokes</li>
<li><b>_</b> right of the current stroke NOT passing through other strokes</li>
<li><b>:</b> under the current stroke passing through other strokes</li>
<li><b>;</b> under the current stroke NOT passing through other strokes</li>
<li><b>/</b> half the distance of <b>:</b> under the current stroke passing through other strokes </li>
<li><b>.</b> diagonal right under the current stroke</li>
<li><b>,</b> diagonal left above the current stroke</li>
<li><b>s</b> smaller version of the stroke (e.g. sb, sc)</li>
<li><b>!</b> mirrored version of the stroke (e.g. !a, !A, !sa)</li>
<li><b>Whitespace</b> Enough distance to start a new character</li>
</ul>
</td><td>
<span id="amount"></span>
<div class="table-wrapper-scroll-y">
<table align="center" id="examples" class="tablesorter">
<thead>
<tr><th>Sign</th><th>Code point</th><th>Transliteration</th><th>Borger</th><th>Comment</th><th>Code</th></tr><tr>
</thead><tbody>
<tr><td>𒁇</td><td>U+12047</td><td>BAR</td><td>121</td><td></td><td><button onClick="showCharacter('a;b')">a;b</a></td></tr>
<tr><td>𒇲</td><td>U+121F2</td><td>LAL</td><td>750</td><td></td><td><button onClick="showCharacter('a-b')">a-b</a></td></tr>
<tr><td>𒈨</td><td>U+12228</td><td>ME</td><td>753</td><td></td><td><button onClick="showCharacter('a-:b')">a-:b</a></td></tr>
<tr><td>𒆜</td><td>U+1219C</td><td>KASKAL</td><td>302</td><td></td><td><button onClick="showCharacter('::c\'d-::d\'c')">::c'd-::d'c</a></td></tr>
<tr><td>𒊐</td><td>U+12290</td><td>RAB</td><td>262</td><td></td><td><button onClick="showCharacter('::b:b-sb:sb:sb_/b::/b-/sb::sa-/sb')">::b:b-sb:sb:sb_/b::/b-/sb::sa-/sb</a></td></tr>
</tbody></table>
Beispiel E:
<table align="center" id="examples" class="tablesorter">
<thead>
<tr><th>Sign</th><th>Code point</th><th>Transliteration</th><th>Borger</th><th>Comment</th><th>Code</th></tr><tr>
</thead><tbody>
<tr><td>𒂊</td><td>U+1208A</td><td>E</td><td>498</td><td>HT246</td><td><button onClick="showCharacter('B:b:b:b_a-a:a')">B:b:b:b_a-a:a</a></td></tr>
<tr><td>𒂊</td><td>U+1208A</td><td>E</td><td>498</td><td>HT4</td><td><button onClick="showCharacter('b::b:b:b:b_:a:a')">b::b:b:b:b_:a:a</a></td></tr>
<tr><td>𒂊</td><td>U+1208A</td><td>E</td><td>498</td><td>HT40,585,97</td><td><button onClick="showCharacter('b:b:b_a-a:a')">b:b:b_a-a:a</a></td></tr>
<tr><td>𒂊</td><td>U+1208A</td><td>E</td><td>498</td><td>HT88,291,37,298</td><td><button onClick="showCharacter('b:b:b_a:a')">b:b:b_a:a</a></td></tr>
<tr><td>𒂊</td><td>U+1208A</td><td>E</td><td>498</td><td>HT188</td><td><button onClick="showCharacter('b::b_a-a:a')">b::b_a-a:a</a></td></tr>
<tr><td>𒂊</td><td>U+1208A</td><td>E</td><td>498</td><td>HT585</td><td><button onClick="showCharacter('b::b-:sb--a-a:a')">b::b-:sb--a-a:a</a></td></tr>
</tbody></table>
</div>
</td></tr></table>
</div>
</td></tr></table>
<div id="graphDiv" width="1000" height="600"></div>
<script>
$(function() {
$("#examples").tablesorter();
var count = $('#examples tr').length;
$('#amount').html((count-1)+" characters");
});
</script>
</body>
</html>