-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
774 lines (714 loc) · 44.6 KB
/
index.html
File metadata and controls
774 lines (714 loc) · 44.6 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TupperTransformer: An Interactive Demo of Tupper's Self-Referential Formula</title>
<!-- Load Tailwind CSS for styling -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Add MathJax for math rendering -->
<script>
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\\[', '\\]']]
}
};
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<style>
/* Keep canvas pixels sharp and crisp when scaled */
canvas {
image-rendering: pixelated;
image-rendering: -moz-crisp-edges;
image-rendering: crisp-edges;
width: 100%;
aspect-ratio: 1060 / 170; /* Use the new native resolution */
background-color: #f0f0f0;
/* Add a border to the canvas itself */
border: 1px solid #ccc;
}
/* Style canvas when draw mode is active */
canvas.draw-mode-active {
cursor: crosshair;
}
/* Simple syntax highlighting for the BibTeX block */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
border-radius: 0.3em;
background: #fdf6e3; /* Solarized Light */
color: #657b83;
}
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #93a1a1; }
.token.punctuation { color: #657b83; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: #cb4b16; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #2aa198; }
.token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string { color: #d33682; }
.token.atrule, .token.attr-value, .token.keyword { color: #859900; }
.token.function, .token.class-name { color: #b58900; }
.token.regex, .token.important, .token.variable { color: #cb4b16; }
/* Styles for the new "tab" buttons */
.tab-button {
@apply w-full font-semibold py-3 px-4 rounded-lg transition-colors shadow-sm text-gray-700 bg-gray-200 hover:bg-gray-300;
}
.tab-button[aria-selected="true"] {
@apply text-white;
}
/* Specific active colors for each tab */
#btnTransformTab[aria-selected="true"] {
@apply bg-indigo-600;
}
#btnLoadTab[aria-selected="true"] {
@apply bg-orange-600;
}
#btnDrawTab[aria-selected="true"] {
@apply bg-green-600;
}
#btnExamplesTab[aria-selected="true"] {
@apply bg-blue-600;
}
/* Add user-select-none to prevent text highlighting when rapidly clicking/holding buttons */
.manual-anim-button {
@apply select-none;
}
#tupper-formula {
cursor: pointer;
transition: background-color 0.2s;
padding: 0.5rem;
}
#tupper-formula:hover {
background-color: #f0f0f0;
border-radius: 0.5rem;
}
/* New styles for the plot */
.plot-container {
display: grid;
grid-template-rows: auto 1fr auto;
gap: 8px;
background-color: #f9f9f9;
border: 1px solid #ccc;
padding: 1rem;
border-radius: 0.5rem;
}
.y-axis-label-top {
text-align: left;
font-size: 0.875rem;
color: #374151;
font-weight: 500;
}
.y-axis-label-bottom {
text-align: left;
font-size: 0.875rem;
color: #374151;
font-weight: 500;
}
.x-axis-label {
text-align: center;
font-size: 0.875rem;
color: #374151;
font-weight: 500;
}
#tupperCanvas {
width: 100%;
height: auto;
}
</style>
</head>
<body class="bg-gray-100 min-h-screen p-4 md:p-8 flex items-center justify-center font-sans">
<div class="bg-white rounded-xl shadow-2xl p-6 md:p-8 w-full max-w-6xl relative">
<!-- GitHub Link -->
<a href="https://github.com/prathameshnium/TupperTransformer" target="_blank" rel="noopener noreferrer" title="View on GitHub" class="absolute top-6 right-6 text-gray-400 hover:text-gray-600 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" viewBox="0 0 16 16">
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"/>
</svg>
</a>
<h1 class="text-3xl md:text-4xl font-bold text-center text-gray-800 mb-2">TupperTransformer</h1>
<p class="text-center text-gray-600 mb-6">
An interactive demo of my Tupper's function transformation algorithm (<a href="https://figshare.com/articles/preprint/Transformation_of_pixels_pdf/6373046/2?file=11711468" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:underline">pre-print from 2018</a>), -Prathamesh Deshmukh.
</p>
<div class="text-center text-gray-600 mb-6 text-lg" id="tupper-formula">
$$ \frac{1}{2} < \left\lfloor \operatorname{mod}\left(\left\lfloor \frac{y}{17} \right\rfloor 2^{-17\lfloor x \rfloor - \operatorname{mod}(\lfloor y \rfloor, 17)}, 2\right) \right\rfloor $$
</div>
<!-- "Read More" Button & Summary Link -->
<div class="text-center mb-6">
<button id="btnReadMore" class="text-blue-600 font-medium hover:underline focus:outline-none">Read more about this project</button>
<!-- NEW LINK to README -->
<span class="mx-2 text-gray-400">|</span>
<a href="https://github.com/prathameshnium/TupperTransformer/blob/main/README.md" target="_blank" rel="noopener noreferrer" class="text-blue-600 font-medium hover:underline focus:outline-none">Quick summary of the paper</a>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8 mt-8">
<!-- Left Column -->
<div class="lg:col-span-2">
<div class="plot-container">
<div class="y-axis-label-top">k+17</div>
<canvas id="tupperCanvas" width="1060" height="170"></canvas>
<div class="flex justify-between">
<div class="y-axis-label-bottom">k</div>
<div class="x-axis-label">x</div>
</div>
</div>
<p class="text-xs text-gray-500 text-center mt-2 italic">
You can also draw directly on the plot to create your own patterns.
</p>
<!-- Transform Controls -->
<div class="mt-6 p-4 border border-gray-200 bg-white rounded-lg">
<h3 class="text-md font-semibold text-gray-800 mb-4 text-center">Transform Pattern</h3>
<!-- Standard Controls -->
<div id="standardTransformControls">
<p class="text-xs text-gray-500 text-center mb-3">Hold buttons to move the pattern on the canvas.</p>
<div class="grid grid-cols-2 gap-2 text-sm">
<button id="btnMoveUp" class="manual-anim-button bg-gray-700 text-white font-semibold py-1 px-3 rounded-md hover:bg-gray-800 transition-colors">Move Up</button>
<button id="btnMoveDown" class="manual-anim-button bg-gray-700 text-white font-semibold py-1 px-3 rounded-md hover:bg-gray-800 transition-colors">Move Down</button>
<button id="btnMoveLeft" class="manual-anim-button bg-gray-700 text-white font-semibold py-1 px-3 rounded-md hover:bg-gray-800 transition-colors">Move Left</button>
<button id="btnMoveRight" class="manual-anim-button bg-gray-700 text-white font-semibold py-1 px-3 rounded-md hover:bg-gray-800 transition-colors">Move Right</button>
<button id="btnMoveDiagUpRight" class="manual-anim-button col-span-2 bg-gray-700 text-white font-semibold py-1 px-3 rounded-md hover:bg-gray-800 transition-colors">Move Diag (Up-Right)</button>
<button id="btnStopManualAnim" class="col-span-2 bg-red-500 text-white font-semibold py-1 px-3 rounded-md hover:bg-red-600 transition-colors hidden">Stop Manual Animation</button>
</div>
</div>
<!-- Tetris Controls -->
<div id="tetrisTransformControls" class="hidden">
<p class="text-xs text-center text-orange-700 mb-3">Use these buttons to move the Tetris piece.</p>
<div class="grid grid-cols-3 gap-2 mt-4 max-w-md mx-auto text-sm">
<button id="btnTetrisMoveLeft" class="w-full bg-gray-700 text-white font-semibold py-1 px-3 rounded-md hover:bg-gray-800 transition-colors">Piece Left</button>
<button id="btnTetrisMoveDown" class="w-full bg-gray-700 text-white font-semibold py-1 px-3 rounded-md hover:bg-gray-800 transition-colors">Piece Down</button>
<button id="btnTetrisMoveRight" class="w-full bg-gray-700 text-white font-semibold py-1 px-3 rounded-md hover:bg-gray-800 transition-colors">Piece Right</button>
</div>
</div>
</div>
<!-- K-Value Input -->
<div class="mt-6">
<label for="k_value" class="block text-sm font-medium text-gray-700">Current K-Value:</label>
<textarea id="k_value" rows="6" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 font-mono text-xs"></textarea>
</div>
</div>
<!-- Right Column (Unified Controls) -->
<div class="lg:col-span-1 space-y-6">
<!-- Clear Canvas Button -->
<button id="btnClearCanvas" class="w-full bg-red-600 text-white font-semibold py-3 px-4 rounded-lg hover:bg-red-700 transition-colors shadow-md">Clear Canvas</button>
<!-- Accordion Item 1: Demos & Examples -->
<div>
<h2 id="accordion-heading-1">
<button type="button" class="accordion-button flex items-center justify-between w-full p-5 font-medium text-left text-gray-700 bg-gray-100 border border-gray-200 rounded-t-xl hover:bg-gray-200" data-accordion-target="#accordion-body-1" aria-expanded="true" aria-controls="accordion-body-1">
<span>1. Demos & Examples</span>
<svg class="w-6 h-6 rotate-180 shrink-0" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
</button>
</h2>
<div id="accordion-body-1" class="p-5 border border-t-0 border-gray-200">
<p class="mb-4 text-sm text-gray-600">Load a pre-defined pattern or watch a demo.</p>
<div class="grid grid-cols-2 gap-3">
<button id="btnLoadTupper" class="w-full bg-gray-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-gray-700 transition-colors shadow-sm">Load Tupper's</button>
<button id="btnLoadUFOCenter" class="w-full bg-gray-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-gray-700 transition-colors shadow-sm">Load UFO (Center)</button>
</div>
<hr class="my-6 border-gray-300">
<div class="p-4 border border-blue-200 bg-blue-50 rounded-lg text-center mb-6">
<h3 class="text-lg font-semibold text-blue-800 mb-4">Animation Demo (Eg3.1)</h3>
<p class="text-blue-700 mb-4 text-sm">Plays the "Top-Left UFO" animation from the paper.</p>
<button id="btnToggleUFOAnim" class="w-full md:w-1/2 bg-blue-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-blue-700 transition-colors shadow-sm">Play UFO Animation</button>
</div>
<div class="p-4 border border-orange-200 bg-orange-50 rounded-lg">
<h3 class="text-lg font-semibold text-orange-800 mb-4 text-center">Interactive Tetris (Eg3.2)</h3>
<div class="text-center mb-4">
<button id="btnLoadTetris" class="w-full md:w-1/2 bg-orange-500 text-white font-semibold py-2 px-4 rounded-md hover:bg-orange-600 transition-colors shadow-sm">Load Tetris Example</button>
</div>
<p class="text-orange-700 mb-4 text-sm text-center">After loading, the transform controls below the canvas will change to Tetris-specific controls.</p>
</div>
<div class="p-4 border border-purple-200 bg-purple-50 rounded-lg text-center mt-6">
<h3 class="text-lg font-semibold text-purple-800 mb-4">Library of Babel</h3>
<p class="text-purple-700 mb-4 text-sm">Continuously generates random K-values.</p>
<button id="btnToggleBabel" class="w-full md:w-1/2 bg-purple-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-purple-700 transition-colors shadow-sm">Start Library of Babel</button>
</div>
</div>
</div>
<!-- Accordion Item 2: Draw -->
<div>
<h2 id="accordion-heading-2">
<button type="button" class="accordion-button flex items-center justify-between w-full p-5 font-medium text-left text-gray-500 border border-gray-200 hover:bg-gray-200" data-accordion-target="#accordion-body-2" aria-expanded="false" aria-controls="accordion-body-2">
<span>2. Draw Your Own</span>
<svg class="w-6 h-6 shrink-0" fill="currentColor" viewBox="0 0 20 20"><path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
</button>
</h2>
<div id="accordion-body-2" class="hidden p-5 border border-t-0 border-gray-200">
<p class="mb-4 text-sm text-gray-600">Drawing is enabled by default. Click the button to disable it.</p>
<button id="btnEnableDraw" class="w-full bg-green-600 text-white font-semibold py-2 px-4 rounded-md hover:bg-green-700 transition-colors shadow-sm">Enable Draw Mode</button>
</div>
</div>
</div>
</div>
<!-- References Section -->
<div class="mt-12 pt-8 border-t border-gray-200">
<h2 class="text-2xl font-bold text-center text-gray-800 mb-6">References</h2>
<ul class="list-disc list-inside space-y-3 max-w-3xl mx-auto text-gray-700 text-center">
<li>
<a href="https://www.petervis.com/mathematics/tuppers_self-referential_formula/tuppers_self-referential_formula.html" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:underline">
Peter Vis: Tupper's Self-Referential Formula
</a>
</li>
<li>
<a href="http://tuppers-formula.tk" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:underline">
Tupper's Formula Tools (tuppers-formula.tk)
</a>
</li>
<li>
<a href="https://youtu.be/_s5RFgd59ao" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:underline">
The "Everything" Formula (YouTube by Numberphile)
</a>
</li>
<li>
<a href="http://campus.lakeforest.edu/trevino/Tupper_Paper.pdf" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:underline">
Tupper's Original Paper (hosted by Lake Forest College)
</a>
</li>
</ul>
</div>
</div>
<!-- "About" Modal -->
<div id="aboutModal" class="fixed inset-0 bg-gray-900 bg-opacity-75 flex items-center justify-center p-4 hidden transition-opacity duration-300 z-50">
<div class="bg-white rounded-xl shadow-2xl p-6 md:p-8 w-full max-w-3xl relative max-h-[90vh] overflow-y-auto">
<!-- Close Button -->
<button id="btnCloseModal" class="absolute top-4 right-5 text-gray-400 hover:text-gray-700 text-3xl font-bold focus:outline-none" title="Close">×</button>
<h2 class="text-2xl font-bold text-gray-800 mb-4">About TupperTransformer</h2>
<h3 class="text-xl font-semibold mt-6 mb-3 text-gray-800">Abstract</h3>
<p class="text-gray-700 mb-4 italic">
"My research idea start with a question that if there is some graphical formation at a particular value of k then what can do to change the graphical formation or to change its position. In his research paper, I have shown that:
</p>
<ul class="list-disc list-inside space-y-2 mb-4 text-gray-700 italic">
<li>How to change any graphical formation into other graphical formation by applying some kind of operation to the value of the k</li>
<li>How can this different graphical formation be used as a frame to create a film/motion picture</li>
</ul>
<h3 class="text-xl font-semibold mt-6 mb-3 text-gray-800">The Core Algorithm (My Original Research)</h3>
<p class="text-gray-700 mb-4">
The technical paper that this project implements is my 2018 preprint, which provides the complete mathematical foundation for these operations.
</p>
<ul class="list-none mb-4 space-y-2 bg-gray-50 p-4 rounded-md border">
<li><strong class="text-gray-800">Paper:</strong> "Transformation of the pixels in Tupper's self-referential formula"</li>
<li><strong class="text-gray-800">Author:</strong> Prathamesh Deshmukh (Me)</li>
<li><strong class="text-gray-800">Publication Date:</strong> May 24, 2018</li>
</ul>
<p class="text-gray-700 mb-4">
The core idea I explored in the paper is that any graphical formation plotted by Tupper's formula (in the $106 \times 17$ grid) can be transformed by applying arithmetic operations directly to the `k` constant.
</p>
<p class="text-gray-700 mb-4">This algorithm allows for precise transformations, including:</p>
<ul class="list-none space-y-4 mb-4 text-gray-700">
<li>
<strong class="text-gray-800 block">Pixel Manipulation:</strong>
Adding or removing any individual pixel `i` by adding or subtracting the value $17 \times 2^{i-1}$ from the `k` constant. (Equation C)
</li>
<li>
<strong class="text-gray-800 block">Spatial Translation (Moving):</strong>
<ul class="list-disc list-inside ml-6 mt-2 space-y-1">
<li><strong>Up/Down:</strong> Moving the entire image `n` pixels up or down by multiplying or dividing `k` by $2^n$.</li>
<li><strong>Left/Right:</strong> Moving the entire image `n` pixels left or right by multiplying or dividing `k` by $2^{n \times 17}$.</li>
</ul>
</li>
</ul>
<h3 class="text-xl font-semibold mt-6 mb-3 text-gray-800">How to Use This Demo</h3>
<ol class="list-decimal list-inside space-y-2 text-gray-700">
<li>Select a mode: Transform & Load, Draw, or Demos & Examples.</li>
<li>The demo will load the relevant example from my paper or a blank canvas.</li>
<li>Use the contextual controls for each mode to transform the image.</li>
<li>See the resulting `k` value and the updated image in real-time.</li>
</Ssol>
<h3 class="text-xl font-semibold mt-6 mb-3 text-gray-800">Citation & Publication History</h3>
<!-- REMOVED iFrame -->
<h4 class="text-lg font-semibold mt-6 mb-2 text-gray-800">BibTeX Citation (Recommended)</h4>
<pre class="language-bibtex rounded-lg"><code>@article{Deshmukh2018,
author = "P Deshmukh",
title = "{Transformation of the pixels in tupper's self-referential formula}",
year = "2018",
month = "6",
url = "https://figshare.com/articles/preprint/Transformation_of_pixels_pdf/6373046",
doi = "10.6084/m9.figshare.6373046.v2"
}</code></pre>
<h4 class="text-lg font-semibold mt-6 mb-2 text-gray-800">Indexing & Archives</h4>
<div class="mt-4 space-y-3">
<div class="bg-gray-50 p-3 rounded-md border">
<p class="font-semibold text-gray-800">Preferred Version (Figshare v2)</p>
<p class="text-sm text-gray-600">Deshmukh, P. (2018). <i>Transformation of the pixels in Tupper's self-referential formula</i>. Figshare. (DOI: 10.6084/m9.figshare.6373046)</p>
<p class="text-sm text-gray-600 mt-1"><strong>First Posted:</strong> June 08, 2018</p>
<a href="https://doi.org/10.6084/m9.figshare.6373046" target="_blank" rel="noopener noreferrer" class="text-blue-600 text-sm hover:underline break-all mt-1 block">https://doi.org/10.6084/m9.figshare.6373046</a>
<!-- NEW: Full Article Link -->
<a href="https://figshare.com/articles/preprint/Transformation_of_pixels_pdf/6373046/2?file=11711468" target="_blank" rel="noopener noreferrer" class="text-green-700 text-sm font-semibold hover:underline mt-2 block">
→ Access the full article here
</a>
</div>
<div class="bg-gray-50 p-3 rounded-md border">
<p class="font-semibold text-gray-800">Semantic Scholar Index</p>
<a href="https://www.semanticscholar.org/paper/Transformation-of-the-Pixels-in-Tupper's-Formula-Deshmukh/f7f02b429a5fcdc20a29410226c73eecaf992541" target="_blank" rel="noopener noreferrer" class="text-blue-600 text-sm hover:underline break-all">https://www.semanticscholar.org/paper/Transformation-of-the-Pixels-in-Tupper's-Formula-Deshmukh/f7f02b429a5fcdc20a29410226c73eecaf992541</a>
</div>
<div class="bg-gray-50 p-3 rounded-md border">
<p class="font-semibold text-gray-800">Internet Archive (Archive of v1)</p>
<a href="https://web.archive.org/web/20200220095114/https://s3-eu-west-1.amazonaws.com/pfigshare-u-files/11711468/Transformation_of_pixels.pdf" target="_blank" rel="noopener noreferrer" class="text-blue-600 text-sm hover:underline break-all">httpsE://web.archive.org/web/20200220095114/https://s3-eu-west-1.amazonaws.com/pfigshare-u-files/11711468/Transformation_of_pixels.pdf</a>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// --- Accordion Logic ---
const accordionButtons = document.querySelectorAll('.accordion-button');
accordionButtons.forEach(button => {
button.addEventListener('click', () => {
const isExpanded = button.getAttribute('aria-expanded') === 'true';
// Close all accordion bodies
accordionButtons.forEach(b => {
b.setAttribute('aria-expanded', 'false');
document.querySelector(b.dataset.accordionTarget).classList.add('hidden');
b.querySelector('svg').classList.remove('rotate-180');
});
// Open the clicked one if it was closed
if (!isExpanded) {
button.setAttribute('aria-expanded', 'true');
document.querySelector(button.dataset.accordionTarget).classList.remove('hidden');
button.querySelector('svg').classList.add('rotate-180');
}
});
});
// --- Canvas & K-Value Elements ---
const canvas = document.getElementById('tupperCanvas');
const ctx = canvas.getContext('2d');
const textarea = document.getElementById('k_value');
const yAxisLabelTop = document.querySelector('.y-axis-label-top');
const yAxisLabelBottom = document.querySelector('.y-axis-label-bottom');
// --- Modal Elements ---
const btnReadMore = document.getElementById('btnReadMore');
const aboutModal = document.getElementById('aboutModal');
const btnCloseModal = document.getElementById('btnCloseModal');
const tupperFormula = document.getElementById('tupper-formula');
// --- Control Containers ---
const standardTransformControls = document.getElementById('standardTransformControls');
const tetrisTransformControls = document.getElementById('tetrisTransformControls');
// --- Control Buttons ---
const btnLoadTupper = document.getElementById('btnLoadTupper');
const btnLoadUFOCenter = document.getElementById('btnLoadUFOCenter');
const btnEnableDraw = document.getElementById('btnEnableDraw');
const btnClearCanvas = document.getElementById('btnClearCanvas');
const btnToggleUFOAnim = document.getElementById('btnToggleUFOAnim');
const btnToggleBabel = document.getElementById('btnToggleBabel');
const btnLoadTetris = document.getElementById('btnLoadTetris');
const btnTetrisMoveLeft = document.getElementById('btnTetrisMoveLeft');
const btnTetrisMoveRight = document.getElementById('btnTetrisMoveRight');
const btnTetrisMoveDown = document.getElementById('btnTetrisMoveDown');
const btnMoveUp = document.getElementById('btnMoveUp');
const btnMoveDown = document.getElementById('btnMoveDown');
const btnMoveLeft = document.getElementById('btnMoveLeft');
const btnMoveRight = document.getElementById('btnMoveRight');
const btnMoveDiagUpRight = document.getElementById('btnMoveDiagUpRight');
const manualAnimButtons = [btnMoveUp, btnMoveDown, btnMoveLeft, btnMoveRight, btnMoveDiagUpRight];
const btnStopManualAnim = document.getElementById('btnStopManualAnim');
// --- Constants ---
const GRID_WIDTH = 106;
const GRID_HEIGHT = 17;
const PIXEL_SCALE = 10;
const H_BIGINT = BigInt(GRID_HEIGHT);
const OFF_PIXEL_COLOR = '#f0f0f0';
const ON_PIXEL_COLOR = '#000000';
const GRID_COLOR = '#ccc';
const ANIMATION_SPEED = 150;
const LATCH_TIME = 500;
const TUPPER_K = 4858450636189713423582095962494202044581400587983244549483093085061934704708809928450644769865524364849997247024915119110411605739177407856919754326571855442057210445735883681829823754139634338225199452191651284348332905131193199953502413758765239264874613394906870130562295813219481113685339535565290850023875092856892694555974281546386510730049106723058933586052544096664351265349363643957125565695936815184334857605266940161251266951421550539554519153785457525756590740540157929001765967965480064427829131488548259914721248506352686630476300n;
const UFO_CENTER_K = 443352924415299750269935582831006891736908292088519263818614474851967119874782775886465719557549939463756309785941884807127269950858601139076519485343718480093603142421094905794300356122213456551693296459008206217500505569300664030340014779960166914732789553875507120518890769928117177323414356728568578317831865211788253557426913017856n;
const UFO_TOP_LEFT_K = 3364095144409490406402517685013936223230541008369211472154153567830130294784n;
const KR_BIGINT = 1465173377163840840964195200776229452338097479160165100993321673778726174973516467105018733852068234022255298658975702245055915087238316041012593947856673785182723705258476099103213618090667396472262335593747367067648n;
const KS_BIGINT = 42640449639783743164699946138133627753613984093735772109827003226441916669711823327553649089932323504047296961434448619137954569794030245783793507114789257497126216466424824493834668782237110139139800432640n;
// --- State ---
let ufoAnimationInterval = null;
let babelAnimationInterval = null;
let manualAnimationInterval = null;
let manualAnimationTimer = null;
let isManualAnimationLatched = false;
let currentTetrisPieceK = 0n;
let isDrawing = false;
let drawnPixels = new Set();
let currentK = 0n;
// --- Core Functions ---
function drawGrid(k) {
if (typeof k !== 'bigint') {
console.error("drawGrid requires a BigInt");
return;
}
currentK = k;
ctx.clearRect(0, 0, canvas.width, canvas.height);
const k_div_17 = k / H_BIGINT;
ctx.strokeStyle = GRID_COLOR;
ctx.lineWidth = 1;
for (let x = 0; x < GRID_WIDTH; x++) {
for (let y = 0; y < GRID_HEIGHT; y++) {
const bit_position = BigInt(x * GRID_HEIGHT + y);
const bit = (k_div_17 >> bit_position) & 1n;
const drawX = x * PIXEL_SCALE;
const drawY = (GRID_HEIGHT - 1 - y) * PIXEL_SCALE;
if (bit === 1n) {
ctx.fillStyle = ON_PIXEL_COLOR;
ctx.fillRect(drawX, drawY, PIXEL_SCALE, PIXEL_SCALE);
}
ctx.strokeRect(drawX, drawY, PIXEL_SCALE, PIXEL_SCALE);
}
}
}
function getCurrentK() {
try {
const k_string = textarea.value.replace(/\s/g, '').replace('n', '');
if (k_string === "") return 0n;
return BigInt(k_string);
} catch (e) {
alert("Invalid K-Value. It must be a valid (very large) integer.");
return null;
}
}
function updateK(newK) {
textarea.value = newK.toString();
currentK = newK;
yAxisLabelTop.textContent = 'k+17';
yAxisLabelBottom.textContent = 'k';
}
// --- Debounce for manual input ---
let debounceTimer;
textarea.addEventListener('input', () => {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => {
const k = getCurrentK();
if (k !== null) {
drawGrid(k);
}
}, 300);
});
function stopAllAnimations() {
if (ufoAnimationInterval) clearInterval(ufoAnimationInterval);
ufoAnimationInterval = null;
if (babelAnimationInterval) clearInterval(babelAnimationInterval);
babelAnimationInterval = null;
btnToggleUFOAnim.textContent = "Play UFO Animation";
btnToggleBabel.textContent = "Start Library of Babel";
forceStopManualAnimation();
standardTransformControls.classList.remove('hidden');
tetrisTransformControls.classList.add('hidden');
}
// --- Modal ---
btnReadMore.addEventListener('click', () => aboutModal.classList.remove('hidden'));
btnCloseModal.addEventListener('click', () => aboutModal.classList.add('hidden'));
aboutModal.addEventListener('click', (e) => {
if (e.target === aboutModal) aboutModal.classList.add('hidden');
});
tupperFormula.addEventListener('click', () => {
btnLoadTupper.click();
});
// --- Control Logic ---
btnLoadTupper.addEventListener('click', () => {
stopAllAnimations();
standardTransformControls.classList.remove('hidden');
tetrisTransformControls.classList.add('hidden');
updateK(TUPPER_K);
drawGrid(TUPPER_K);
});
btnLoadUFOCenter.addEventListener('click', () => {
stopAllAnimations();
standardTransformControls.classList.remove('hidden');
tetrisTransformControls.classList.add('hidden');
updateK(UFO_CENTER_K);
drawGrid(UFO_CENTER_K);
});
// --- Draw Mode ---
function setDrawMode(enabled) {
isDrawing = false;
if (enabled) {
canvas.classList.add('draw-mode-active');
btnEnableDraw.textContent = 'Disable Draw Mode';
btnEnableDraw.classList.remove('bg-green-600', 'hover:bg-green-700');
btnEnableDraw.classList.add('bg-red-500', 'hover:bg-red-600');
} else {
canvas.classList.remove('draw-mode-active');
btnEnableDraw.textContent = 'Enable Draw Mode';
btnEnableDraw.classList.remove('bg-red-500', 'hover:bg-red-600');
btnEnableDraw.classList.add('bg-green-600', 'hover:bg-green-700');
}
}
btnEnableDraw.addEventListener('click', () => {
const isDrawActive = canvas.classList.contains('draw-mode-active');
setDrawMode(!isDrawActive);
});
btnClearCanvas.addEventListener('click', () => {
stopAllAnimations();
standardTransformControls.classList.remove('hidden');
tetrisTransformControls.classList.add('hidden');
updateK(0n);
drawGrid(0n);
});
// --- Demos ---
btnToggleUFOAnim.addEventListener('click', () => {
if (ufoAnimationInterval) {
stopAllAnimations();
} else {
stopAllAnimations();
let tempK = UFO_TOP_LEFT_K;
updateK(tempK);
drawGrid(tempK);
ufoAnimationInterval = setInterval(() => {
tempK *= (2n ** H_BIGINT);
updateK(tempK);
drawGrid(tempK);
}, 300);
btnToggleUFOAnim.textContent = "Stop Animation";
}
});
btnLoadTetris.addEventListener('click', () => {
stopAllAnimations();
standardTransformControls.classList.add('hidden');
tetrisTransformControls.classList.remove('hidden');
currentTetrisPieceK = KS_BIGINT;
const totalK = KR_BIGINT + currentTetrisPieceK;
updateK(totalK);
drawGrid(totalK);
});
btnTetrisMoveLeft.addEventListener('click', () => {
currentTetrisPieceK /= (2n ** H_BIGINT);
drawGrid(KR_BIGINT + currentTetrisPieceK);
});
btnTetrisMoveRight.addEventListener('click', () => {
currentTetrisPieceK *= (2n ** H_BIGINT);
drawGrid(KR_BIGINT + currentTetrisPieceK);
});
btnTetrisMoveDown.addEventListener('click', () => {
currentTetrisPieceK /= 2n;
drawGrid(KR_BIGINT + currentTetrisPieceK);
});
function getRandomK() {
let k_string = '';
const num_digits = 537;
for (let i = 0; i < num_digits; i++) {
k_string += Math.floor(Math.random() * 10);
}
return BigInt(k_string);
}
btnToggleBabel.addEventListener('click', () => {
if (babelAnimationInterval) {
stopAllAnimations();
} else {
stopAllAnimations();
babelAnimationInterval = setInterval(() => {
const randomK = getRandomK();
updateK(randomK);
drawGrid(randomK);
}, 200);
btnToggleBabel.textContent = "Stop Library of Babel";
}
});
// --- Manual Transform ---
function startManualAnimation(transformFunction) {
stopAllAnimations();
isManualAnimationLatched = false;
let k = getCurrentK();
if (k === null) return;
k = transformFunction(k);
updateK(k);
drawGrid(k);
manualAnimationInterval = setInterval(() => {
k = transformFunction(getCurrentK());
k = transformFunction(k);
updateK(k);
drawGrid(k);
}, ANIMATION_SPEED);
manualAnimationTimer = setTimeout(() => {
isManualAnimationLatched = true;
btnStopManualAnim.classList.remove('hidden');
}, LATCH_TIME);
}
function stopManualAnimation() {
if (isManualAnimationLatched) return;
if (manualAnimationInterval) clearInterval(manualAnimationInterval);
if (manualAnimationTimer) clearTimeout(manualAnimationTimer);
manualAnimationInterval = null;
manualAnimationTimer = null;
}
function forceStopManualAnimation() {
if (manualAnimationInterval) clearInterval(manualAnimationInterval);
if (manualAnimationTimer) clearTimeout(manualAnimationTimer);
manualAnimationInterval = null;
manualAnimationTimer = null;
isManualAnimationLatched = false;
btnStopManualAnim.classList.add('hidden');
}
const transformUp = (k) => k * 2n;
const transformDown = (k) => k / 2n;
const transformLeft = (k) => k / (2n ** H_BIGINT);
const transformRight = (k) => k * (2n ** H_BIGINT);
const transformDiag = (k) => (k * (2n ** H_BIGINT)) * 2n;
const stopEvents = ['mouseup', 'mouseleave', 'touchend'];
btnMoveUp.addEventListener('mousedown', () => startManualAnimation(transformUp));
btnMoveUp.addEventListener('touchstart', (e) => { e.preventDefault(); startManualAnimation(transformUp); });
btnMoveDown.addEventListener('mousedown', () => startManualAnimation(transformDown));
btnMoveDown.addEventListener('touchstart', (e) => { e.preventDefault(); startManualAnimation(transformDown); });
btnMoveLeft.addEventListener('mousedown', () => startManualAnimation(transformLeft));
btnMoveLeft.addEventListener('touchstart', (e) => { e.preventDefault(); startManualAnimation(transformLeft); });
btnMoveRight.addEventListener('mousedown', () => startManualAnimation(transformRight));
btnMoveRight.addEventListener('touchstart', (e) => { e.preventDefault(); startManualAnimation(transformRight); });
btnMoveDiagUpRight.addEventListener('mousedown', () => startManualAnimation(transformDiag));
btnMoveDiagUpRight.addEventListener('touchstart', (e) => { e.preventDefault(); startManualAnimation(transformDiag); });
manualAnimButtons.forEach(button => {
stopEvents.forEach(event => button.addEventListener(event, stopManualAnimation));
});
btnStopManualAnim.addEventListener('click', forceStopManualAnimation);
// --- Canvas Drawing ---
function handleDraw(event) {
if (!canvas.classList.contains('draw-mode-active')) return;
const rect = canvas.getBoundingClientRect();
const scaleX = canvas.width / rect.width;
const scaleY = canvas.height / rect.height;
let clientX, clientY;
if (event.touches) {
clientX = event.touches[0].clientX;
clientY = event.touches[0].clientY;
} else {
clientX = event.clientX;
clientY = event.clientY;
}
const x_canvas = (clientX - rect.left) * scaleX;
const y_canvas = (clientY - rect.top) * scaleY;
const x = Math.floor(x_canvas / PIXEL_SCALE);
const y = (GRID_HEIGHT - 1) - Math.floor(y_canvas / PIXEL_SCALE);
if (x < 0 || x >= GRID_WIDTH || y < 0 || y >= GRID_HEIGHT) return;
const pixelKey = `${x},${y}`;
if (isDrawing && drawnPixels.has(pixelKey)) return;
drawnPixels.add(pixelKey);
const bit_position = BigInt(x * GRID_HEIGHT + y);
const value_to_change = H_BIGINT * (2n ** bit_position);
const k_div_17 = getCurrentK() / H_BIGINT;
const bit = (k_div_17 >> bit_position) & 1n;
const newK = (bit === 1n) ? getCurrentK() - value_to_change : getCurrentK() + value_to_change;
updateK(newK);
drawGrid(newK);
}
function startDrawing(e) {
if (!canvas.classList.contains('draw-mode-active')) return;
e.preventDefault();
isDrawing = true;
drawnPixels.clear();
handleDraw(e);
}
function draw(e) {
if (!isDrawing || !canvas.classList.contains('draw-mode-active')) return;
e.preventDefault();
handleDraw(e);
}
function stopDrawing(e) {
if (!canvas.classList.contains('draw-mode-active')) return;
e.preventDefault();
isDrawing = false;
drawnPixels.clear();
}
canvas.addEventListener('mousedown', startDrawing);
canvas.addEventListener('mousemove', draw);
canvas.addEventListener('mouseup', stopDrawing);
canvas.addEventListener('mouseleave', stopDrawing);
canvas.addEventListener('touchstart', startDrawing);
canvas.addEventListener('touchmove', draw);
canvas.addEventListener('touchend', stopDrawing);
canvas.addEventListener('touchcancel', stopDrawing);
// --- Initial Load ---
updateK(UFO_CENTER_K);
drawGrid(UFO_CENTER_K);
setDrawMode(true);
});
</script>