Skip to content
This repository
tree: 7eeea769d5
Fetching contributors…

Cannot retrieve contributors at this time

file 1050 lines (978 sloc) 40.113 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 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 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
(* Yoann Padioleau
*
* Copyright (C) 2010 Facebook
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)

open Common

(*****************************************************************************)
(* Prelude *)
(*****************************************************************************)

(* was called color.ml but camlimages has also a file called color.ml *)

(*****************************************************************************)
(* Types *)
(*****************************************************************************)

(* Canonical form. When writing converters, try to first define the
* xxx_to_rgbf first.
*)

type rgbf = (float * float * float)


type rgb = (int * int * int)

(* a Graphics.color is a [0xRRGGBB] *)
type color = (* Graphics.color *) int

type emacs_color = string



let rainbow_array = [|
    0.0, 0.0, 0.0;

    1.0, 0.0, 0.0;
    0.0, 1.0, 0.0;
    0.0, 0.0, 1.0;

    1.0, 1.0, 0.0;
    1.0, 0.0, 1.0;
    0.0, 1.0, 1.0;


    0.5, 0.0, 0.0;
    0.0, 0.5, 0.0;
    0.0, 0.0, 0.5;

    0.5, 0.5, 0.0;
    0.5, 0.0, 0.5;
    0.0, 0.5, 0.5;


    0.2, 0.0, 0.0;
    0.0, 0.2, 0.0;
    0.0, 0.0, 0.2;

    0.7, 0.0, 0.0;
    0.0, 0.7, 0.0;
    0.0, 0.0, 0.7;

    0.2, 0.2, 0.0;
    0.2, 0.0, 0.2;
    0.0, 0.2, 0.2;

    0.7, 0.7, 0.0;
    0.7, 0.0, 0.7;
    0.0, 0.7, 0.7;


  |]

let rainbow_color i =
  rainbow_array.(i)



(*****************************************************************************)
(* Converters *)
(*****************************************************************************)

(* copy paste of Graphics.rgb *)
let rgb r g b = (r lsl 16) + (g lsl 8) + b

(* a Graphics.color is a [0xRRGGBB] *)
let unrgb rgb =
  let b = (rgb land 0xFF) in
  let g = (rgb land 0xFF00) lsr 8 in
  let r = (rgb land 0xFF0000) lsr 16 in
  (r, g, b)

(*
let _ = Common.example (unrgb red = (255, 0, 0))
let _ = Common.example (unrgb green = (0, 255, 0))
let _ = Common.example (unrgb blue = (0, 0, 255))
*)

let rgb_of_color c =
  unrgb c

let rgb_of_rgbf (r,g,b) =
  let conv x = int_of_float (floor (x *. 255.0)) in
  (conv r, conv g, conv b)

let rgbf_of_rgb (r,g,b) =
  let conv x = ((float_of_int x /. 255.0)) in
  (conv r, conv g, conv b)

let color_of_rgb (r,g,b) =
  rgb r g b

let color_of_rgbf rgbf =
  let rgb = rgb_of_rgbf rgbf in
  color_of_rgb rgb


