-
Notifications
You must be signed in to change notification settings - Fork 3
/
FibbonacciWord.html
638 lines (581 loc) · 22.9 KB
/
FibbonacciWord.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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>
body{
-webkit-transition:all 2.5s ease-in;
-moz-transition:all 2.5s ease-in;
-o-transition:all 2.5s ease-in;
transition:all 2.5s ease-in;
}
a{
color:violet;
}
.opaqueDiv{
position:fixed;top:0;left:0;width:100%;height:100%;background:black;opacity:0.5;
}
.alertDiv{
padding: 13px 0px 10px 26px;
position: fixed;
top: 0;
margin-top: 3%;
margin-left: 20%;
background: rgb(0, 102, 0);
width: 50%;
height: auto;
color: yellowGreen;
border: 1px solid yellowGreen;
-webkit-box-shadow: rgba(0, 255, 0, 0.498039) 0px 0px 15px;
box-shadow: rgba(0, 255, 0, 0.498039) 0px 0px 15px;
}
.containerDiv{
position: fixed;
top: 0;
margin-left: 20%;
background: rgb(0, 102, 0);
width: 50%;
height: 100%;
color: yellowGreen;
border: 1px solid yellowGreen;
}
.containerDiv div{margin-left:20px}
#settings{
max-width:30%;
background: brown;
color: white;
opacity: 0.5;
}
#settings:hover{
opacity:1;
}
#settings:hover div{display:block;}
#settings div{display:none;}
#settings label{float:right;}
#settings li{list-style: none;
padding: 5px;
margin: 0;margin-top: 16px;}
</style>
<title>Fibbonacci Word Sequence!</title>
<script>
var bitsetWrapper = function () {
function GetJavaScriptWordSize() {
var bits = 1; //Get's the engine word size, this limits the length of the integers.
var prev = 0;
var sumM1 = 1;
var sum = 2;
while (sumM1 < sum) {
bits++;
prev = sum;
sumM1 = sumM1 + sum;
sum = sumM1 + 1;
}
return bits - 1;
}
function byteConcantenation(BASE) { //It has unnamed arguments!
//BASE is not numerical base, is byte base.
//This concantenates bits (values) and attempts to get a value from it. For example 255 and 255 would give 65535 if base 8 of course.
//It will cast mod 2^BASE-1 to argument values
for (var i = arguments.length - 1, value = 0, r = 0; 0 < i; i--, r++) {
value += leftShiftNumber(arguments[i] % (Math.pow(2, BASE)), r * 8);
//console.log('I am called',arguments[i]%(Math.pow(2,BASE)),r*8);
}
return value;
}
function splitNumberIntoBytes(number, offset, BASE) {
BASE = BASE || 8;
offset |= 0;
number |= 0;
if(number===0)return [0];
var numberArray = [],
i = Math.floor(Math.log(number) * Math.LOG2E) + 1;
offset += (BASE - i) > 0 ? BASE - i : 0;
i += offset;
for (var s = 8 - (i) % 8; i > 0; i -= 8) {
//console.log(Math.floor(Math.log(number)*Math.LOG2E)+1+offset)
//console.log(rightShiftNumber(number,i-8<0?0:i-8),rightShiftNumber(number,i-8<0?0:i-8)&(i>=8?generateOnesByLength(8):generateOnesByLength(i)),i,i>=8?generateOnesByLength(8):generateOnesByLength(i))
numberArray.push(rightShiftNumber(number, (i - 8 < 0 ? 0 : i - 8)) & (i >= 8 ? generateOnesByLength(8) : generateOnesByLength(i)));
}
numberArray[numberArray.length - 1] <<= s % 8;
return numberArray;
}
function generateOnesByLength(n) { //Attempts to generate a binary number full of ones given a length..
//This function is really dumb perhaps there's a faster way or something..?
var x = 0;
for (var i = 0; i < n; i++) {
x <<= 1;
x |= 1; //I don't know if this is performant faster than Math.pow but seriously I don't think I'll need Math.pow, do I?
}
return x;
}
function leftShiftNumber(number, shiftIndex, PRENUMBER) { //a FAKE << operator because << doesn't support BIG values or values higuer than 2^30
//PRENUMBER is a secret argument which can take 0 or 1 if 0 it fills the bits with zeros, with 1 it fills the bits with ones
//shiftIndex shouldn't be higuer than The JavaScript Enigne word size
//Did you guys know that bit shifting is actually just simply a multiplication by two? 11*10=110 //This is true in binary, tertiary, hexal, decimal, hexadecimal, etc..
return number * Math.pow(2, shiftIndex) + (PRENUMBER ? Math.pow(2, shiftIndex) : 0); //Wasn't it clear enough?
}
function rightShiftNumber(number, shiftIndex) { //The exact opposite of above.
return Math.floor(number / Math.pow(2, shiftIndex));
}
function generateReverseOnesByLength(n) { //Won't throw errors, beware.
return generateOnesByLength(n) << 8 - n;
}
function ByteSplice(byte, index, length) { //You should infer what this does.
//Numbers are immutable so it won't modify parent.. not that it matters.
//This won't throw errors, so you should be careful with the input.
if (0 > index) { //I wish I didn't had to do this.
index = 8 + index; //But I must support everyone will to don't think by themselves. Wait.. this is a private function...
}
if (length !== 0) { //I h8 JS
length = length || 8 - index;
}
byte &= generateOnesByLength(8 - index); //Killin first bytes
return byte >> (8 - index) - length;
}
function convertBinaryArrayTo8bitArray(arr, epicOffset) { //It will attempt to convert an Array
var newarr = [],
remainingArray = arr.splice(0),
currArray = [],
currNumber = 0;
remainingArray = (new Array(epicOffset | 0)).concat(remainingArray);
while (remainingArray.length) {
currArray = remainingArray.splice(0, 8);
currNumber = 0;
for (var i = 0; i < 8; i++) {
var x = (currArray[i] % 2) | 0; //Undefined, Null or any other thing will be 0
currNumber |= x << (7 - i);
}
newarr.push(currNumber);
}
return newarr;
}
function $_Uint1Array(typedarr, gffLength) { //friends with Uint8Array, not an actual array though, length shouldn't be modified, a complete mess, but hey... it's easier.. In a way
//This actually attempts to support bytes with non-8 bits.
var buff, ui8, l, TheJavaScriptEnignewordsize = GetJavaScriptWordSize();
//START
if (typedarr.length && typedarr.constructor !== ArrayBuffer) { //Please don't enter any DOM objects you plebs
this.length = typedarr.length;
ui8 = new Uint8Array(convertBinaryArrayTo8bitArray(typedarr));
} else if (!isNaN(typedarr)) {
ui8 = new Uint8Array(Math.ceil(typedarr / 8));
this.length = typedarr;
} else {
ui8 = new Uint8Array((typedarr.constructor === ArrayBuffer) ? typedarr : null); //This will throw error if any of you put objects that you shouldn't, that should teach you.
this.length = ui8.length;
}
this.length = gffLength || this.length; //Hmhm that seems reasonable.
this.getByteArray = function () {
return ui8;
}
this.subarray = function (a, b) { //b is absolute.
//This function doesn't modify the this object, it creates a new one.
b = Math.ceil(b || this.length);
var c = Math.floor(a / 8),
d = Math.ceil(b / 8),
$length = (Math.ceil((b - a) / 8)), //Yeah, now it's relative.
u = new Uint8Array($length),
usedArr = ui8.subarray(c, d);
for (var i = 0, l = u.length; i < l; i++) {
u[i] = ByteSplice(usedArr[i], a % 8) << a % 8;
//console.log(u[i],"FIRST",b%8);
if (!isNaN(usedArr[i + 1])) u[i] |= ByteSplice(usedArr[i + 1], 0, a % 8);
//console.log(u[i],"SECOND");
}
//console.log((b-a)%8);
//Buggy Prone!
//Should be tested a lot!
if (b % 8 && (b - a) % 8) {
u[i - 1] = ByteSplice(u[i - 1], 0, (b - a) % 8) << (8 - (b - a) % 8);
} //Lel
//console.log(u,i,usedArr);
return new $_Uint1Array(u.buffer, b - a);
}
//this funtion is also untested
this.subNumberValue = function (a, b, c) { //b is relative
c |= 0; //if c is undefined it defaults to 0.
//So what is c? c is the value the offsets should be, or the value that is outside this.length
//gets the value from a with the bit length b, will not work correctly if b is larger than The JavaScript Enigne word size
var f = this.subarray(a, a + b),
n = [8];
for (var i = 0, x = f.getByteArray(), l = x.length; i < l; i++) {
n.push(x[i]);
}
//console.log(byteConcantenation.apply(this,n),Math.pow(2,(8-(b%8))%8),n)
if (a + b > this.length) {
(a + b) - this.length;
}
return Math.floor(byteConcantenation.apply(this, n) / Math.pow(2, (8 - (b % 8)) % 8)); //MAGIC
}
this.valueOf = function (i) { //replacement of arr[i], it will be harder but, meh worth it.
i |= 0;
if (i < 0 || i >= this.length) {
return undefined;
}
return ByteSplice(ui8[Math.floor(i / 8)], i % 8, 1); //That was easier than I expected it
}
this.set = function (sset, lindex) {
lindex |= 0;
if (sset.length + lindex > this.length) {
throw new RangeError("Index is out of range. Why don't you try concantenating them..?")
}
var ar = convertBinaryArrayTo8bitArray(sset, lindex % 8);
console.log(ar, lindex, ui8[Math.floor(lindex / 8)], generateReverseOnesByLength(lindex % 8))
ar[0] = ui8[Math.floor(lindex / 8)] & generateReverseOnesByLength(lindex % 8) | ar[0];
ui8.set(ar, Math.floor(lindex / 8));
}
//finally
this.byteSet = function (sset, lindex, BYTEBASE) { //OH GAWD//BYTEBASE IS 8!!! But.. what if.. what if the BYTEBASE WASN'T 8 AT ALL??
lindex |= 0;
BYTEBASE |= 0;
BYTEBASE = BYTEBASE || 8; //BYTEBASE CAN'T BE ZERO!
var TheResultingArray = [],
index = lindex % 8,
currentBytes = [];
for (var i = 0, l = sset.length; i < l; i++) {
//console.log(TheResultingArray,index,currentBytes)
currentBytes = splitNumberIntoBytes(sset[i], index, BYTEBASE);
//console.log("splitNumberIntoBytes(sset[i], index, BYTEBASE)",splitNumberIntoBytes(sset[i], index, BYTEBASE));
index = (index + BYTEBASE) % 8;
if (TheResultingArray.length&&index) {
TheResultingArray[TheResultingArray.length - 1] |= currentBytes.shift();
}
TheResultingArray = TheResultingArray.concat(currentBytes);
}
//console.log(TheResultingArray)
ui8.set(TheResultingArray, lindex);
return this;
}
this.getSplitValueBy = function (leNumber, index) { //THE FUN BEGINS NOW
//I first thought of using this.subarray but then I realized that leNumber can be bigger than 8.
leNumber |= 0;
index |= 0;
if (leNumber > TheJavaScriptEnignewordsize) {
throw new RangeError("The byte length really, really shouldn't be higuer than The Browser Word Size (Or anything close to it)"); //Unless you have a big number library or something, but who the hell needs bytes longer than The JavaScript Enigne word size bits, do you really really want to have a byte with a max value of 2^(The JavaScript Enigne word size)-1??
} else if (leNumber < 1) { //I was tempted to put leNumber<2 but then I reasoned with myself.
throw new Error("You entered a value less than.. 1");
} else {
var RealLength = this.length - index,
newBytesLength = Math.ceil(RealLength / leNumber),
arrr = [];
for (var i = 0; i < newBytesLength; i++) {
arrr.push(this.subNumberValue((leNumber * i) + index, leNumber));
}
return arrr;
}
}
}
return $_Uint1Array;
}();
function makeElem(elemName,attribs){//atribs must be an Object
var e=document.createElement(elemName),a,b,d;
for(a in attribs){
if(attribs.hasOwnProperty(a)){
if(a=='style'){
d=attribs.style;
for(b in d){
if(d.hasOwnProperty(b)){
e.style[b]=d[b];
}
}
continue;
}
e.setAttribute(a,attribs[a]);
}
}
return e;
}
var requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback, /* DOMElement */ element){
window.setTimeout(callback, 1000 / 60);
};
})();
var functionsrunning=[],functioncount=0,listfunctions=["standardFunction","invertedFunction","changeDirectionOfTurns","fibspiralQ","fibspiralS"];
allfunctions={standardFunction:function(angle){return (function init(){
var direction=angle;
var fibwords=[[1],[0]];
function fibbonacciWordI(){
var x=fibwords[1].concat(fibwords[0]);
fibwords[0]=fibwords[1];
fibwords[1]=x;
}
var set=new bitsetWrapper(fibwords[1].slice(0));
return function(currentPoint,iter,ctx,strokelength,length){
if(iter==fibwords[1].length){
fibbonacciWordI();
set=new bitsetWrapper(fibwords[1].slice(0));
}
var curr=set.valueOf(iter);
ctx.beginPath();
ctx.moveTo.apply(ctx,currentPoint);
currentPoint[0]+=Math.cos(direction)*strokelength;
currentPoint[1]+=Math.sin(direction)*strokelength;
ctx.lineTo.apply(ctx,currentPoint);
ctx.stroke();
if(!curr){
if(iter%2){//EVEN
//turn right
//console.log("AE",direction)
direction-=Math.PI/2;
//console.log("AA",direction)
}else{//ODD
//turn left
//console.log("AF",direction,directions.length)
direction+=Math.PI/2;
//console.log("AKK",direction)
}
direction%=2*Math.PI;
}}}())},invertedFunction:function(angle){return (function init(){
var direction=angle;
var fibwords=[[0],[1]];
function fibbonacciWordI(){
var x=fibwords[1].concat(fibwords[0]);
fibwords[0]=fibwords[1];
fibwords[1]=x;
}
var set=new bitsetWrapper(fibwords[1].slice(0));
return function(currentPoint,iter,ctx,strokelength,length){
if(iter==fibwords[1].length){
fibbonacciWordI();
set=new bitsetWrapper(fibwords[1].slice(0));
}
var curr=set.valueOf(iter);
ctx.beginPath();
ctx.moveTo.apply(ctx,currentPoint);
currentPoint[0]+=Math.cos(direction)*strokelength;
currentPoint[1]+=Math.sin(direction)*strokelength;
ctx.lineTo.apply(ctx,currentPoint);
ctx.stroke();
if(!curr){
if(iter%2){//EVEN
//turn right
//console.log("AE",direction)
direction-=Math.PI/2;
//console.log("AA",direction)
}else{//ODD
//turn left
//console.log("AF",direction,directions.length)
direction+=Math.PI/2;
//console.log("AKK",direction)
}
direction%=2*Math.PI;
}}}())},changeDirectionOfTurns:function(angle){return (function init(){
var direction=angle;
var fibwords=[[1],[0]],addchang=Math.PI/2;
function fibbonacciWordI(){
var x=fibwords[1].concat(fibwords[0]);
fibwords[0]=fibwords[1];
fibwords[1]=x;
}
var set=new bitsetWrapper(fibwords[1].slice(0));
return function(currentPoint,iter,ctx,strokelength,length){
if(iter==fibwords[1].length){
fibbonacciWordI();
set=new bitsetWrapper(fibwords[1].slice(0));
}
var curr=set.valueOf(iter);
ctx.beginPath();
ctx.moveTo.apply(ctx,currentPoint);
currentPoint[0]+=Math.cos(direction)*strokelength;
currentPoint[1]+=Math.sin(direction)*strokelength;
ctx.lineTo.apply(ctx,currentPoint);
ctx.stroke();
if(curr){
addchang=-addchang;
}
direction+=addchang;
direction%=2*Math.PI;
}}())},fibspiralQ:(function(angle){return (function init(){
var direction=angle;
direction%=2*Math.PI;
var fibwords=[0,1],addchang=Math.PI/2;
function fibbonacci(){
var i=fibwords[1];
fibwords[1]+=fibwords[0];
return fibwords[0]=i;
}
return function(currentPoint,iter,ctx,strokelength,length){
var fib=fibbonacci();
console.log(fib);
ctx.beginPath();
ctx.moveTo.apply(ctx,currentPoint);
currentPoint[0]+=Math.cos(direction)*strokelength*fib;
currentPoint[1]+=Math.sin(direction)*strokelength*fib;
ctx.lineTo.apply(ctx,currentPoint);
ctx.stroke();
direction+=addchang;
direction%=2*Math.PI;
}}())}),fibspiralS:(function(angle){return (function init(){
var direction=angle;
direction%=2*Math.PI;
var fibwords=[0,1],addchang=Math.PI/2;
function fibbonacci(){
var i=fibwords[1];
fibwords[1]+=fibwords[0];
return fibwords[0]=i;
}
return function(currentPoint,iter,ctx,strokelength,length){
var fib=fibbonacci();
var sleng=strokelength*fib
ctx.beginPath();
ctx.moveTo.apply(ctx,currentPoint);
currentPoint[0]+=Math.cos(direction)*sleng;
ctx.lineTo.apply(ctx,currentPoint);
var fag=currentPoint.slice(0);
currentPoint[1]+=Math.sin(direction)*sleng;
ctx.lineTo.apply(ctx,currentPoint);
currentPoint[0]-=Math.cos(direction)*sleng;
var asdf=currentPoint.slice(0);
ctx.lineTo.apply(ctx,currentPoint);
currentPoint[1]-=Math.sin(direction)*sleng;
ctx.lineTo.apply(ctx,currentPoint);
currentPoint[0]+=Math.cos(direction)*sleng;
currentPoint[1]+=Math.sin(direction)*sleng;
ctx.moveTo.apply(ctx,fag);
ctx.lineTo.apply(ctx,asdf);
ctx.moveTo.apply(ctx,currentPoint);
if((!(direction>=Math.PI/2&&direction<=Math.PI))&&(!(direction>=(3*Math.PI)/2&&direction<=2*Math.PI))){
var sr=asdf;
asdf=fag;
fag=sr;
}
// ctx.moveTo.apply(ctx,fag);
// ctx.lineTo((asdf[0]+fag[0])/2,(asdf[1]+fag[1])/2);
// ctx.stroke();
// ctx.beginPath();
// ctx.moveTo((asdf[0]+fag[0])/2,(asdf[1]+fag[1])/2);
// ctx.setStrokeColor("#f00");
//ctx.lineTo.apply(ctx,asdf);
// ctx.moveTo.apply(ctx,currentPoint);
// ctx.stroke();
// ctx.beginPath();
// ctx.setStrokeColor("#000")
//ctx.lineTo.apply(ctx,fag);
//console.log(Math.cos(direction)*sleng+Math.sin(direction)*sleng);
// window.ctx=ctx;
//console.log(direction/Math.PI+"π");
//Math.abs(Math.cos(direction)*sleng)
var das=direction-3*Math.PI/4;
ctx.arc(fag[0],fag[1],Math.abs(Math.cos(direction)*sleng),das+Math.PI/2,das,true);
ctx.moveTo.apply(ctx,currentPoint);
//ctx.lineTo.apply(ctx,currentPoint);
ctx.stroke();
direction+=addchang;
direction%=2*Math.PI;
}}())})};
window.addEventListener("load",function(){
var canvas = document.getElementById('canvas');
canvas.height =1000; canvas.width = 1300;
var ctx = canvas.getContext && canvas.getContext("2d");
ctx.translate(0.5, 0.5)
//2 LINES
ctx.fillText("Fibbonacci Word Sequence!",20,10)
function fibbonacciWord(strokelength,length,currentPoint,angle,thef){
var iter=0,ss,k;
var func=allfunctions[thef](angle);
k=functionsrunning.push({name:thef,id:(ss=functioncount++),running:true});
requestAnimFrame(function(){
//console.log(curr,directions[direction])
func(currentPoint,iter,ctx,strokelength,length);
if(length>iter++&&functionsrunning[k-1].running){
requestAnimFrame(arguments.callee);}else{
delete functionsrunning[k-1];
}
});
}
fibbonacciWord(1,90040,[50,20],Math.PI/2,"invertedFunction");
(function(){
function $(a){
return document.getElementById(a);
}
function s(d,f,c){
return d.addEventListener(f,c,false);
}
function redooodo(c,match,parent){
return function(e){
var tar=e.target;
while(tar&&tar!=parent){
if(matchElement(tar,match)){c(tar);break;}
tar=tar.parentNode;
}
}
}
function matchElement(element,matcher){
var a;
//console.log("ELEMENT",element)
if(!element)return false;
for(a in matcher){
if(matcher.hasOwnProperty(a)){
if(a=="tagName"){
if(matcher[a].toUpperCase()!==element[a].toUpperCase()){return false;}
}else if(matcher[a]!==element[a]){return false;}
}
}
return true;
}
function doConfirm(msg,butto,call){
var a=makeElem('div'),b=makeElem('div'),c;
a.innerHTML=" "+msg;
for(var i=0,l=butto.length;i<l;i++){
c=makeElem('button');c.appendChild(document.createTextNode(butto[i].content));
s(c,"click",function(f){return function(e){call(butto[f].value);}}(i));
b.appendChild(c);
}
a.appendChild(b);
return a;
}
var body=document.getElementsByTagName('body')[0],lef;
s(body,"click",redooodo(lef=function(element){element.parentNode.removeChild(element);Array.prototype.forEach.call(document.getElementsByClassName('opOS'),function(element){element.parentNode.removeChild(element);})},{className:"opaqueDiv"},body));
s($("draw"),"click",function(){
var len=+$("strl").value||1,iter=+$("it").value||1||10,
coor=[$("coorx").value|0,$("coory").value|0],ang=$("angle").value,f=listfunctions[$("selectoptions").selectedIndex];
if(!isNaN(ang))fibbonacciWord(len,iter,coor,ang*2*Math.PI,f);
});
s($("cls"),'click',function(e){e.preventDefault();var container=makeElem("div",{"class":"alertDiv opOS"}),
opaque=makeElem("div",{"class":"opaqueDiv"}),lol;
body.appendChild(opaque);
body.appendChild(container);
(lol=doConfirm("This will clear the canvas, it will not stop functions from drawing, do you want to continue?",[{content:"Yes",value:true},{content:"No",value:false}],function(agsd){
if(agsd){ctx.clearRect(-.5, -.5, canvas.width, canvas.height);}
lef(opaque);
}));
container.appendChild(lol);
})
s($("Ih8puttingsomanyids"),"click",function(e){var fgsd=makeElem("ul");e.preventDefault();functionsrunning.forEach(function(a){var dis=makeElem('button'),li;dis.appendChild(document.createTextNode("Stop"));s(dis,'click',function(d){a.running=false;console.log(a)});li=makeElem('li');li.innerHTML="<b>id:</b>"+a.id+" <b>function name:</b>"+a.name+" ";li.appendChild(dis);fgsd.appendChild(li);});
console.log(functionsrunning)
var container=makeElem("div",{"class":"containerDiv opOS"}),
opaque=makeElem("div",{"class":"opaqueDiv"});
body.appendChild(opaque);
body.appendChild(container);
container.innerHTML="<div><h3>All functions currently being drawn</h3><p>These are the functions that are being drawn you can chose too disable them if they take too long </p><div>";
container.getElementsByTagName('p')[0].appendChild(fgsd);
});
})()
},false);
</script>
</head>
<body>
<div id="settings">
<b>Settings</b>
<div>
<fieldset>
<legend><b>You can draw it too!</b> <small>(All size values are in pixels)</small></legend>
<ul>
<li><label>Length of the strokes:<input type="number" id="strl" name="st" value="1"/></label></li>
<li><label>Iterations:<input type="number" id="it" value="90"/></label></li>
<li><p>Coordinates: <label>x<input type="number" value="400" id="coorx"></label><label>y<input type="number" value="400" id="coory"></label></p></li>
<li><label>Angle <small>(in circunferences)</small> <input type="number" value='1.125' id="angle"/></label></li>
<li><label>Choose the algorithm that you want to draw: <select id='selectoptions'><option>Fibonacci Word</option><option>Fibonacci Word inverted</option><option>change direction of turns</option><option>fibonacci spiral lineTos</option><option>fibonacci spiral squares</option></select></label></li><br>
<li>See <a href="#" id="Ih8puttingsomanyids">all patterns</a> being drawn.</li>
<li><button id="cls">Clear!</button> <button id="draw">Draw!</button></li>
</ul>
</fieldset>
</div>
</div>
<canvas id="canvas"></canvas>
</body>
</html>