-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
690 lines (668 loc) · 37.7 KB
/
index.html
File metadata and controls
690 lines (668 loc) · 37.7 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
<!DOCTYPE html> <!-- May 2021 - RoccoLox Programs -->
<!--
Thank you epsilon5. This wouldn't exist without you.
Thank you Zeroko for your rgb1555 to rgb888 (and vice versa) conversion code.
Thank you to anyone else who suggested features and has used this program.
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>1555 Color Picker</title>
<style type="text/css">
body {
background-color: rgb(243,243,243);
}
div.table {
display: flex;
border-width: 1px;
margin: 10px auto;
width: auto;
background-color: #000000;
border: solid black 1px;
height: fit-content;
justify-content: center;
border-radius: 5px;
}
div.osColors {
display: flex;
padding: 1px;
width: 100%;
justify-content: center;
align-items: center;
color: #ffffff;
font-family: sans-serif;
font-weight: bold;
cursor: pointer;
height: 35px;
}
h1 {
margin: 5px 0px 0px 0px;
text-align: center;
font-size: 250%;
font-family: sans-serif;
font-weight: normal;
text-decoration: underline;
}
h3 {
color: #000000;
margin: 0px;
cursor: pointer;
}
p {
text-align: center;
font-weight: bold;
font-size: 200%;
padding: 8%;
font-family: sans-serif;
margin: 20px auto 35px auto;
}
p#colorView {
border-radius: 5px;
}
footer {
background-color: rgb(243,243,243);
bottom: 0px;
left: 0px;
position: fixed;
width: 100%;
}
a {
text-decoration: none;
color: #0179f9;
font-family: sans-serif;
font-size: 110%;
padding: 0px 5px 5px 5px;
}
input {
border-radius: 5px;
border-width: 1px;
}
input:focus {
outline-width: 0px;
}
input.numberValue {
padding: inherit;
font-size: 100%;
text-align: center;
}
input.textValue {
padding: inherit;
font-size: 100%;
text-align: center;
width: 140px;
}
h3.modeDisplay {
float: left;
padding-left: 5px;
cursor: text;
}
/* slider styling */
.colorSlider {
-webkit-appearance: none;
appearance: none;
width: 100%;
height: 20px;
border-radius: 10px;
background: rgb(150,150,150);
outline: none;
opacity: 0.7;
-webkit-transition: .3s;
transition: opacity .3s;
}
.colorSlider:hover {
opacity: 1;
}
.colorSlider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 30px;
height: 30px;
border-radius: 50%;
border: 1px white solid;
background: #000000;
cursor: pointer;
}
.colorSlider::-moz-range-thumb {
width: 30px;
height: 30px;
border-radius: 50%;
background: #000000;
cursor: pointer;
}
/* switch styling */
.switch {
position: relative;
display: inline-block;
width: 48px;
height: 22px;
}
.switch input {
opacity: 0;
width: 0px;
height: 0px;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: #bebebe;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 16px;
width: 16px;
left: 4px;
bottom: 3px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider:before {
-webkit-transform: translateX(24px);
-ms-transform: translateX(24px);
transform: translateX(24px);
}
.slider.round {
border-radius: 22px;
}
.slider.round:before {
border-radius: 50%;
}
/* button styling */
.customPalette {
margin-top: 5px;
background-color: #bebebe;
color: #000000;
padding: 8px;
font-family: sans-serif;
border-radius: 5px;
cursor: pointer;
font-size: 55%;
border: hidden;
font-weight: bold;
}
.copyButtons {
padding: 5px 15px;
margin: 0px;
font-size: 75%;
}
/* dropdown box styling */
.dropdown {
position: relative;
display: inline-block;
}
.dropdownButtons {
display: none;
position: absolute;
border-radius: 5px;
box-shadow: 3px 3px 5px 2px #666666;
width: fit-content;
padding: 8px;
top: 110%;
z-index: 1;
left: 50%;
transform: translateX(-50%);
}
.dropdownButtons input {
display: block;
width: 100%;
margin-bottom: 5px;
}
.show {
display: block;
}
</style>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ZQ45HCDQNB"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ZQ45HCDQNB');
</script>
<script type="text/javascript">
function updateValues(red, green, blue, color1555) {
var paletteValue;
document.getElementById("1555slider").value = color1555;
c1555 = parseInt(color1555).toString(16).toUpperCase(); // get the 1555/565 hex value
document.getElementById("1555userValue").value = '000'.substr(0, 4 - c1555.length) + c1555;
// make sure the length is 6
if (c1555.length == 1) c1555 = '0x000' + c1555;
else if (c1555.length == 2) c1555 = '0x00' + c1555;
else if (c1555.length == 3) c1555 = '0x0' + c1555;
else if (c1555.length == 4) c1555 = '0x' + c1555;
if (colorMode565) {
var red1555 = ((((color1555 >> 11) & 0x1F) * 527) + 23) >> 6;
var green1555 = ((((color1555 >> 5) & 0x3F) * 259) + 33) >> 6;
var blue1555 = (((color1555 & 0x1F) * 527) + 23) >> 6;
paletteValue = RGBto1555(red1555, green1555, blue1555);
paletteValue = parseInt(paletteValue).toString(16).toUpperCase(); // get the 1555 hex value
if (paletteValue.length == 1) paletteValue = '0x000' + paletteValue;
else if (paletteValue.length == 2) paletteValue = '0x00' + paletteValue;
else if (paletteValue.length == 3) paletteValue = '0x0' + paletteValue;
else if (paletteValue.length == 4) paletteValue = '0x' + paletteValue;
} else {
paletteValue = c1555;
}
var pal1 = paletteValue.substring(4,6); // first palette color
var pal2 = paletteValue.substring(0,4); // second palette color
// find the hex value for the rgb color
var redHex = parseInt(red).toString(16).toUpperCase();
var greenHex = parseInt(green).toString(16).toUpperCase();
var blueHex = parseInt(blue).toString(16).toUpperCase();
// update values and redisplay them
document.getElementById("redUserValue").value = red;
document.getElementById("greenUserValue").value = green;
document.getElementById("blueUserValue").value = blue;
if (!colorMode565) {
document.getElementById("1555hexValue").innerHTML = `1555: ${c1555} Palette: 0x${pal1}, ${pal2}`;
let tempVar = parseInt(c1555.substr(2, 4), 16);
let tempRed = Math.round((tempVar >> 10 & 31) * 255 / 31);
let tempGreen = Math.round((tempVar >> 15 & 1 | tempVar >> 4 & 62) * 255 / 63);
let tempBlue = Math.round((tempVar & 31) * 255 / 31);
tempVar = RGBto565(tempRed, tempGreen, tempBlue);
tempVar = tempVar.toString(16).toUpperCase();
if (tempVar.length == 1) tempVar = '0x000' + tempVar;
else if (tempVar.length == 2) tempVar = '0x00' + tempVar;
else if (tempVar.length == 3) tempVar = '0x0' + tempVar;
else if (tempVar.length == 4) tempVar = '0x' + tempVar;
hiByte = parseInt(tempVar.substr(2, 2), 16);
loByte = parseInt(tempVar.substr(4, 2), 16);
document.getElementById("celticUserValLo").value = loByte;
document.getElementById("celticUserValHi").value = hiByte;
copyCeltic = loByte + ", " + hiByte;
} else {
document.getElementById("1555hexValue").innerHTML = `565: ${c1555} Palette: 0x${pal1}, ${pal2}`;
hiByte = parseInt(c1555.substr(2, 2), 16);
loByte = parseInt(c1555.substr(4, 2), 16);
document.getElementById("celticUserValLo").value = loByte;
document.getElementById("celticUserValHi").value = hiByte;
copyCeltic = loByte + ", " + hiByte;
}
copy1555 = c1555;
if (!colorMode565) {
red = Math.round((color1555 >> 10 & 31) * 255 / 31);
green = Math.round((color1555 >> 15 & 1 | color1555 >> 4 & 62) * 255 / 63);
blue = Math.round((color1555 & 31) * 255 / 31);
} else {
red = ((((color1555 >> 11) & 0x1F) * 527) + 23) >> 6;
green = ((((color1555 >> 5) & 0x3F) * 259) + 33) >> 6;
blue = (((color1555 & 0x1F) * 527) + 23) >> 6;
}
// update the color box
if (localStorage.getItem("RLP_1555ColorPicker_mode_052920") == "dark") document.getElementById("colorView").setAttribute("style",`background-color: rgb(${red}, ${green}, ${blue}); border-color: #ffffff; border-width: thin; border-style: solid;`);
else document.getElementById("colorView").setAttribute("style",`background-color: rgb(${red}, ${green}, ${blue}); border-color: #000000; border-width: thin; border-style: solid;`);
copyRGB = "r: " + red + ", g: " + green + ", b: " + blue;
// update the hex value box
if (redHex.length == 1) redHex = '0' + redHex;
if (greenHex.length == 1) greenHex = '0' + greenHex;
if (blueHex.length == 1) blueHex = '0' + blueHex;
document.getElementById("hexUserValue").value = redHex + greenHex + blueHex;
copyHex = redHex + greenHex + blueHex;
}
function OScolor(r, g, b, rgb1555, rgb565) {
red = r;
green = g;
blue = b;
if (!colorMode565) c1555 = rgb1555;
else c1555 = rgb565;
updateValues(red, green, blue, c1555);
}
function RGBto1555(r, g, b) { // convert the rgb888 to rgb1555
var scaledGreen = Math.round(g * 63 / 255);
var rgb1555 = (Math.round(r * 31 / 255) << 10) | (scaledGreen << 15 & 0x8000) | (scaledGreen << 4 & 0x03E0) | Math.round(b * 31 / 255);
return rgb1555;
}
function RGBto565(r, g, b) { // convert rgb888 to rgb565
var rgb565 = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
return rgb565;
}
function changeRGBmode() {
if (colorMode565) {
colorMode565 = false;
document.getElementById('rgbMode').innerHTML = "1555 Mode ";
c1555 = RGBto1555(red, green, blue);
} else {
colorMode565 = true;
document.getElementById('rgbMode').innerHTML = "565 Mode ";
c1555 = RGBto565(red, green, blue);
}
updateValues(red, green, blue, c1555);
}
function changeMode() {
if (localStorage.getItem("RLP_1555ColorPicker_mode_052920") == 'light') { // change mode
localStorage.setItem("RLP_1555ColorPicker_mode_052920","dark");
darkMode();
} else {
localStorage.setItem("RLP_1555ColorPicker_mode_052920","light");
lightMode();
}
}
function lightMode() {
document.getElementById("body").setAttribute("style","background-color: rgb(243,243,243);"); // chanhe background
document.getElementsByTagName("footer")[0].setAttribute("style","background-color: rgb(243,243,243);"); // change footer background
document.getElementById('changeColorPicker').setAttribute('style','font-size: 100%; margin: 0px 0px 15px 0px; padding: 0px; font-weight: normal; color: #000000;');
document.getElementById("OSColors").setAttribute("style","border: solid black thin; background-color: #000000;"); // change border color
document.getElementById("TI").setAttribute("style","font-size: 170%; font-family: sans-serif; font-weight: bold; text-align: center; margin: 5px 0px; padding: 0px;"); // change text color
document.getElementById("1555hexValue").setAttribute("style","font-size: 175%; padding: 0px; margin: 5px; color: #000000;");
document.getElementById("colorView").setAttribute("style",`background-color: rgb(${red}, ${green}, ${blue}); border: solid black thin;`);
document.getElementById("userInput").setAttribute("style","padding: 0px; margin: unset; font-size: 150%; color: #000000;");
document.getElementById("title").setAttribute("style","color: #000000;"); // change text color
document.getElementById("mode").setAttribute("style","color: #000000;");
document.getElementById("rgbMode").setAttribute("style","color: #000000;");
document.getElementById("copyright").setAttribute("style","color: #808080; float: right; padding-left: 5px;");
document.getElementById("mode").innerHTML = 'Light Mode '; // change option
document.getElementById("dropdownBox").setAttribute("style","background-color: rgb(243,243,243); border: solid black 1px;");
document.getElementById("breakLine").setAttribute("style","color: #000000; float: right; cursor: default;");
}
function darkMode() {
document.getElementById("body").setAttribute("style","background-color: rgb(40,40,40);"); // chanhe background
document.getElementsByTagName("footer")[0].setAttribute("style","background-color: rgb(40,40,40);"); // change footer background
document.getElementById('changeColorPicker').setAttribute('style','font-size: 100%; margin: 0px 0px 15px 0px; padding: 0px; font-weight: normal; color: #ffffff;');
document.getElementById("OSColors").setAttribute("style","border: solid white thin; background-color: #ffffff;"); // change border color
document.getElementById("TI").setAttribute("style","font-size: 170%; font-family: sans-serif; font-weight: bold; text-align: center; margin: 5px 0px; padding: 0px; color: #ffffff;"); // change text color
document.getElementById("1555hexValue").setAttribute("style","font-size: 175%; padding: 0px; margin: 5px; color: #ffffff;");
document.getElementById("colorView").setAttribute("style",`background-color: rgb(${red}, ${green}, ${blue}); border: solid white thin;`);
document.getElementById("userInput").setAttribute("style","padding: 0px; margin: unset; font-size: 150%; color: #ffffff;");
document.getElementById("title").setAttribute("style","color: #ffffff;"); // change text color
document.getElementById("mode").setAttribute("style","color: #ffffff;");
document.getElementById("rgbMode").setAttribute("style","color: #ffffff;");
document.getElementById("copyright").setAttribute("style","color: #b3b3b3; float: right; padding-left: 5px;");
document.getElementById("mode").innerHTML = 'Dark Mode '; // change option
document.getElementById("dropdownBox").setAttribute("style","background-color: rgb(40,40,40); border: solid white 1px;");
document.getElementById("breakLine").setAttribute("style","color: #ffffff; float: right; cursor: default;");
}
function hover(n, r, g, b) {
onMouseOut(); // remove the hover box
// draw new hover box
if (n < 10 || n > 13) document.getElementsByTagName('div')[n].setAttribute("style",`background-color: rgb(${r}, ${g}, ${b}); border: solid white 1px; padding: 0px; color: #ffffff;`);
else document.getElementsByTagName('div')[n].setAttribute("style",`background-color: rgb(${r}, ${g}, ${b}); border: solid black 1px; padding: 0px; color: #000000;`);
// update values
oldn = n;
oldr = r;
oldg = g;
oldb = b;
}
function onMouseOut() { // when not over a table, remove the hover box
if (oldn < 10 || oldn > 13) document.getElementsByTagName('div')[oldn].setAttribute("style",`background-color: rgb(${oldr}, ${oldg}, ${oldb});`);
else document.getElementsByTagName('div')[oldn].setAttribute("style",`background-color: rgb(${oldr}, ${oldg}, ${oldb}); color: #000000;`);
}
function selectAll(id) {
document.getElementById(id).select();
}
function dropdownButtons(buttonNumber) {
document.getElementById("dropdownBox").classList.toggle("show");
if (buttonNumber == 0) return;
if (buttonNumber == 1) {
let copyValue = copy1555;
if (colorMode565) {
color1555 = parseInt(copy1555.substr(2, 4), 16);
red = ((((color1555 >> 11) & 0x1F) * 527) + 23) >> 6;
green = ((((color1555 >> 5) & 0x3F) * 259) + 33) >> 6;
blue = (((color1555 & 0x1F) * 527) + 23) >> 6;
color1555 = RGBto1555(red, green, blue);
copyValue = parseInt(color1555).toString(16).toUpperCase();
// make sure the length is 6
if (copyValue.length == 1) copyValue = '0x000' + copyValue;
else if (copyValue.length == 2) copyValue = '0x00' + copyValue;
else if (copyValue.length == 3) copyValue = '0x0' + copyValue;
else if (copyValue.length == 4) copyValue = '0x' + copyValue;
}
navigator.clipboard.writeText(copyValue);
} else if (buttonNumber == 2) {
let copyValue = copy1555;
if (!colorMode565) {
color1555 = parseInt(copy1555.substr(2, 4), 16);
red = Math.round((color1555 >> 10 & 31) * 255 / 31);
green = Math.round((color1555 >> 15 & 1 | color1555 >> 4 & 62) * 255 / 63);
blue = Math.round((color1555 & 31) * 255 / 31);
color1555 = RGBto565(red, green, blue);
copyValue = parseInt(color1555).toString(16).toUpperCase();
// make sure the length is 6
if (copyValue.length == 1) copyValue = '0x000' + copyValue;
else if (copyValue.length == 2) copyValue = '0x00' + copyValue;
else if (copyValue.length == 3) copyValue = '0x0' + copyValue;
else if (copyValue.length == 4) copyValue = '0x' + copyValue;
}
navigator.clipboard.writeText(copyValue);
} else if (buttonNumber == 3) {
navigator.clipboard.writeText(copyHex);
} else if (buttonNumber == 4) {
navigator.clipboard.writeText(copyRGB);
} else if (buttonNumber == 5) {
navigator.clipboard.writeText(copyCeltic);
}
}
window.onclick = function(event) {
if (!event.target.matches('.copyButtons')) {
let dropdowns = document.getElementsByClassName("dropdownButtons");
for (let i = 0; i < dropdowns.length; i++) {
let openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
function info() { // short description
alert("1555 Color Picker\nBy RoccoLox Programs\nVersion: 1.7\nDate: 2023-04-18\nLicense: BSD 3-Clause License\nDescription: 1555 color picker for C and Assembly programmers on the TI-84 Plus CE.");
}
</script>
</head>
<body id="body">
<label class="switch" style="float: left;">
<input type="checkbox" id="switch" onclick="changeMode()">
<span class="slider round"></span>
</label>
<h3 id="mode" class="modeDisplay">Light Mode </h3>
<label class="switch" style="float: left;">
<input type="checkbox" onclick="changeRGBmode()">
<span class="slider round"></span>
</label>
<h3 id="rgbMode" class="modeDisplay">1555 Mode </h3>
<section class="dropdown">
<input type="button" value="Copy Values" class="customPalette copyButtons" onclick="dropdownButtons(0)">
<section id="dropdownBox" class="dropdownButtons" style="background-color: rgb(243,243,243); border: solid black 1px;">
<input type="button" value="Copy 1555" class="customPalette copyButtons" onclick="dropdownButtons(1)">
<input type="button" value="Copy 565" class="customPalette copyButtons" onclick="dropdownButtons(2)">
<input type="button" value="Copy 24b Hex" class="customPalette copyButtons" onclick="dropdownButtons(3)">
<input type="button" value="Copy RGB" class="customPalette copyButtons" onclick="dropdownButtons(4)">
<input type="button" value="Copy Celtic" class="customPalette copyButtons" onclick="dropdownButtons(5)" style="margin: 0px;">
</section>
</section>
<h3 id="copyright" style="color: #808080; float: right; padding-left: 5px;" onclick="info()"></h3>
<h3 style="color: #000000; float: right; cursor: default;" id="breakLine">|</h3>
<a href="https://github.com/RoccoLoxPrograms/1555ColorPicker/blob/main/README.md" target="_blank" style="float: right;" title="See a list of features.">View ReadMe</a>
<br>
<h1 id="title">1555 Color Picker</h1>
<p id="changeColorPicker" style="font-size: 100%; margin: 0px 0px 15px 0px; padding: 0px; font-weight: normal;">
(<a href="https://roccoloxprograms.github.io/XlibcColorPicker" style="padding: 0px;">Xlibc Color Picker</a>)
</p>
<input type="range" min="0" max="65535" value="0" class="colorSlider" id="1555slider">
<br>
<br>
<p style="padding: 0px; margin: unset; font-size: 150%;" id="userInput">
HEX (16-bit):
<input type="text" value="0000" class="textValue" id="1555userValue" onclick="selectAll('1555userValue')">
RED: <input type="number" min="0" max="255" value="0" class="numberValue" id="redUserValue" onclick="selectAll('redUserValue')">
GREEN: <input type="number" min="0" max="255" value="0" class="numberValue" id="greenUserValue" onclick="selectAll('greenUserValue')">
BLUE: <input type="number" min="0" max="255" value="0" class="numberValue" id="blueUserValue" onclick="selectAll('blueUserValue')">
HEX (24-bit): <input type="text" value="000000" class="textValue" id="hexUserValue" onclick="selectAll('hexUserValue')">
<br>
<br>
Celtic Format
<br>
LOW BYTE: <input type="number" min="0" max="255" value="0" class="numberValue" id="celticUserValLo" onclick="selectAll('celticUserValLo')">
HIGH BYTE: <input type="number" min="0" max="255" value="0" class="numberValue" id="celticUserValHi" onclick="selectAll('celticUserValHi')">
</p>
<br>
<p id="1555hexValue" style="font-size: 175%; padding: 0px; margin: 5px;">1555: 0x0000 Palette: 0x00, 0x00</p>
<p id="colorView" style="background-color: #000000; border: solid black thin;"></p>
<div class="table" id="OSColors" onmouseout="onMouseOut()"> <!-- TI-OS color table -->
<div class="osColors" style="background-color: rgb(0, 0, 255);" onclick="OScolor(0,0,255,31,31)" onmouseover="hover(1,0,0,255)">BLUE</div>
<div class="osColors" style="background-color: rgb(255,0,0);" onclick="OScolor(255,0,0,31744,63488)" onmouseover="hover(2,255,0,0)">RED</div>
<div class="osColors" style="background-color: rgb(0, 0, 0);" onclick="OScolor(0,0,0,0,0)" onmouseover="hover(3,0,0,0)">BLACK</div>
<div class="osColors" style="background-color: rgb(255,0,255);" onclick="OScolor(255,0,255,31775,63519)" onmouseover="hover(4,255,0,255)">MAGENTA</div>
<div class="osColors" style="background-color: rgb(0,158,0);" onclick="OScolor(0,158,0,33376,1248)" onmouseover="hover(5,0,158,0)">GREEN</div>
<div class="osColors" style="background-color: rgb(255,142,33);" onclick="OScolor(255,142,33,65060,64612)" onmouseover="hover(6,255,142,33)">ORANGE</div>
<div class="osColors" style="background-color: rgb(181,32,0);" onclick="OScolor(181,32,0,22656,45312)" onmouseover="hover(7,181,32,0)">BROWN</div>
<div class="osColors" style="background-color: rgb(0,0,132);" onclick="OScolor(0,0,132,16,16)" onmouseover="hover(8,0,0,132)">NAVY</div>
<div class="osColors" style="background-color: rgb(0,146,255);" onclick="OScolor(0,146,255,607,1183)" onmouseover="hover(9,0,146,255)">LTBLUE</div>
<div class="osColors" style="background-color: rgb(255,255,0); color: #000000;" onclick="OScolor(255,255,0,65504,65504)" onmouseover="hover(10,255,255,0)">YELLOW</div>
<div class="osColors" style="background-color: rgb(255,255,255); color: #000000;" onclick="OScolor(255,255,255,65535,65535)" onmouseover="hover(11,255,255,255)">WHITE</div>
<div class="osColors" style="background-color: rgb(230,227,230); color: #000000;" onclick="OScolor(230,227,230,29596,59164)" onmouseover="hover(12,230,227,230)">LTGRAY</div>
<div class="osColors" style="background-color: rgb(197,194,197); color: #000000;" onclick="OScolor(197,194,197,25368,50712)" onmouseover="hover(13,197,194,197)">MEDGRAY</div>
<div class="osColors" style="background-color: rgb(140,138,140);" onclick="OScolor(140,138,140,17969,35921)" onmouseover="hover(14,140,138,140)">GRAY</div>
<div class="osColors" style="background-color: rgb(82,85,82);" onclick="OScolor(82,85,82,43338,21162)" onmouseover="hover(15,82,85,82)">DARKGRAY</div>
</div>
<p id ="TI" style="font-size: 170%; font-family: sans-serif; font-weight: bold; text-align: center; margin: 5px 0px; padding: 0px;">TI-OS Colors</p>
<br> <!-- for smaller screen sizes -->
<footer> <!-- advertising! -->
<hr style="margin: 0px; margin-bottom: 5px;">
<a href="https://www.cemetech.net/forum/viewtopic.php?p=294387#294387" target="_blank">Ask a question or suggest a feature</a>
<a href="https://github.com/RoccoLoxPrograms/1555ColorPicker/releases/latest" target="_blank" style="float: right;">Download the newest version</a>
</footer>
<script type="text/javascript">
// get slider value
document.getElementById("1555slider").oninput = function() {
if (!colorMode565) {
// convert 1555 to rgb
red = Math.round((this.value >> 10 & 31) * 255 / 31);
green = Math.round((this.value >> 15 & 1 | this.value >> 4 & 62) * 255 / 63);
blue = Math.round((this.value & 31) * 255 / 31);
} else {
// convert 565 to rgb
red = ((((this.value >> 11) & 0x1F) * 527) + 23) >> 6;
green = ((((this.value >> 5) & 0x3F) * 259) + 33) >> 6;
blue = (((this.value & 0x1F) * 527) + 23) >> 6;
}
updateValues(red, green, blue, this.value);
}
// get 1555/565 input value
document.getElementById("1555userValue").oninput = function() {
var hex = this.value;
// in case the string is too long or too short
if (hex.length == 5) hex = hex.substring(1,5);
if (hex.length == 0) hex = '0';
var c1555 = parseInt(hex, 16).toString(10);
if (!colorMode565) {
// convert 1555 to rgb
red = Math.round((c1555 >> 10 & 31) * 255 / 31);
green = Math.round((c1555 >> 15 & 1 | c1555 >> 4 & 62) * 255 / 63);
blue = Math.round((c1555 & 31) * 255 / 31);
} else {
// convert 565 to rgb
red = ((((c1555 >> 11) & 0x1F) * 527) + 23) >> 6;
green = ((((c1555 >> 5) & 0x3F) * 259) + 33) >> 6;
blue = (((c1555 & 0x1F) * 527) + 23) >> 6;
}
updateValues(red, green, blue, c1555);
}
// get hex color input value
document.getElementById("hexUserValue").oninput = function() {
var hex = this.value;
// in case the string is too long or too short
if (hex.length == 7) hex = hex.substring(1,7);
if (hex.length == 0) hex = '000000';
// make sure the length is 6
if (hex.length == 1) hex = '00000' + hex;
else if (hex.length == 2) hex = '0000' + hex;
else if (hex.length == 3) hex = '000' + hex;
else if (hex.length == 4) hex = '00' + hex;
else if (hex.length == 5) hex = '0' + hex;
red = parseInt(hex.substring(0,2), 16).toString(10);
green = parseInt(hex.substring(2,4), 16).toString(10);
blue = parseInt(hex.substring(4,hex.length), 16).toString(10);
var c1555 = RGBto1555(red, green, blue);
if (colorMode565) c1555 = RGBto565(red, green, blue);
updateValues(red, green, blue, c1555);
}
// get red input value
document.getElementById("redUserValue").oninput = function() {
red = this.value;
if (red == '') red = 0;
green = document.getElementById("greenUserValue").value;
blue = document.getElementById("blueUserValue").value;
var c1555 = RGBto1555(red, green, blue);
if (colorMode565) c1555 = RGBto565(red, green, blue);
updateValues(red, green, blue, c1555);
}
// get green input value
document.getElementById("greenUserValue").oninput = function() {
red = document.getElementById("redUserValue").value;
green = this.value;
if (green == '') green = 0;
blue = document.getElementById("blueUserValue").value;
var c1555 = RGBto1555(red, green, blue);
if (colorMode565) c1555 = RGBto565(red, green, blue);
updateValues(red, green, blue, c1555);
}
// get blue input value
document.getElementById("blueUserValue").oninput = function() {
red = document.getElementById("redUserValue").value;
green = document.getElementById("greenUserValue").value;
blue = this.value;
if (blue == '') blue = 0;
var c1555 = RGBto1555(red, green, blue);
if (colorMode565) c1555 = RGBto565(red, green, blue);
updateValues(red, green, blue, c1555);
}
document.getElementById("celticUserValLo").oninput = function() {
celticLo = this.value;
if (celticLo == '') celticLo = 0;
celticLo = parseInt(celticLo);
celticHi = parseInt(document.getElementById("celticUserValHi").value);
celticHi = celticHi << 8;
c1555 = celticHi + celticLo;
if (colorMode565) {
red = ((((c1555 >> 11) & 0x1F) * 527) + 23) >> 6;
green = ((((c1555 >> 5) & 0x3F) * 259) + 33) >> 6;
blue = (((c1555 & 0x1F) * 527) + 23) >> 6;
} else {
red = ((((c1555 >> 11) & 0x1F) * 527) + 23) >> 6;
green = ((((c1555 >> 5) & 0x3F) * 259) + 33) >> 6;
blue = (((c1555 & 0x1F) * 527) + 23) >> 6;
c1555 = RGBto1555(red, green, blue);
}
updateValues(red, green, blue, c1555);
}
document.getElementById("celticUserValHi").oninput = function() {
celticHi = this.value;
if (celticHi == '') celticHi = 0;
celticHi = parseInt(celticHi);
celticLo = parseInt(document.getElementById("celticUserValLo").value);
celticHi = celticHi << 8;
c1555 = celticHi + celticLo;
if (colorMode565) {
red = ((((c1555 >> 11) & 0x1F) * 527) + 23) >> 6;
green = ((((c1555 >> 5) & 0x3F) * 259) + 33) >> 6;
blue = (((c1555 & 0x1F) * 527) + 23) >> 6;
} else {
red = ((((c1555 >> 11) & 0x1F) * 527) + 23) >> 6;
green = ((((c1555 >> 5) & 0x3F) * 259) + 33) >> 6;
blue = (((c1555 & 0x1F) * 527) + 23) >> 6;
c1555 = RGBto1555(red, green, blue);
}
updateValues(red, green, blue, c1555);
}
// define all of these variables
var red = 0, green = 0, blue = 0, oldn = 1, oldr = 0, oldg = 0, oldb = 255, colorMode565 = false;
var copyCeltic = "0, 0", copyHex = "000000", copyRGB = "r: 0, g: 0, b: 0", copy1555 = "0x0000";
// change copyright year
const date = new Date();
document.getElementById("copyright").innerHTML = `© 2021-${date.getFullYear()} RoccoLox Programs`;
// set mode
if (localStorage.getItem("RLP_1555ColorPicker_mode_052920") == 'dark') {
document.getElementById("switch").checked = true;
darkMode(); // switch to dark mode
}
else localStorage.setItem("RLP_1555ColorPicker_mode_052920","light"); // default mode is light
</script>
</body>
</html>