(*
* generated from this emacs code:
(with-output-to-temp-buffer "res"
(mapcar
'(lambda (c)
(let* ((rgb (color-values c))
(rgb2 (mapcar '(lambda (code) (/ code 65535.0)) rgb))
)
(insert
(format "\"%s\", (%f, %f, %f);\n" c
(nth 0 rgb2)
(nth 1 rgb2)
(nth 2 rgb2)
))
(format "%s: %S" c rgb2)
)
)
(defined-colors))
)
*
*
*)

let emacs_basic_colors = [
"snow", (1.000000, 0.980392, 0.980392);
"ghost white", (0.972549, 0.972549, 1.000000);
"GhostWhite", (0.972549, 0.972549, 1.000000);
"white smoke", (0.960784, 0.960784, 0.960784);
"WhiteSmoke", (0.960784, 0.960784, 0.960784);
"gainsboro", (0.862745, 0.862745, 0.862745);
"floral white", (1.000000, 0.980392, 0.941176);
"FloralWhite", (1.000000, 0.980392, 0.941176);
"old lace", (0.992157, 0.960784, 0.901961);
"OldLace", (0.992157, 0.960784, 0.901961);
"linen", (0.980392, 0.941176, 0.901961);
"antique white", (0.980392, 0.921569, 0.843137);
"AntiqueWhite", (0.980392, 0.921569, 0.843137);
"papaya whip", (1.000000, 0.937255, 0.835294);
"PapayaWhip", (1.000000, 0.937255, 0.835294);
"blanched almond", (1.000000, 0.921569, 0.803922);
"BlanchedAlmond", (1.000000, 0.921569, 0.803922);
"bisque", (1.000000, 0.894118, 0.768627);
"peach puff", (1.000000, 0.854902, 0.725490);
"PeachPuff", (1.000000, 0.854902, 0.725490);
"navajo white", (1.000000, 0.870588, 0.678431);
"NavajoWhite", (1.000000, 0.870588, 0.678431);
"moccasin", (1.000000, 0.894118, 0.709804);
"cornsilk", (1.000000, 0.972549, 0.862745);
"ivory", (1.000000, 1.000000, 0.941176);
"lemon chiffon", (1.000000, 0.980392, 0.803922);
"LemonChiffon", (1.000000, 0.980392, 0.803922);
"seashell", (1.000000, 0.960784, 0.933333);
"honeydew", (0.941176, 1.000000, 0.941176);
"mint cream", (0.960784, 1.000000, 0.980392);
"MintCream", (0.960784, 1.000000, 0.980392);
"azure", (0.941176, 1.000000, 1.000000);
"alice blue", (0.941176, 0.972549, 1.000000);
"AliceBlue", (0.941176, 0.972549, 1.000000);
"lavender", (0.901961, 0.901961, 0.980392);
"lavender blush", (1.000000, 0.941176, 0.960784);
"LavenderBlush", (1.000000, 0.941176, 0.960784);
"misty rose", (1.000000, 0.894118, 0.882353);
"MistyRose", (1.000000, 0.894118, 0.882353);
"white", (1.000000, 1.000000, 1.000000);
"black", (0.000000, 0.000000, 0.000000);
"dark slate gray", (0.184314, 0.309804, 0.309804);
"DarkSlateGray", (0.184314, 0.309804, 0.309804);
"dark slate grey", (0.184314, 0.309804, 0.309804);
"DarkSlateGrey", (0.184314, 0.309804, 0.309804);
"dim gray", (0.411765, 0.411765, 0.411765);
"DimGray", (0.411765, 0.411765, 0.411765);
"dim grey", (0.411765, 0.411765, 0.411765);
"DimGrey", (0.411765, 0.411765, 0.411765);
"slate gray", (0.439216, 0.501961, 0.564706);
"SlateGray", (0.439216, 0.501961, 0.564706);
"slate grey", (0.439216, 0.501961, 0.564706);
"SlateGrey", (0.439216, 0.501961, 0.564706);
"light slate gray", (0.466667, 0.533333, 0.600000);
"LightSlateGray", (0.466667, 0.533333, 0.600000);
"light slate grey", (0.466667, 0.533333, 0.600000);
"LightSlateGrey", (0.466667, 0.533333, 0.600000);
"gray", (0.745098, 0.745098, 0.745098);
"grey", (0.745098, 0.745098, 0.745098);
"light grey", (0.827451, 0.827451, 0.827451);
"LightGrey", (0.827451, 0.827451, 0.827451);
"light gray", (0.827451, 0.827451, 0.827451);
"LightGray", (0.827451, 0.827451, 0.827451);
"midnight blue", (0.098039, 0.098039, 0.439216);
"MidnightBlue", (0.098039, 0.098039, 0.439216);
"navy", (0.000000, 0.000000, 0.501961);
"navy blue", (0.000000, 0.000000, 0.501961);
"NavyBlue", (0.000000, 0.000000, 0.501961);
"cornflower blue", (0.392157, 0.584314, 0.929412);
"CornflowerBlue", (0.392157, 0.584314, 0.929412);
"dark slate blue", (0.282353, 0.239216, 0.545098);
"DarkSlateBlue", (0.282353, 0.239216, 0.545098);
"slate blue", (0.415686, 0.352941, 0.803922);
"SlateBlue", (0.415686, 0.352941, 0.803922);
"medium slate blue", (0.482353, 0.407843, 0.933333);
"MediumSlateBlue", (0.482353, 0.407843, 0.933333);
"light slate blue", (0.517647, 0.439216, 1.000000);
"LightSlateBlue", (0.517647, 0.439216, 1.000000);
"medium blue", (0.000000, 0.000000, 0.803922);
"MediumBlue", (0.000000, 0.000000, 0.803922);
"royal blue", (0.254902, 0.411765, 0.882353);
"RoyalBlue", (0.254902, 0.411765, 0.882353);
"blue", (0.000000, 0.000000, 1.000000);
"dodger blue", (0.117647, 0.564706, 1.000000);
"DodgerBlue", (0.117647, 0.564706, 1.000000);
"deep sky blue", (0.000000, 0.749020, 1.000000);
"DeepSkyBlue", (0.000000, 0.749020, 1.000000);
"sky blue", (0.529412, 0.807843, 0.921569);
"SkyBlue", (0.529412, 0.807843, 0.921569);
"light sky blue", (0.529412, 0.807843, 0.980392);
"LightSkyBlue", (0.529412, 0.807843, 0.980392);
"steel blue", (0.274510, 0.509804, 0.705882);
"SteelBlue", (0.274510, 0.509804, 0.705882);
"light steel blue", (0.690196, 0.768627, 0.870588);
"LightSteelBlue", (0.690196, 0.768627, 0.870588);
"light blue", (0.678431, 0.847059, 0.901961);
"LightBlue", (0.678431, 0.847059, 0.901961);
"powder blue", (0.690196, 0.878431, 0.901961);
"PowderBlue", (0.690196, 0.878431, 0.901961);
"pale turquoise", (0.686275, 0.933333, 0.933333);
"PaleTurquoise", (0.686275, 0.933333, 0.933333);
"dark turquoise", (0.000000, 0.807843, 0.819608);
"DarkTurquoise", (0.000000, 0.807843, 0.819608);
"medium turquoise", (0.282353, 0.819608, 0.800000);
"MediumTurquoise", (0.282353, 0.819608, 0.800000);
"turquoise", (0.250980, 0.878431, 0.815686);
"cyan", (0.000000, 1.000000, 1.000000);
"light cyan", (0.878431, 1.000000, 1.000000);
"LightCyan", (0.878431, 1.000000, 1.000000);
"cadet blue", (0.372549, 0.619608, 0.627451);
"CadetBlue", (0.372549, 0.619608, 0.627451);
"medium aquamarine", (0.400000, 0.803922, 0.666667);
"MediumAquamarine", (0.400000, 0.803922, 0.666667);
"aquamarine", (0.498039, 1.000000, 0.831373);
"dark green", (0.000000, 0.392157, 0.000000);
"DarkGreen", (0.000000, 0.392157, 0.000000);
"dark olive green", (0.333333, 0.419608, 0.184314);
"DarkOliveGreen", (0.333333, 0.419608, 0.184314);
"dark sea green", (0.560784, 0.737255, 0.560784);
"DarkSeaGreen", (0.560784, 0.737255, 0.560784);
"sea green", (0.180392, 0.545098, 0.341176);
"SeaGreen", (0.180392, 0.545098, 0.341176);
"medium sea green", (0.235294, 0.701961, 0.443137);
"MediumSeaGreen", (0.235294, 0.701961, 0.443137);
"light sea green", (0.125490, 0.698039, 0.666667);
"LightSeaGreen", (0.125490, 0.698039, 0.666667);
"pale green", (0.596078, 0.984314, 0.596078);
"PaleGreen", (0.596078, 0.984314, 0.596078);
"spring green", (0.000000, 1.000000, 0.498039);
"SpringGreen", (0.000000, 1.000000, 0.498039);
"lawn green", (0.486275, 0.988235, 0.000000);
"LawnGreen", (0.486275, 0.988235, 0.000000);
"green", (0.000000, 1.000000, 0.000000);
"chartreuse", (0.498039, 1.000000, 0.000000);
"medium spring green", (0.000000, 0.980392, 0.603922);
"MediumSpringGreen", (0.000000, 0.980392, 0.603922);
"green yellow", (0.678431, 1.000000, 0.184314);
"GreenYellow", (0.678431, 1.000000, 0.184314);
"lime green", (0.196078, 0.803922, 0.196078);
"LimeGreen", (0.196078, 0.803922, 0.196078);
"yellow green", (0.603922, 0.803922, 0.196078);
"YellowGreen", (0.603922, 0.803922, 0.196078);
"forest green", (0.133333, 0.545098, 0.133333);
"ForestGreen", (0.133333, 0.545098, 0.133333);
"olive drab", (0.419608, 0.556863, 0.137255);
"OliveDrab", (0.419608, 0.556863, 0.137255);
"dark khaki", (0.741176, 0.717647, 0.419608);
"DarkKhaki", (0.741176, 0.717647, 0.419608);
"khaki", (0.941176, 0.901961, 0.549020);
"pale goldenrod", (0.933333, 0.909804, 0.666667);
"PaleGoldenrod", (0.933333, 0.909804, 0.666667);
"light goldenrod yellow", (0.980392, 0.980392, 0.823529);
"LightGoldenrodYellow", (0.980392, 0.980392, 0.823529);
"light yellow", (1.000000, 1.000000, 0.878431);
"LightYellow", (1.000000, 1.000000, 0.878431);
"yellow", (1.000000, 1.000000, 0.000000);
"gold", (1.000000, 0.843137, 0.000000);
"light goldenrod", (0.933333, 0.866667, 0.509804);
"LightGoldenrod", (0.933333, 0.866667, 0.509804);
"goldenrod", (0.854902, 0.647059, 0.125490);
"dark goldenrod", (0.721569, 0.525490, 0.043137);
"DarkGoldenrod", (0.721569, 0.525490, 0.043137);
"rosy brown", (0.737255, 0.560784, 0.560784);
"RosyBrown", (0.737255, 0.560784, 0.560784);
"indian red", (0.803922, 0.360784, 0.360784);
"IndianRed", (0.803922, 0.360784, 0.360784);
"saddle brown", (0.545098, 0.270588, 0.074510);
"SaddleBrown", (0.545098, 0.270588, 0.074510);
"sienna", (0.627451, 0.321569, 0.176471);
"peru", (0.803922, 0.521569, 0.247059);
"burlywood", (0.870588, 0.721569, 0.529412);
"beige", (0.960784, 0.960784, 0.862745);
"wheat", (0.960784, 0.870588, 0.701961);
"sandy brown", (0.956863, 0.643137, 0.376471);
"SandyBrown", (0.956863, 0.643137, 0.376471);
"tan", (0.823529, 0.705882, 0.549020);
"chocolate", (0.823529, 0.411765, 0.117647);
"firebrick", (0.698039, 0.133333, 0.133333);
"brown", (0.647059, 0.164706, 0.164706);
"dark salmon", (0.913725, 0.588235, 0.478431);
"DarkSalmon", (0.913725, 0.588235, 0.478431);
"salmon", (0.980392, 0.501961, 0.447059);
"light salmon", (1.000000, 0.627451, 0.478431);
"LightSalmon", (1.000000, 0.627451, 0.478431);
"orange", (1.000000, 0.647059, 0.000000);
"dark orange", (1.000000, 0.549020, 0.000000);
"DarkOrange", (1.000000, 0.549020, 0.000000);
"coral", (1.000000, 0.498039, 0.313725);
"light coral", (0.941176, 0.501961, 0.501961);
"LightCoral", (0.941176, 0.501961, 0.501961);
"tomato", (1.000000, 0.388235, 0.278431);
"orange red", (1.000000, 0.270588, 0.000000);
"OrangeRed", (1.000000, 0.270588, 0.000000);
"red", (1.000000, 0.000000, 0.000000);
"hot pink", (1.000000, 0.411765, 0.705882);
"HotPink", (1.000000, 0.411765, 0.705882);
"deep pink", (1.000000, 0.078431, 0.576471);
"DeepPink", (1.000000, 0.078431, 0.576471);
"pink", (1.000000, 0.752941, 0.796078);
"light pink", (1.000000, 0.713725, 0.756863);
"LightPink", (1.000000, 0.713725, 0.756863);
"pale violet red", (0.858824, 0.439216, 0.576471);
"PaleVioletRed", (0.858824, 0.439216, 0.576471);
"maroon", (0.690196, 0.188235, 0.376471);
"medium violet red", (0.780392, 0.082353, 0.521569);
"MediumVioletRed", (0.780392, 0.082353, 0.521569);
"violet red", (0.815686, 0.125490, 0.564706);
"VioletRed", (0.815686, 0.125490, 0.564706);
"magenta", (1.000000, 0.000000, 1.000000);
"violet", (0.933333, 0.509804, 0.933333);
"plum", (0.866667, 0.627451, 0.866667);
"orchid", (0.854902, 0.439216, 0.839216);
"medium orchid", (0.729412, 0.333333, 0.827451);
"MediumOrchid", (0.729412, 0.333333, 0.827451);
"dark orchid", (0.600000, 0.196078, 0.800000);
"DarkOrchid", (0.600000, 0.196078, 0.800000);
"dark violet", (0.580392, 0.000000, 0.827451);
"DarkViolet", (0.580392, 0.000000, 0.827451);
"blue violet", (0.541176, 0.168627, 0.886275);
"BlueViolet", (0.541176, 0.168627, 0.886275);
"purple", (0.627451, 0.125490, 0.941176);
"medium purple", (0.576471, 0.439216, 0.858824);
"MediumPurple", (0.576471, 0.439216, 0.858824);
"thistle", (0.847059, 0.749020, 0.847059);
]

let emacs_degrade_colors = [
"snow1", (1.000000, 0.980392, 0.980392);
"snow2", (0.933333, 0.913725, 0.913725);
"snow3", (0.803922, 0.788235, 0.788235);
"snow4", (0.545098, 0.537255, 0.537255);
"seashell1", (1.000000, 0.960784, 0.933333);
"seashell2", (0.933333, 0.898039, 0.870588);
"seashell3", (0.803922, 0.772549, 0.749020);
"seashell4", (0.545098, 0.525490, 0.509804);
"AntiqueWhite1", (1.000000, 0.937255, 0.858824);
"AntiqueWhite2", (0.933333, 0.874510, 0.800000);
"AntiqueWhite3", (0.803922, 0.752941, 0.690196);
"AntiqueWhite4", (0.545098, 0.513725, 0.470588);
"bisque1", (1.000000, 0.894118, 0.768627);
"bisque2", (0.933333, 0.835294, 0.717647);
"bisque3", (0.803922, 0.717647, 0.619608);
"bisque4", (0.545098, 0.490196, 0.419608);
"PeachPuff1", (1.000000, 0.854902, 0.725490);
"PeachPuff2", (0.933333, 0.796078, 0.678431);
"PeachPuff3", (0.803922, 0.686275, 0.584314);
"PeachPuff4", (0.545098, 0.466667, 0.396078);
"NavajoWhite1", (1.000000, 0.870588, 0.678431);
"NavajoWhite2", (0.933333, 0.811765, 0.631373);
"NavajoWhite3", (0.803922, 0.701961, 0.545098);
"NavajoWhite4", (0.545098, 0.474510, 0.368627);
"LemonChiffon1", (1.000000, 0.980392, 0.803922);
"LemonChiffon2", (0.933333, 0.913725, 0.749020);
"LemonChiffon3", (0.803922, 0.788235, 0.647059);
"LemonChiffon4", (0.545098, 0.537255, 0.439216);
"cornsilk1", (1.000000, 0.972549, 0.862745);
"cornsilk2", (0.933333, 0.909804, 0.803922);
"cornsilk3", (0.803922, 0.784314, 0.694118);
"cornsilk4", (0.545098, 0.533333, 0.470588);
"ivory1", (1.000000, 1.000000, 0.941176);
"ivory2", (0.933333, 0.933333, 0.878431);
"ivory3", (0.803922, 0.803922, 0.756863);
"ivory4", (0.545098, 0.545098, 0.513725);
"honeydew1", (0.941176, 1.000000, 0.941176);
"honeydew2", (0.878431, 0.933333, 0.878431);
"honeydew3", (0.756863, 0.803922, 0.756863);
"honeydew4", (0.513725, 0.545098, 0.513725);
"LavenderBlush1", (1.000000, 0.941176, 0.960784);
"LavenderBlush2", (0.933333, 0.878431, 0.898039);
"LavenderBlush3", (0.803922, 0.756863, 0.772549);
"LavenderBlush4", (0.545098, 0.513725, 0.525490);
"MistyRose1", (1.000000, 0.894118, 0.882353);
"MistyRose2", (0.933333, 0.835294, 0.823529);
"MistyRose3", (0.803922, 0.717647, 0.709804);
"MistyRose4", (0.545098, 0.490196, 0.482353);
"azure1", (0.941176, 1.000000, 1.000000);
"azure2", (0.878431, 0.933333, 0.933333);
"azure3", (0.756863, 0.803922, 0.803922);
"azure4", (0.513725, 0.545098, 0.545098);
"SlateBlue1", (0.513725, 0.435294, 1.000000);
"SlateBlue2", (0.478431, 0.403922, 0.933333);
"SlateBlue3", (0.411765, 0.349020, 0.803922);
"SlateBlue4", (0.278431, 0.235294, 0.545098);
"RoyalBlue1", (0.282353, 0.462745, 1.000000);
"RoyalBlue2", (0.262745, 0.431373, 0.933333);
"RoyalBlue3", (0.227451, 0.372549, 0.803922);
"RoyalBlue4", (0.152941, 0.250980, 0.545098);
"blue1", (0.000000, 0.000000, 1.000000);
"blue2", (0.000000, 0.000000, 0.933333);
"blue3", (0.000000, 0.000000, 0.803922);
"blue4", (0.000000, 0.000000, 0.545098);
"DodgerBlue1", (0.117647, 0.564706, 1.000000);
"DodgerBlue2", (0.109804, 0.525490, 0.933333);
"DodgerBlue3", (0.094118, 0.454902, 0.803922);
"DodgerBlue4", (0.062745, 0.305882, 0.545098);
"SteelBlue1", (0.388235, 0.721569, 1.000000);
"SteelBlue2", (0.360784, 0.674510, 0.933333);
"SteelBlue3", (0.309804, 0.580392, 0.803922);
"SteelBlue4", (0.211765, 0.392157, 0.545098);
"DeepSkyBlue1", (0.000000, 0.749020, 1.000000);
"DeepSkyBlue2", (0.000000, 0.698039, 0.933333);
"DeepSkyBlue3", (0.000000, 0.603922, 0.803922);
"DeepSkyBlue4", (0.000000, 0.407843, 0.545098);
"SkyBlue1", (0.529412, 0.807843, 1.000000);
"SkyBlue2", (0.494118, 0.752941, 0.933333);
"SkyBlue3", (0.423529, 0.650980, 0.803922);
"SkyBlue4", (0.290196, 0.439216, 0.545098);
"LightSkyBlue1", (0.690196, 0.886275, 1.000000);
"LightSkyBlue2", (0.643137, 0.827451, 0.933333);
"LightSkyBlue3", (0.552941, 0.713725, 0.803922);
"LightSkyBlue4", (0.376471, 0.482353, 0.545098);
"SlateGray1", (0.776471, 0.886275, 1.000000);
"SlateGray2", (0.725490, 0.827451, 0.933333);
"SlateGray3", (0.623529, 0.713725, 0.803922);
"SlateGray4", (0.423529, 0.482353, 0.545098);
"LightSteelBlue1", (0.792157, 0.882353, 1.000000);
"LightSteelBlue2", (0.737255, 0.823529, 0.933333);
"LightSteelBlue3", (0.635294, 0.709804, 0.803922);
"LightSteelBlue4", (0.431373, 0.482353, 0.545098);
"LightBlue1", (0.749020, 0.937255, 1.000000);
"LightBlue2", (0.698039, 0.874510, 0.933333);
"LightBlue3", (0.603922, 0.752941, 0.803922);
"LightBlue4", (0.407843, 0.513725, 0.545098);
"LightCyan1", (0.878431, 1.000000, 1.000000);
"LightCyan2", (0.819608, 0.933333, 0.933333);
"LightCyan3", (0.705882, 0.803922, 0.803922);
"LightCyan4", (0.478431, 0.545098, 0.545098);
"PaleTurquoise1", (0.733333, 1.000000, 1.000000);
"PaleTurquoise2", (0.682353, 0.933333, 0.933333);
"PaleTurquoise3", (0.588235, 0.803922, 0.803922);
"PaleTurquoise4", (0.400000, 0.545098, 0.545098);
"CadetBlue1", (0.596078, 0.960784, 1.000000);
"CadetBlue2", (0.556863, 0.898039, 0.933333);
"CadetBlue3", (0.478431, 0.772549, 0.803922);
"CadetBlue4", (0.325490, 0.525490, 0.545098);
"turquoise1", (0.000000, 0.960784, 1.000000);
"turquoise2", (0.000000, 0.898039, 0.933333);
"turquoise3", (0.000000, 0.772549, 0.803922);
"turquoise4", (0.000000, 0.525490, 0.545098);
"cyan1", (0.000000, 1.000000, 1.000000);
"cyan2", (0.000000, 0.933333, 0.933333);
"cyan3", (0.000000, 0.803922, 0.803922);
"cyan4", (0.000000, 0.545098, 0.545098);
"DarkSlateGray1", (0.592157, 1.000000, 1.000000);
"DarkSlateGray2", (0.552941, 0.933333, 0.933333);
"DarkSlateGray3", (0.474510, 0.803922, 0.803922);
"DarkSlateGray4", (0.321569, 0.545098, 0.545098);
"aquamarine1", (0.498039, 1.000000, 0.831373);
"aquamarine2", (0.462745, 0.933333, 0.776471);
"aquamarine3", (0.400000, 0.803922, 0.666667);
"aquamarine4", (0.270588, 0.545098, 0.454902);
"DarkSeaGreen1", (0.756863, 1.000000, 0.756863);
"DarkSeaGreen2", (0.705882, 0.933333, 0.705882);
"DarkSeaGreen3", (0.607843, 0.803922, 0.607843);
"DarkSeaGreen4", (0.411765, 0.545098, 0.411765);
"SeaGreen1", (0.329412, 1.000000, 0.623529);
"SeaGreen2", (0.305882, 0.933333, 0.580392);
"SeaGreen3", (0.262745, 0.803922, 0.501961);
"SeaGreen4", (0.180392, 0.545098, 0.341176);
"PaleGreen1", (0.603922, 1.000000, 0.603922);
"PaleGreen2", (0.564706, 0.933333, 0.564706);
"PaleGreen3", (0.486275, 0.803922, 0.486275);
"PaleGreen4", (0.329412, 0.545098, 0.329412);
"SpringGreen1", (0.000000, 1.000000, 0.498039);
"SpringGreen2", (0.000000, 0.933333, 0.462745);
"SpringGreen3", (0.000000, 0.803922, 0.400000);
"SpringGreen4", (0.000000, 0.545098, 0.270588);
"green1", (0.000000, 1.000000, 0.000000);
"green2", (0.000000, 0.933333, 0.000000);
"green3", (0.000000, 0.803922, 0.000000);
"green4", (0.000000, 0.545098, 0.000000);
"chartreuse1", (0.498039, 1.000000, 0.000000);
"chartreuse2", (0.462745, 0.933333, 0.000000);
"chartreuse3", (0.400000, 0.803922, 0.000000);
"chartreuse4", (0.270588, 0.545098, 0.000000);
"OliveDrab1", (0.752941, 1.000000, 0.243137);
"OliveDrab2", (0.701961, 0.933333, 0.227451);
"OliveDrab3", (0.603922, 0.803922, 0.196078);
"OliveDrab4", (0.411765, 0.545098, 0.133333);
"DarkOliveGreen1", (0.792157, 1.000000, 0.439216);
"DarkOliveGreen2", (0.737255, 0.933333, 0.407843);
"DarkOliveGreen3", (0.635294, 0.803922, 0.352941);
"DarkOliveGreen4", (0.431373, 0.545098, 0.239216);
"khaki1", (1.000000, 0.964706, 0.560784);
"khaki2", (0.933333, 0.901961, 0.521569);
"khaki3", (0.803922, 0.776471, 0.450980);
"khaki4", (0.545098, 0.525490, 0.305882);
"LightGoldenrod1", (1.000000, 0.925490, 0.545098);
"LightGoldenrod2", (0.933333, 0.862745, 0.509804);
"LightGoldenrod3", (0.803922, 0.745098, 0.439216);
"LightGoldenrod4", (0.545098, 0.505882, 0.298039);
"LightYellow1", (1.000000, 1.000000, 0.878431);
"LightYellow2", (0.933333, 0.933333, 0.819608);
"LightYellow3", (0.803922, 0.803922, 0.705882);
"LightYellow4", (0.545098, 0.545098, 0.478431);
"yellow1", (1.000000, 1.000000, 0.000000);
"yellow2", (0.933333, 0.933333, 0.000000);
"yellow3", (0.803922, 0.803922, 0.000000);
"yellow4", (0.545098, 0.545098, 0.000000);
"gold1", (1.000000, 0.843137, 0.000000);
"gold2", (0.933333, 0.788235, 0.000000);
"gold3", (0.803922, 0.678431, 0.000000);
"gold4", (0.545098, 0.458824, 0.000000);
"goldenrod1", (1.000000, 0.756863, 0.145098);
"goldenrod2", (0.933333, 0.705882, 0.133333);
"goldenrod3", (0.803922, 0.607843, 0.113725);
"goldenrod4", (0.545098, 0.411765, 0.078431);
"DarkGoldenrod1", (1.000000, 0.725490, 0.058824);
"DarkGoldenrod2", (0.933333, 0.678431, 0.054902);
"DarkGoldenrod3", (0.803922, 0.584314, 0.047059);
"DarkGoldenrod4", (0.545098, 0.396078, 0.031373);
"RosyBrown1", (1.000000, 0.756863, 0.756863);
"RosyBrown2", (0.933333, 0.705882, 0.705882);
"RosyBrown3", (0.803922, 0.607843, 0.607843);
"RosyBrown4", (0.545098, 0.411765, 0.411765);
"IndianRed1", (1.000000, 0.415686, 0.415686);
"IndianRed2", (0.933333, 0.388235, 0.388235);
"IndianRed3", (0.803922, 0.333333, 0.333333);
"IndianRed4", (0.545098, 0.227451, 0.227451);
"sienna1", (1.000000, 0.509804, 0.278431);
"sienna2", (0.933333, 0.474510, 0.258824);
"sienna3", (0.803922, 0.407843, 0.223529);
"sienna4", (0.545098, 0.278431, 0.149020);
"burlywood1", (1.000000, 0.827451, 0.607843);
"burlywood2", (0.933333, 0.772549, 0.568627);
"burlywood3", (0.803922, 0.666667, 0.490196);
"burlywood4", (0.545098, 0.450980, 0.333333);
"wheat1", (1.000000, 0.905882, 0.729412);
"wheat2", (0.933333, 0.847059, 0.682353);
"wheat3", (0.803922, 0.729412, 0.588235);
"wheat4", (0.545098, 0.494118, 0.400000);
"tan1", (1.000000, 0.647059, 0.309804);
"tan2", (0.933333, 0.603922, 0.286275);
"tan3", (0.803922, 0.521569, 0.247059);
"tan4", (0.545098, 0.352941, 0.168627);
"chocolate1", (1.000000, 0.498039, 0.141176);
"chocolate2", (0.933333, 0.462745, 0.129412);
"chocolate3", (0.803922, 0.400000, 0.113725);
"chocolate4", (0.545098, 0.270588, 0.074510);
"firebrick1", (1.000000, 0.188235, 0.188235);
"firebrick2", (0.933333, 0.172549, 0.172549);
"firebrick3", (0.803922, 0.149020, 0.149020);
"firebrick4", (0.545098, 0.101961, 0.101961);
"brown1", (1.000000, 0.250980, 0.250980);
"brown2", (0.933333, 0.231373, 0.231373);
"brown3", (0.803922, 0.200000, 0.200000);
"brown4", (0.545098, 0.137255, 0.137255);
"salmon1", (1.000000, 0.549020, 0.411765);
"salmon2", (0.933333, 0.509804, 0.384314);
"salmon3", (0.803922, 0.439216, 0.329412);
"salmon4", (0.545098, 0.298039, 0.223529);
"LightSalmon1", (1.000000, 0.627451, 0.478431);
"LightSalmon2", (0.933333, 0.584314, 0.447059);
"LightSalmon3", (0.803922, 0.505882, 0.384314);
"LightSalmon4", (0.545098, 0.341176, 0.258824);
"orange1", (1.000000, 0.647059, 0.000000);
"orange2", (0.933333, 0.603922, 0.000000);
"orange3", (0.803922, 0.521569, 0.000000);
"orange4", (0.545098, 0.352941, 0.000000);
"DarkOrange1", (1.000000, 0.498039, 0.000000);
"DarkOrange2", (0.933333, 0.462745, 0.000000);
"DarkOrange3", (0.803922, 0.400000, 0.000000);
"DarkOrange4", (0.545098, 0.270588, 0.000000);
"coral1", (1.000000, 0.447059, 0.337255);
"coral2", (0.933333, 0.415686, 0.313725);
"coral3", (0.803922, 0.356863, 0.270588);
"coral4", (0.545098, 0.243137, 0.184314);
"tomato1", (1.000000, 0.388235, 0.278431);
"tomato2", (0.933333, 0.360784, 0.258824);
"tomato3", (0.803922, 0.309804, 0.223529);
"tomato4", (0.545098, 0.211765, 0.149020);
"OrangeRed1", (1.000000, 0.270588, 0.000000);
"OrangeRed2", (0.933333, 0.250980, 0.000000);
"OrangeRed3", (0.803922, 0.215686, 0.000000);
"OrangeRed4", (0.545098, 0.145098, 0.000000);
"red1", (1.000000, 0.000000, 0.000000);
"red2", (0.933333, 0.000000, 0.000000);
"red3", (0.803922, 0.000000, 0.000000);
"red4", (0.545098, 0.000000, 0.000000);
"DeepPink1", (1.000000, 0.078431, 0.576471);
"DeepPink2", (0.933333, 0.070588, 0.537255);
"DeepPink3", (0.803922, 0.062745, 0.462745);
"DeepPink4", (0.545098, 0.039216, 0.313725);
"HotPink1", (1.000000, 0.431373, 0.705882);
"HotPink2", (0.933333, 0.415686, 0.654902);
"HotPink3", (0.803922, 0.376471, 0.564706);
"HotPink4", (0.545098, 0.227451, 0.384314);
"pink1", (1.000000, 0.709804, 0.772549);
"pink2", (0.933333, 0.662745, 0.721569);
"pink3", (0.803922, 0.568627, 0.619608);
"pink4", (0.545098, 0.388235, 0.423529);
"LightPink1", (1.000000, 0.682353, 0.725490);
"LightPink2", (0.933333, 0.635294, 0.678431);
"LightPink3", (0.803922, 0.549020, 0.584314);
"LightPink4", (0.545098, 0.372549, 0.396078);
"PaleVioletRed1", (1.000000, 0.509804, 0.670588);
"PaleVioletRed2", (0.933333, 0.474510, 0.623529);
"PaleVioletRed3", (0.803922, 0.407843, 0.537255);
"PaleVioletRed4", (0.545098, 0.278431, 0.364706);
"maroon1", (1.000000, 0.203922, 0.701961);
"maroon2", (0.933333, 0.188235, 0.654902);
"maroon3", (0.803922, 0.160784, 0.564706);
"maroon4", (0.545098, 0.109804, 0.384314);
"VioletRed1", (1.000000, 0.243137, 0.588235);
"VioletRed2", (0.933333, 0.227451, 0.549020);
"VioletRed3", (0.803922, 0.196078, 0.470588);
"VioletRed4", (0.545098, 0.133333, 0.321569);
"magenta1", (1.000000, 0.000000, 1.000000);
"magenta2", (0.933333, 0.000000, 0.933333);
"magenta3", (0.803922, 0.000000, 0.803922);
"magenta4", (0.545098, 0.000000, 0.545098);
"orchid1", (1.000000, 0.513725, 0.980392);
"orchid2", (0.933333, 0.478431, 0.913725);
"orchid3", (0.803922, 0.411765, 0.788235);
"orchid4", (0.545098, 0.278431, 0.537255);
"plum1", (1.000000, 0.733333, 1.000000);
"plum2", (0.933333, 0.682353, 0.933333);
"plum3", (0.803922, 0.588235, 0.803922);
"plum4", (0.545098, 0.400000, 0.545098);
"MediumOrchid1", (0.878431, 0.400000, 1.000000);
"MediumOrchid2", (0.819608, 0.372549, 0.933333);
"MediumOrchid3", (0.705882, 0.321569, 0.803922);
"MediumOrchid4", (0.478431, 0.215686, 0.545098);
"DarkOrchid1", (0.749020, 0.243137, 1.000000);
"DarkOrchid2", (0.698039, 0.227451, 0.933333);
"DarkOrchid3", (0.603922, 0.196078, 0.803922);
"DarkOrchid4", (0.407843, 0.133333, 0.545098);
"purple1", (0.607843, 0.188235, 1.000000);
"purple2", (0.568627, 0.172549, 0.933333);
"purple3", (0.490196, 0.149020, 0.803922);
"purple4", (0.333333, 0.101961, 0.545098);
"MediumPurple1", (0.670588, 0.509804, 1.000000);
"MediumPurple2", (0.623529, 0.474510, 0.933333);
"MediumPurple3", (0.537255, 0.407843, 0.803922);
"MediumPurple4", (0.364706, 0.278431, 0.545098);
"thistle1", (1.000000, 0.882353, 1.000000);
"thistle2", (0.933333, 0.823529, 0.933333);
"thistle3", (0.803922, 0.709804, 0.803922);
"thistle4", (0.545098, 0.482353, 0.545098);
]

let emacs_gray_colors = [
"gray0", (0.000000, 0.000000, 0.000000);
"grey0", (0.000000, 0.000000, 0.000000);
"gray1", (0.011765, 0.011765, 0.011765);
"grey1", (0.011765, 0.011765, 0.011765);
"gray2", (0.019608, 0.019608, 0.019608);
"grey2", (0.019608, 0.019608, 0.019608);
"gray3", (0.031373, 0.031373, 0.031373);
"grey3", (0.031373, 0.031373, 0.031373);
"gray4", (0.039216, 0.039216, 0.039216);
"grey4", (0.039216, 0.039216, 0.039216);
"gray5", (0.050980, 0.050980, 0.050980);
"grey5", (0.050980, 0.050980, 0.050980);
"gray6", (0.058824, 0.058824, 0.058824);
"grey6", (0.058824, 0.058824, 0.058824);
"gray7", (0.070588, 0.070588, 0.070588);
"grey7", (0.070588, 0.070588, 0.070588);
"gray8", (0.078431, 0.078431, 0.078431);
"grey8", (0.078431, 0.078431, 0.078431);
"gray9", (0.090196, 0.090196, 0.090196);
"grey9", (0.090196, 0.090196, 0.090196);
"gray10", (0.101961, 0.101961, 0.101961);
"grey10", (0.101961, 0.101961, 0.101961);
"gray11", (0.109804, 0.109804, 0.109804);
"grey11", (0.109804, 0.109804, 0.109804);
"gray12", (0.121569, 0.121569, 0.121569);
"grey12", (0.121569, 0.121569, 0.121569);
"gray13", (0.129412, 0.129412, 0.129412);
"grey13", (0.129412, 0.129412, 0.129412);
"gray14", (0.141176, 0.141176, 0.141176);
"grey14", (0.141176, 0.141176, 0.141176);
"gray15", (0.149020, 0.149020, 0.149020);
"grey15", (0.149020, 0.149020, 0.149020);
"gray16", (0.160784, 0.160784, 0.160784);
"grey16", (0.160784, 0.160784, 0.160784);
"gray17", (0.168627, 0.168627, 0.168627);
"grey17", (0.168627, 0.168627, 0.168627);
"gray18", (0.180392, 0.180392, 0.180392);
"grey18", (0.180392, 0.180392, 0.180392);
"gray19", (0.188235, 0.188235, 0.188235);
"grey19", (0.188235, 0.188235, 0.188235);
"gray20", (0.200000, 0.200000, 0.200000);
"grey20", (0.200000, 0.200000, 0.200000);
"gray21", (0.211765, 0.211765, 0.211765);
"grey21", (0.211765, 0.211765, 0.211765);
"gray22", (0.219608, 0.219608, 0.219608);
"grey22", (0.219608, 0.219608, 0.219608);
"gray23", (0.231373, 0.231373, 0.231373);
"grey23", (0.231373, 0.231373, 0.231373);
"gray24", (0.239216, 0.239216, 0.239216);
"grey24", (0.239216, 0.239216, 0.239216);
"gray25", (0.250980, 0.250980, 0.250980);
"grey25", (0.250980, 0.250980, 0.250980);
"gray26", (0.258824, 0.258824, 0.258824);
"grey26", (0.258824, 0.258824, 0.258824);
"gray27", (0.270588, 0.270588, 0.270588);
"grey27", (0.270588, 0.270588, 0.270588);
"gray28", (0.278431, 0.278431, 0.278431);
"grey28", (0.278431, 0.278431, 0.278431);
"gray29", (0.290196, 0.290196, 0.290196);
"grey29", (0.290196, 0.290196, 0.290196);
"gray30", (0.301961, 0.301961, 0.301961);
"grey30", (0.301961, 0.301961, 0.301961);
"gray31", (0.309804, 0.309804, 0.309804);
"grey31", (0.309804, 0.309804, 0.309804);
"gray32", (0.321569, 0.321569, 0.321569);
"grey32", (0.321569, 0.321569, 0.321569);
"gray33", (0.329412, 0.329412, 0.329412);
"grey33", (0.329412, 0.329412, 0.329412);
"gray34", (0.341176, 0.341176, 0.341176);
"grey34", (0.341176, 0.341176, 0.341176);
"gray35", (0.349020, 0.349020, 0.349020);
"grey35", (0.349020, 0.349020, 0.349020);
"gray36", (0.360784, 0.360784, 0.360784);
"grey36", (0.360784, 0.360784, 0.360784);
"gray37", (0.368627, 0.368627, 0.368627);
"grey37", (0.368627, 0.368627, 0.368627);
"gray38", (0.380392, 0.380392, 0.380392);
"grey38", (0.380392, 0.380392, 0.380392);
"gray39", (0.388235, 0.388235, 0.388235);
"grey39", (0.388235, 0.388235, 0.388235);
"gray40", (0.400000, 0.400000, 0.400000);
"grey40", (0.400000, 0.400000, 0.400000);
"gray41", (0.411765, 0.411765, 0.411765);
"grey41", (0.411765, 0.411765, 0.411765);
"gray42", (0.419608, 0.419608, 0.419608);
"grey42", (0.419608, 0.419608, 0.419608);
"gray43", (0.431373, 0.431373, 0.431373);
"grey43", (0.431373, 0.431373, 0.431373);
"gray44", (0.439216, 0.439216, 0.439216);
"grey44", (0.439216, 0.439216, 0.439216);
"gray45", (0.450980, 0.450980, 0.450980);
"grey45", (0.450980, 0.450980, 0.450980);
"gray46", (0.458824, 0.458824, 0.458824);
"grey46", (0.458824, 0.458824, 0.458824);
"gray47", (0.470588, 0.470588, 0.470588);
"grey47", (0.470588, 0.470588, 0.470588);
"gray48", (0.478431, 0.478431, 0.478431);
"grey48", (0.478431, 0.478431, 0.478431);
"gray49", (0.490196, 0.490196, 0.490196);
"grey49", (0.490196, 0.490196, 0.490196);
"gray50", (0.498039, 0.498039, 0.498039);
"grey50", (0.498039, 0.498039, 0.498039);
"gray51", (0.509804, 0.509804, 0.509804);
"grey51", (0.509804, 0.509804, 0.509804);
"gray52", (0.521569, 0.521569, 0.521569);
"grey52", (0.521569, 0.521569, 0.521569);
"gray53", (0.529412, 0.529412, 0.529412);
"grey53", (0.529412, 0.529412, 0.529412);
"gray54", (0.541176, 0.541176, 0.541176);
"grey54", (0.541176, 0.541176, 0.541176);
"gray55", (0.549020, 0.549020, 0.549020);
"grey55", (0.549020, 0.549020, 0.549020);
"gray56", (0.560784, 0.560784, 0.560784);
"grey56", (0.560784, 0.560784, 0.560784);
"gray57", (0.568627, 0.568627, 0.568627);
"grey57", (0.568627, 0.568627, 0.568627);
"gray58", (0.580392, 0.580392, 0.580392);
"grey58", (0.580392, 0.580392, 0.580392);
"gray59", (0.588235, 0.588235, 0.588235);
"grey59", (0.588235, 0.588235, 0.588235);
"gray60", (0.600000, 0.600000, 0.600000);
"grey60", (0.600000, 0.600000, 0.600000);
"gray61", (0.611765, 0.611765, 0.611765);
"grey61", (0.611765, 0.611765, 0.611765);
"gray62", (0.619608, 0.619608, 0.619608);
"grey62", (0.619608, 0.619608, 0.619608);
"gray63", (0.631373, 0.631373, 0.631373);
"grey63", (0.631373, 0.631373, 0.631373);
"gray64", (0.639216, 0.639216, 0.639216);
"grey64", (0.639216, 0.639216, 0.639216);
"gray65", (0.650980, 0.650980, 0.650980);
"grey65", (0.650980, 0.650980, 0.650980);
"gray66", (0.658824, 0.658824, 0.658824);
"grey66", (0.658824, 0.658824, 0.658824);
"gray67", (0.670588, 0.670588, 0.670588);
"grey67", (0.670588, 0.670588, 0.670588);
"gray68", (0.678431, 0.678431, 0.678431);
"grey68", (0.678431, 0.678431, 0.678431);
"gray69", (0.690196, 0.690196, 0.690196);
"grey69", (0.690196, 0.690196, 0.690196);
"gray70", (0.701961, 0.701961, 0.701961);
"grey70", (0.701961, 0.701961, 0.701961);
"gray71", (0.709804, 0.709804, 0.709804);
"grey71", (0.709804, 0.709804, 0.709804);
"gray72", (0.721569, 0.721569, 0.721569);
"grey72", (0.721569, 0.721569, 0.721569);
"gray73", (0.729412, 0.729412, 0.729412);
"grey73", (0.729412, 0.729412, 0.729412);
"gray74", (0.741176, 0.741176, 0.741176);
"grey74", (0.741176, 0.741176, 0.741176);
"gray75", (0.749020, 0.749020, 0.749020);
"grey75", (0.749020, 0.749020, 0.749020);
"gray76", (0.760784, 0.760784, 0.760784);
"grey76", (0.760784, 0.760784, 0.760784);
"gray77", (0.768627, 0.768627, 0.768627);
"grey77", (0.768627, 0.768627, 0.768627);
"gray78", (0.780392, 0.780392, 0.780392);
"grey78", (0.780392, 0.780392, 0.780392);
"gray79", (0.788235, 0.788235, 0.788235);
"grey79", (0.788235, 0.788235, 0.788235);
"gray80", (0.800000, 0.800000, 0.800000);
"grey80", (0.800000, 0.800000, 0.800000);
"gray81", (0.811765, 0.811765, 0.811765);
"grey81", (0.811765, 0.811765, 0.811765);
"gray82", (0.819608, 0.819608, 0.819608);
"grey82", (0.819608, 0.819608, 0.819608);
"gray83", (0.831373, 0.831373, 0.831373);
"grey83", (0.831373, 0.831373, 0.831373);
"gray84", (0.839216, 0.839216, 0.839216);
"grey84", (0.839216, 0.839216, 0.839216);
"gray85", (0.850980, 0.850980, 0.850980);
"grey85", (0.850980, 0.850980, 0.850980);
"gray86", (0.858824, 0.858824, 0.858824);
"grey86", (0.858824, 0.858824, 0.858824);
"gray87", (0.870588, 0.870588, 0.870588);
"grey87", (0.870588, 0.870588, 0.870588);
"gray88", (0.878431, 0.878431, 0.878431);
"grey88", (0.878431, 0.878431, 0.878431);
"gray89", (0.890196, 0.890196, 0.890196);
"grey89", (0.890196, 0.890196, 0.890196);
"gray90", (0.898039, 0.898039, 0.898039);
"grey90", (0.898039, 0.898039, 0.898039);
"gray91", (0.909804, 0.909804, 0.909804);
"grey91", (0.909804, 0.909804, 0.909804);
"gray92", (0.921569, 0.921569, 0.921569);
"grey92", (0.921569, 0.921569, 0.921569);
"gray93", (0.929412, 0.929412, 0.929412);
"grey93", (0.929412, 0.929412, 0.929412);
"gray94", (0.941176, 0.941176, 0.941176);
"grey94", (0.941176, 0.941176, 0.941176);
"gray95", (0.949020, 0.949020, 0.949020);
"grey95", (0.949020, 0.949020, 0.949020);
"gray96", (0.960784, 0.960784, 0.960784);
"grey96", (0.960784, 0.960784, 0.960784);
"gray97", (0.968627, 0.968627, 0.968627);
"grey97", (0.968627, 0.968627, 0.968627);
"gray98", (0.980392, 0.980392, 0.980392);
"grey98", (0.980392, 0.980392, 0.980392);
"gray99", (0.988235, 0.988235, 0.988235);
"grey99", (0.988235, 0.988235, 0.988235);
"gray100", (1.000000, 1.000000, 1.000000);
"grey100", (1.000000, 1.000000, 1.000000);
"dark grey", (0.662745, 0.662745, 0.662745);
"DarkGrey", (0.662745, 0.662745, 0.662745);
"dark gray", (0.662745, 0.662745, 0.662745);
"DarkGray", (0.662745, 0.662745, 0.662745);
"dark blue", (0.000000, 0.000000, 0.545098);
"DarkBlue", (0.000000, 0.000000, 0.545098);
"dark cyan", (0.000000, 0.545098, 0.545098);
"DarkCyan", (0.000000, 0.545098, 0.545098);
"dark magenta", (0.545098, 0.000000, 0.545098);
"DarkMagenta", (0.545098, 0.000000, 0.545098);
"dark red", (0.545098, 0.000000, 0.000000);
"DarkRed", (0.545098, 0.000000, 0.000000);
"light green", (0.564706, 0.933333, 0.564706);
"LightGreen", (0.564706, 0.933333, 0.564706);
]

let emacs_colors =
  emacs_basic_colors @ emacs_degrade_colors @ emacs_gray_colors

let random_emacs_color xs =
  let len = List.length xs in
  let n = Random.int len in
  List.nth xs n +> fst

let rgbf_of_string s =
  try
    List.assoc s emacs_colors
  with
  Not_found -> failwith ("color name not found: " ^ s)

let rgb_of_string s =
  s +> rgbf_of_string +> rgb_of_rgbf


let color_of_string s =
  s +> rgbf_of_string +> rgb_of_rgbf +> color_of_rgb

let c x = color_of_string x



let string_of_color color =
  let rgb = rgb_of_color color in
  let rgbf = rgbf_of_rgb rgb in

  (* find closest color *)
  let dist (a1,b1,c1) (a2,b2,c2) =
    abs_float (a1 -. a2) +.
    abs_float (b1 -. b2) +.
    abs_float (c1 -. c2) +.
    0.0
  in
  let dists = emacs_colors +> List.map (fun (s, rgbf2) ->
    (s, dist rgbf rgbf2)
  )
  in
  Common.sort_by_val_lowfirst dists +> List.hd +> fst


(*
Graphics.rgb (Random.int maxc) (Random.int maxc) (Random.int maxc)
*)

(*****************************************************************************)
(* Misc *)
(*****************************************************************************)

type degrade =
  | Degrade1
  | Degrade2
  | Degrade3
  | Degrade4

let mk_degrade i =
  match i with
  | 1 -> Degrade1
  | 2 -> Degrade2
  | 3 -> Degrade3
  | 4 -> Degrade4
  | _ -> failwith "mk_degrade: the level must be between 1 and 4"
let i_of_degrade x =
  match x with
  | Degrade1 -> 1
  | Degrade2 -> 2
  | Degrade3 -> 3
  | Degrade4 -> 4

(* When 100 it will be black, when 0 it will be white.
* Because grey100 is actually white and grey0 black, we need
* the 100 - xxx below.
*)
let degrade_grey percent =
  assert (percent <= 100.0);
  let i = 100 - (int_of_float percent) in
  c ("grey" ^ (i_to_s i))


let degrade str lvl =
  (* assert exist color ? *)
  let i = i_of_degrade lvl in
  color_of_string (str ^ (i_to_s i))
  

let degrade_random str =
  let i = Random.int 4 + 1 in
  degrade str (mk_degrade i)
  



(* does not work very well ... *)
let degrade_random_bis color =
  let (r,g,b) = unrgb color in
  let around = 2 in
  let middle = around / 2 in

  let r = r + (Random.int around - middle) in
(*
let g = g + (Random.int around - middle) in
let b = b + (Random.int around - middle) in
*)
  rgb r g b

let rgbf_of_color c =
  c +> rgb_of_color +> rgbf_of_rgb


(*
let black = Graphics.black
let white = Graphics.white
let red = Graphics.red
let green = Graphics.green
let blue = Graphics.blue
let yellow = Graphics.yellow
let cyan = Graphics.cyan
let magenta = Graphics.magenta
*)
(* copy paste from Graphics.ml ocaml source *)
let black = 0x000000
and white = 0xFFFFFF
and red = 0xFF0000
and green = 0x00FF00
and blue = 0x0000FF
and yellow = 0xFFFF00
and cyan = 0x00FFFF
and magenta = 0xFF00FF

let blackf = rgbf_of_color black
let whitef = rgbf_of_color white
let redf = rgbf_of_color red
let greenf = rgbf_of_color green
let bluef = rgbf_of_color blue
let yellowf = rgbf_of_color yellow
let cyanf = rgbf_of_color cyan
let magentaf = rgbf_of_color magenta
Something went wrong with that request. Please try again.