-
Notifications
You must be signed in to change notification settings - Fork 1
/
simpledraw-19.html
853 lines (708 loc) · 27.1 KB
/
simpledraw-19.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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
<doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SimpleDraw</title>
<style>
/*
HTML
*/
body {
background: gainsboro;
padding: 0;
margin: 0;
}
h1 {
text-transform: capitalize;
font-size: 1.5em;
font-family: Impact, sans-serif;
margin: 0;
color: #1F497D;
}
section {
/*border: thin gray solid;*/
height: 100%
}
section#controls {
float: left;
padding: 0 0.5em;
}
section#drawing-area {
float: left;
padding: 0;
margin: 0;
}
fieldset {
font-family: Impact, sans-serif;
border: 2px solid #1F497D;
border-radius: 2px;
margin-bottom: 0.5em
}
fieldset legend {
background: #1F497D;
color: #fff;
padding: 1px 5px;
font-size: 1em;
border-radius: 2px;
margin-left: -12px;
}
button {
font-family: Impact, sans-serif;
background-color: #1F497D;
color: #fff;
padding: 1px 5px;
font-size: 1em;
border-radius: 2px;
text-decoration: none;
border: none;
box-shadow: 1px 1px 2px #777;
display: block;
width: 6em;
margin: 0.25em 0.25em 0.25em 0;
}
button:hover, button:focus {
box-shadow: 2px 2px 4px #777;
}
button:active {
box-shadow: 0px 0px 1px #777;
}
button[aria-pressed="true"] {
color: #1F497D;
background-color: #fff;
}
ul[role="listbox"] {
font-family: Impact, sans-serif;
font-size: 1em;
text-decoration: none;
border: none;
box-shadow: 1px 1px 2px #777;
list-style: none;
background-color: #1F497D;
color: #fff;
margin: 0;
padding: 0;
width: 6em;
}
ul[role="listbox"] li {
display: block;
margin: 4px;
padding: 1px;
border-radius: 2px;
}
ul[role="listbox"] li[aria-selected="false"] {
display: none;
/*outline: 2px black solid;*/
margin: 4px;
padding: 1px;
}
ul[role="listbox"] li[aria-selected="false"]:hover {
outline: 2px white solid;
}
ul[role="listbox"]:hover li[aria-selected="false"],
ul[role="listbox"]:focus li[aria-selected="false"]{
display: block;
}
label {
font-family: Impact, sans-serif;
font-size: 1em;
background-color: #1F497D;
color: #fff;
padding: 1px 5px;
margin: 0 0 0.25em 0;
}
input[type="number"] {
font-family: Impact, sans-serif;
font-size: 1em;
background-color: #1F497D;
color: #fff;
border: none;
padding: 1px 5px;
margin: 0 0 0.25em -5px;
width: 3em;
}
/*
SVG
*/
svg {
width: 580px;
height: 580px;
background: white; /* Note that this only works for the SVG root */
}
*[role="button"] {
stroke: indigo;
fill: violet;
stroke-width: 1px;
}
*[role="button"] text {
font-size: 12px;
font-family: Verdana, sans-serif;
text-anchor: middle;
stroke: none;
fill: indigo;
pointer-events: none;
}
*[aria-pressed="true"] rect {
stroke-width: 3px;
}
svg#canvas {
/* pointer-events: all; */
}
rect#backdrop {
fill: url(#grid100);
stroke: gray;
}
</style>
<script>
window.onload = function () {
var svgrooot = document.getElementById("simpledraw");
var dnd = new simpledrawObj(svgrooot);
dnd.init();
}
function simpledrawObj(svgrooot) {
this.root = svgrooot;
this.backdrop = this.root.getElementById("backdrop");
this.canvas = this.root.getElementById("canvas");
this.scaffolds = this.root.getElementById("scaffolds");
// NOTE: now distinguish between active shape and
// other drawn elements, like the scaffold
this.activeShape = null;
this.activeScaffold = null;
this.activeHandle = null;
this.points = null;
this.buttons = null;
this.mode = "draw-dot";
this.coords = this.root.createSVGPoint();
this.originpoint = this.root.createSVGPoint();
// styles
this.styles = {
"fill": "black",
"stroke": "black",
"stroke-width": "1px"
};
this.values = {
"symbol": "hexagon"
};
// constants
this.svgns = "http://www.w3.org/2000/svg";
this.xlinkns = "http://www.w3.org/1999/xlink";
}
simpledrawObj.prototype.init = function (){
this.root.addEventListener('click', bind(this, this.draw), false );
this.root.addEventListener('mousedown', bind(this, this.grab), false );
this.root.addEventListener('mousemove', bind(this, this.drag), false );
this.root.addEventListener('mouseup', bind(this, this.drop), false );
this.buttons = document.querySelectorAll("button");
for (var b = 0, bLen = this.buttons.length; bLen > b; ++b) {
var eachButton = this.buttons[b];
eachButton.addEventListener('click', bind(this, this.handleButtons), false );
}
this.listboxes = document.querySelectorAll("[role='listbox']");
for (var l = 0, lLen = this.listboxes.length; lLen > l; ++l) {
var eachListbox = this.listboxes[l];
eachListbox.addEventListener('click', bind(this, this.handleDropdown), false );
}
this.inputs = document.querySelectorAll("input[type='number']");
for (var i = 0, iLen = this.inputs.length; iLen > i; ++i) {
var eachInput = this.inputs[i];
eachInput.addEventListener('click', bind(this, this.handleInputs), false );
}
// console.log( JSON.stringify(this.styles).replace(/"/g, "").replace(/,/g, "; ").replace(/[{}]/g, "") )
}
/*
// draw
*/
simpledrawObj.prototype.draw = function (event){
if ( this.backdrop == event.target
|| this.canvas == event.target.parentNode
|| this.scaffolds == event.target.parentNode ) {
// adjust coords
this.coords = localCoords(event, this.backdrop, this.root);
//console.log(event.detail)
if (2 == event.detail){
this.reset();
} else {
switch (this.mode) {
case "draw-dot":
this.drawDot();
break;
case "draw-polyline":
this.drawPoly("polyline" );
break;
case "draw-polygon":
this.drawPoly("polygon");
break;
case "draw-rect":
this.drawRect();
break;
case "draw-circle":
this.drawCircle();
break;
case "draw-path":
this.drawPath();
break;
case "draw-freehand":
this.drawFreehand();
break;
case "draw-use":
this.drawUse();
break;
}
}
}
}
simpledrawObj.prototype.drawDot = function (){
this.activeShape = document.createElementNS(this.svgns, "circle");
this.activeShape.setAttribute("cx", this.coords.x);
this.activeShape.setAttribute("cy", this.coords.y);
this.activeShape.setAttribute("r", "2");
this.activeShape.setAttribute("style", this.getStyle() );
// note that we're now appending draw elements to a specific canvas
this.canvas.appendChild( this.activeShape );
// if we don't set this to null, it starts dragging immediately!
this.activeShape = null;
}
simpledrawObj.prototype.drawPoly = function (shape){
if (!this.activeShape
|| shape != this.activeShape.localName ) {
this.activeShape = document.createElementNS(this.svgns, shape);
this.activeShape.setAttribute("style", this.getStyle() );
} else {
var points = this.activeShape.getAttribute("points");
this.points = points.split(" ");
}
if (!this.points) {
this.points = [];
}
this.points.push( this.coords.x + "," + this.coords.y );
this.activeShape.setAttribute("points", this.points.join(" "));
// no longer need to worry about SVG controls
this.canvas.appendChild( this.activeShape );
}
simpledrawObj.prototype.drawRect = function (){
if (!this.activeShape ) {
this.activeShape = document.createElementNS(this.svgns, "rect");
this.activeShape.setAttribute("style", this.getStyle() );
if (!this.points) {
this.points = [];
}
// we're using the points array, but in a different way for rect than for polys
this.points.push( this.coords.x );
this.points.push( this.coords.y );
this.activeShape.setAttribute("x", this.points[0] );
this.activeShape.setAttribute("y", this.points[1] );
this.canvas.appendChild( this.activeShape );
}
}
simpledrawObj.prototype.drawCircle = function (){
if (!this.activeShape ) {
this.activeShape = document.createElementNS(this.svgns, "circle");
this.activeShape.setAttribute("style", this.getStyle() );
if (!this.points) {
this.points = [];
}
// we're using the points array, but in a different way for rect than for polys
this.points.push( this.coords.x );
this.points.push( this.coords.y );
this.activeShape.setAttribute("cx", this.points[0] );
this.activeShape.setAttribute("cy", this.points[1] );
this.canvas.appendChild( this.activeShape );
}
}
simpledrawObj.prototype.drawPath = function (){
if (!this.activeShape ) {
this.activeShape = document.createElementNS(this.svgns, "path");
this.activeShape.setAttribute("style", this.getStyle() );
}
// var d = this.activeShape.getAttribute("d");
// if (!d) {
// d = "M";
// }
// d += " " + this.coords.x + "," + this.coords.y + " ";
// NOTE: we're now storing the points array for a path
if (!this.points) {
this.points = [];
}
this.points.push( this.coords.x + "," + this.coords.y );
var d = "M";
var pointCount = this.points.length;
if ( 3 == pointCount ) {
d += this.points[0] + " Q" + this.points[1] + " " + this.points[2];
} else if ( 4 == pointCount ) {
d += this.points[0] + " C" + this.points[1] + " " + this.points[2] + " " + this.points[3];
} else {
d += this.points.join(" ");
}
this.activeShape.setAttribute("d", d);
this.canvas.appendChild( this.activeShape );
this.drawScaffold();
}
simpledrawObj.prototype.drawFreehand = function (){
if (!this.activeShape ) {
this.activeShape = document.createElementNS(this.svgns, "path");
this.activeShape.setAttribute("style", this.getStyle() );
}
var d = this.activeShape.getAttribute("d");
if (!d) {
d = "M";
}
d += " " + this.coords.x + "," + this.coords.y + " ";
this.activeShape.setAttribute("d", d);
this.canvas.appendChild( this.activeShape );
}
simpledrawObj.prototype.drawUse = function (){
this.activeShape = document.createElementNS(this.svgns, "use");
this.activeShape.setAttribute("x", this.coords.x);
this.activeShape.setAttribute("y", this.coords.y);
this.activeShape.setAttributeNS(this.xlinkns, "href", "#" + this.values["symbol"]);
this.activeShape.setAttribute("style", this.getStyle() );
this.canvas.appendChild( this.activeShape );
this.activeShape = null;
}
simpledrawObj.prototype.drawScaffold = function (){
if (!this.activeScaffold ) {
this.activeScaffold = document.createElementNS(this.svgns, "polyline");
var scaffoldStyle = "fill:none; ";
scaffoldStyle += "stroke:blue; ";
scaffoldStyle += "stroke-width:3px; ";
scaffoldStyle += "stroke-linecap:round; ";
scaffoldStyle += "stroke-linejoin:round; ";
scaffoldStyle += "stroke-dasharray:0.5 10; ";
scaffoldStyle += "marker:url(#handle); ";
this.activeScaffold.setAttribute("style", scaffoldStyle );
this.scaffolds.appendChild( this.activeScaffold );
}
this.activeShape.setAttribute("points", this.points.join(" "));
// create initial handle
this.activeHandle = document.createElementNS(this.svgns, "circle");
this.activeHandle.setAttribute("cx", this.coords.x);
this.activeHandle.setAttribute("cy", this.coords.y);
this.activeHandle.setAttribute("r", "6");
var handleStyle = "fill:none; ";
handleStyle += "stroke:blue; ";
handleStyle += "stroke-width:2px; ";
handleStyle += "pointer-events:all; ";
this.activeHandle.setAttribute("style", handleStyle );
this.scaffolds.appendChild( this.activeHandle );
}
/*
// drag-n-drop
*/
simpledrawObj.prototype.grab = function (event){
if ( "drag" == this.mode
|| "erase" == this.mode
|| "animate" == this.mode ){
// stop native drag-n-drop
event.preventDefault();
event.stopPropagation();
// only grab things in drawing area
if ( this.canvas == event.target.parentNode ) {
var target = event.target;
if (this.backdrop != target) {
this.activeShape = target;
this.coords = localCoords(event, this.backdrop, this.root);
this.originpoint = this.coords;
// adjust for existing transforms
var transform = this.activeShape.getAttribute("transform");
if (transform) {
var translate = transform.replace("translate(", "").replace(")", "").split(",");
this.originpoint.x -= parseFloat( translate[0] );
this.originpoint.y -= parseFloat( translate[1] );
}
}
}
}
}
simpledrawObj.prototype.drag = function (event){
// stop native drag-n-drop
event.preventDefault();
event.stopPropagation();
this.coords = localCoords(event, this.backdrop, this.root);
if ( "drag" == this.mode ){
if ( this.activeShape ) {
var x = this.coords.x - this.originpoint.x;
var y = this.coords.y - this.originpoint.y;
this.activeShape.setAttribute("transform", "translate(" + x + "," + y + ")");
}
} else if (this.activeShape) {
switch (this.mode) {
case "draw-dot":
break;
case "draw-rect":
this.updateRect();
break;
case "draw-circle":
this.updateCircle();
break;
case "draw-polyline":
case "draw-polygon":
this.updatePoly();
break;
case "draw-path":
this.updatePath();
break;
case "draw-freehand":
this.updateFreehand();
break;
}
}
}
simpledrawObj.prototype.drop = function (){
if ( "drag" == this.mode ){
this.activeShape = null;
} else if ( "erase" == this.mode ) {
if ( this.activeShape ) {
this.activeShape.parentNode.removeChild( this.activeShape );
this.activeShape = null;
}
} else if ( "animate" == this.mode ) {
this.animate();
}
}
/*
// Update shapes
*/
simpledrawObj.prototype.updatePoly = function (){
var points = this.points.join(" ");
points += " " + this.coords.x + "," + this.coords.y;
this.activeShape.setAttribute("points", points);
}
simpledrawObj.prototype.updatePath = function (){
var d = "M";
var pointCount = this.points.length;
if ( 2 == pointCount ) {
d += this.points[0] + " Q" + this.points[1];
} else if ( 3 == pointCount ) {
d += this.points[0] + " C" + this.points[1] + " " + this.points[2];
} else {
d += this.points.join(" ");
}
d += " " + this.coords.x + "," + this.coords.y;
this.activeShape.setAttribute("d", d);
this.updateScaffold();
}
simpledrawObj.prototype.updateFreehand = function (){
var d = this.activeShape.getAttribute("d");
if (!d) {
d = "M";
}
d += this.coords.x + "," + this.coords.y + " ";
this.activeShape.setAttribute("d", d);
}
simpledrawObj.prototype.updateRect = function (){
// we're using the points array, but in a different way for rect than for polys
this.points[2] = this.coords.x;
this.points[3] = this.coords.y;
var x = this.points[0];
var width = this.points[2] - this.points[0];
if ( 0 > width ) {
//if the current cursor x is to the left of the origin, we have to reposition the x attribute
x = this.points[2];
width = this.points[0] - this.points[2];
}
var y = this.points[1];
var height = this.points[3] - this.points[1];
if ( 0 > height ) {
//if the current cursor y is to the top of the origin, we have to reposition the y attribute
y = this.points[3];
height = this.points[1] - this.points[3];
}
this.activeShape.setAttribute("x", x );
this.activeShape.setAttribute("y", y );
this.activeShape.setAttribute("width", width );
this.activeShape.setAttribute("height", height );
}
simpledrawObj.prototype.updateCircle = function (){
this.points[2] = this.coords.x;
this.points[3] = this.coords.y;
// geometry magic!
var radius = Math.sqrt(Math.pow(Math.abs(this.points[2] - this.points[0]), 2)
+ Math.pow(Math.abs(this.points[3] - this.points[1]), 2));
this.activeShape.setAttribute("r", radius );
}
simpledrawObj.prototype.updateScaffold = function (){
if (this.activeScaffold) {
var points = this.points.join(" ");
points += " " + this.coords.x + "," + this.coords.y;
this.activeScaffold.setAttribute("points", points);
}
}
simpledrawObj.prototype.animate = function (){
if ( this.activeShape && "path" == this.activeShape.localName ) {
this.pathLength = this.activeShape.getTotalLength();
this.pathOffset = this.pathLength;
this.activeShape.style.strokeDasharray = this.pathLength;
this.activeShape.style.strokeDashoffset = this.pathOffset;
var t = this;
this.timer = setInterval( function () {
if ( 0 < t.pathOffset ) {
t.pathOffset -= 5;
t.activeShape.style.strokeDashoffset = t.pathOffset;
} else {
clearInterval( t.timer );
}
}, 10);
}
}
/*
// UI controls
*/
simpledrawObj.prototype.handleButtons = function (){
this.reset();
for (var b = 0, bLen = this.buttons.length; bLen > b; ++b) {
var eachButton = this.buttons[b];
eachButton.setAttribute("aria-pressed", "false" );
}
var target = event.target;
target.setAttribute("aria-pressed", "true" );
this.mode = target.getAttribute("data-mode");
console.log("mode: " + this.mode);
}
simpledrawObj.prototype.handleDropdown = function (){
var target = event.target;
var options = target.parentNode.querySelectorAll("[role='option']")
for (var o = 0, oLen = options.length; oLen > o; ++o) {
var eachOption = options[o];
eachOption.setAttribute("aria-selected", "false" );
}
target.setAttribute("aria-selected", "true" );
var prop = target.parentNode.getAttribute("data-property");
if ( prop ) {
this.styles[prop] = target.textContent;
} else {
var datatype = target.parentNode.getAttribute("data-type");
this.values[datatype] = target.textContent;
}
}
simpledrawObj.prototype.handleInputs = function (){
var target = event.target;
var prop = target.getAttribute("data-property");
this.styles[prop] = target.value;
}
simpledrawObj.prototype.getStyle = function (){
var style = JSON.stringify(this.styles)
.replace(/"/g, "")
.replace(/,/g, "; ")
.replace(/[{}]/g, "");
return style;
}
simpledrawObj.prototype.reset = function (){
// clicking on any button should start a new active element and new mode
this.points = null;
this.activeShape = null;
this.activeScaffold = null;
this.activeHandle = null;
// NOTE: remove all old scaffolds
while (this.scaffolds.firstChild) {
this.scaffolds.removeChild(this.scaffolds.firstChild);
}
}
// adjust coordinates for transforms
// note that this changed to add the SVG root element
function localCoords ( event, element, root ) {
var p = root.createSVGPoint();
p.x = event.clientX;
p.y = event.clientY;
p = p.matrixTransform(element.getScreenCTM().inverse());
// NOTE: now we're looking at the numbers, so limiting the floats to precison 2 makes it easier
// since SVG only works at one pixel of accuracy anyway
// p.x = Math.round(p.x * 100)/100;
// p.y = Math.round(p.y * 100)/100;
// console.log("p: " + p.x + "," + p.y);
return p;
}
function bind (scope, fn) {
return function () {
return fn.apply( scope, arguments );
}
}
</script>
</head>
<body>
<main id="app">
<section id="controls">
<h1>SimpleDraw</h1>
<fieldset>
<legend>shapes</legend>
<button aria-pressed="true" data-mode="draw-dot">dot</button>
<button aria-pressed="false" data-mode="draw-polyline">polyline</button>
<button aria-pressed="false" data-mode="draw-polygon">polygon</button>
<button aria-pressed="false" data-mode="draw-rect">rectangle</button>
<button aria-pressed="false" data-mode="draw-circle">circle</button>
<button aria-pressed="false" data-mode="draw-path">path</button>
<button aria-pressed="false" data-mode="draw-freehand">freehand</button>
<button aria-pressed="false" data-mode="draw-use">use</button>
</fieldset>
<fieldset>
<legend>symbols</legend>
<ul id="colors" role="listbox" data-type="symbol" tabindex="1">
<li role="option" tabindex="1" tabindex="1" aria-selected="true">hexagon</li>
<li role="option" tabindex="1" aria-selected="false">boom</li>
</ul>
</fieldset>
<fieldset>
<legend>controls</legend>
<button aria-pressed="false" data-mode="drag">drag</button>
<button aria-pressed="false" data-mode="erase">erase</button>
<button aria-pressed="false" data-mode="animate">animate</button>
</fieldset>
<fieldset>
<legend>stroke</legend>
<ul id="colors" role="listbox" data-property="stroke" tabindex="1">
<li role="option" tabindex="1" tabindex="1" aria-selected="true" style="color:black; background-color:black;">black</li>
<li role="option" tabindex="1" aria-selected="false" style="color:gray; background-color:gray;">gray</li>
<li role="option" tabindex="1" aria-selected="false" style="color:white; background-color:white;">white</li>
<li role="option" tabindex="1" aria-selected="false" style="color:red; background-color:red;">red</li>
<li role="option" tabindex="1" aria-selected="false" style="color:blue; background-color:blue;">blue</li>
<li role="option" tabindex="1" aria-selected="false" style="color:green; background-color:green;">green</li>
<li role="option" tabindex="1" aria-selected="false" style="color:yellow; background-color:yellow;">yellow</li>
<li role="option" tabindex="1" aria-selected="false" style="color:orange; background-color:orange;">orange</li>
<li role="option" tabindex="1" aria-selected="false" style="color:purple; background-color:purple;">purple</li>
<li role="option" tabindex="1" aria-selected="false" style="color:black; background-color:white;">none</li>
</ul>
<label for="stroke-width">width:</label>
<input id="stroke-width" type="number" min="0.5" max="10" step="0.5" value="1" data-property="stroke-width"/>
<br>
<label for="stroke-dasharray">dasharray:</label>
<input id="stroke-dasharray" type="number" min="0" max="100" step="1" value="0" data-property="stroke-dasharray"/>
</fieldset>
<fieldset>
<legend>fill</legend>
<ul id="colors" role="listbox" data-property="fill" tabindex="1">
<li role="option" tabindex="1" tabindex="1" aria-selected="true" style="color:black; background-color:black;">black</li>
<li role="option" tabindex="1" aria-selected="false" style="color:gray; background-color:gray;">gray</li>
<li role="option" tabindex="1" aria-selected="false" style="color:white; background-color:white;">white</li>
<li role="option" tabindex="1" aria-selected="false" style="color:red; background-color:red;">red</li>
<li role="option" tabindex="1" aria-selected="false" style="color:blue; background-color:blue;">blue</li>
<li role="option" tabindex="1" aria-selected="false" style="color:green; background-color:green;">green</li>
<li role="option" tabindex="1" aria-selected="false" style="color:yellow; background-color:yellow;">yellow</li>
<li role="option" tabindex="1" aria-selected="false" style="color:orange; background-color:orange;">orange</li>
<li role="option" tabindex="1" aria-selected="false" style="color:purple; background-color:purple;">purple</li>
<li role="option" tabindex="1" aria-selected="false" style="color:black; background-color:white;">none</li>
</ul>
<label for="fill-opacity">opacity:</label>
<input id="fill-opacity" type="number" min="0" max="1" step="0.1" value="1" data-property="fill-opacity"/>
</fieldset>
</section>
<section id="drawing-area">
<svg id="simpledraw"
width="100%" height="100%" viewBox="0 0 600 600">
<defs>
<pattern id="grid10" x="0" y="0" width="10" height="10" patternUnits="userSpaceOnUse">
<rect x="0" y="0" width="10" height="10" style="stroke:gray;stroke-width:.1;fill:none;"/>
</pattern>
<pattern id="grid100" x="0" y="0" width="100" height="100" patternUnits="userSpaceOnUse">
<rect x="0" y="0" width="100" height="100" style="stroke:gray;stroke-width:0.2;fill:url(#grid10);"/>
</pattern>
<path id="hexagon" d="M17.5,-30.3 35,0 17.5,30.3 -17.5,30.3 -35,4.3 -17.5,-30.3 17.5,-30.3" />
<path id="boom" d="M3.2e-15,-53 C5.1,-19.3 1.8,-6.7 20.9,-36.3 C4.9,-4.9 14.1,-14.1 45.8,-26.5 C19.3,-5.1 6.7,-1.8 42,0 C6.7,1.8 19.3,5.1 45.8,26.4 C14.1,14.1 4.9,4.9 21.0,36.3 C1.8,6.7 5.1,19.3 3.2e-15,53 C-5.1,19.3 -1.8,6.7 -20.9,36.3 C-4.9,4.9 -14.1,14.1 -45.8,26.5 C-19.3,5.1 -6.7,1.8 -42,5.1e-15 C-6.7,-1.8 -19.3,-5.1 -45.8,-26.5 C-14.1,-14.1 -4.9,-4.9 -20.9,-36.3 C-1.8,-6.7 -5.1,-19.3 -9.7e-15,-53 "/>
</defs>
<rect id="backdrop" x="0" y="0" width="600" height="600"/>
<svg id="canvas" x="0" y="0" width="100%" height="100%"> </svg>
<g id="scaffolds"> </g>
</svg>
</section>
</main>
<script>
</script>
</body>
</html>