Tk Source Code

Check-in [4ecc5287]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:elimination of gray table by using calculations in stead
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rfe-3503317
Files: files | file ages | folders
SHA1: 4ecc5287407e891d49c02bda9452cc5ba700e839
User & Date: jan.nijtmans 2012-03-17 00:33:15
Context
2012-03-18
16:45
test output in Xorg rgb.txt format Closed-Leaf check-in: 588cd445 user: jan.nijtmans tags: rfe-3503317
2012-03-17
00:33
elimination of gray table by using calculations in stead check-in: 4ecc5287 user: jan.nijtmans tags: rfe-3503317
00:18
implementation complete, todo: more testing check-in: 190211c6 user: jan.nijtmans tags: rfe-3503317
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to xlib/xcolors.c.

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
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tkInt.h"

/*
 * Special array for the colors gray9-gray100 (and grey9-grey100, which are
 * identical). (TODO: to be removed, because the values can be calculated)
 */

static const char graymap[] = "\377\377\377\374\374\374\372\372\372\367\367\367"
	"\365\365\365\362\362\362\360\360\360\355\355\355\353\353\353\350\350\350"
	"\345\345\345\343\343\343\340\340\340\336\336\336\333\333\333\331\331\331"
	"\326\326\326\324\324\324\321\321\321\317\317\317\314\314\314\311\311\311"
	"\307\307\307\304\304\304\302\302\302\277\277\277\275\275\275\272\272\272"
	"\270\270\270\265\265\265\263\263\263\260\260\260\255\255\255\253\253\253"
	"\250\250\250\246\246\246\243\243\243\241\241\241\236\236\236\234\234\234"
	"\231\231\231\226\226\226\224\224\224\221\221\221\217\217\217\214\214\214"
	"\212\212\212\207\207\207\205\205\205\202\202\202\177\177\177\175\175\175"
	"\172\172\172\170\170\170\165\165\165\163\163\163\160\160\160\156\156\156"
	"\153\153\153\151\151\151\146\146\146\143\143\143\141\141\141\136\136\136"
	"\134\134\134\131\131\131\127\127\127\124\124\124\122\122\122\117\117\117"
	"\115\115\115\112\112\112\107\107\107\105\105\105\102\102\102\100\100\100"
	"\075\075\075\073\073\073\070\070\070\066\066\066\063\063\063\060\060\060"
	"\056\056\056\053\053\053\051\051\051\046\046\046\044\044\044\041\041\041"
	"\037\037\037\034\034\034\032\032\032\027\027\027";

/*
 * Index array. For each of the characters 'a'-'y', this table gives the first color
 * starting with that character in the xColors table.
 */
static int az[] = {0, 4, 12, 19, 43, 43, 46, 56, 58, 60, 60, 61, 84, 99,
	102, 107, 118, 118, 121, 134, 138, 138, 140, 143, 143, 145};








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







9
10
11
12
13
14
15






















16
17
18
19
20
21
22
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tkInt.h"























/*
 * Index array. For each of the characters 'a'-'y', this table gives the first color
 * starting with that character in the xColors table.
 */
static int az[] = {0, 4, 12, 19, 43, 43, 46, 56, 58, 60, 60, 61, 84, 99,
	102, 107, 118, 118, 121, 134, 138, 138, 140, 143, 143, 145};

393
394
395
396
397
398
399
400






401
402
403
404
405
406

407
408
409
410
411
412
413
		return 0;
	    }
	    r = colorcmp(spec + 1, *p, &num);
	}
	if (num > (*p)[31]) {
	    if (((*p)[31] != 8) || num > 100)
	    	return 0;
	    q = graymap + 300 - num * 3;






	} else {
	    q = *p + 28 - num * 3;
	}
	colorPtr->red = ((RED(q) << 8) | RED(q));
	colorPtr->green = ((GREEN(q) << 8) | GREEN(q));
	colorPtr->blue = ((BLUE(q) << 8) | BLUE(q));

    }
    colorPtr->pixel = TkpGetPixel(colorPtr);
    colorPtr->flags = DoRed|DoGreen|DoBlue;
    colorPtr->pad = 0;
    return 1;
}








|
>
>
>
>
>
>


<
|
|
|
>







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
		return 0;
	    }
	    r = colorcmp(spec + 1, *p, &num);
	}
	if (num > (*p)[31]) {
	    if (((*p)[31] != 8) || num > 100)
	    	return 0;
	    num = (num * 255 + 50) / 100;
	    if ((num == 230) || (num == 128)) {
	    	/* Those two entries have a deviation i.r.t the table */
		num--;
	    }
	    num |= (num << 8);
	    colorPtr->red = colorPtr->green = colorPtr->blue = num;
	} else {
	    q = *p + 28 - num * 3;

	    colorPtr->red = ((RED(q) << 8) | RED(q));
	    colorPtr->green = ((GREEN(q) << 8) | GREEN(q));
	    colorPtr->blue = ((BLUE(q) << 8) | BLUE(q));
	}
    }
    colorPtr->pixel = TkpGetPixel(colorPtr);
    colorPtr->flags = DoRed|DoGreen|DoBlue;
    colorPtr->pad = 0;
    return 1;
}