%! % POSTSCRIPT "WEB FRIENDLY" COLOR TINT MODULE % ============================================ % Copyright c 1999, 2011 by Don Lancaster and Syenrgetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 don@tinaja.com < http://www.tinaja.com > % Consulting services available per < http://www.tinaja.com/info01.html > % Additional PostScript resources at < http://www.tinaja.com/pssamp1.asp > % All commercial rights and all electronic media rights fully reserved. % Personal use permitted provided header and entire file remains intact. % Linking welcome. Reposting expressly forbidden. % version 1.1 % ========================================================================== % "Web friendly" colors are a group of 216 tints based on % red, blue, and green being restricted to hex values of % $00, $33, $66, $99, $CC, and $FF each. % This routine accepts a number from 0 to 215 and generates % a "web friendly" color from it. Those colors are optionally displayed. % This is basically a "paint by numbers" scheme which reduces any color % to a single decimal number from 0 to 215. Thus greatly simplifying its % recognition and coding. % You can think of each color as a cublet arranged into a 6x6x6 master cube. % The principal diagonal of the cublet varies from black through gray to white. % Red is stronger to the east. Green is stronger to the north. Blue is stronger up. % The three remaining corners are strongest yellow, aqua, and magenta. % The code also shows how a self-building table lookup can avoid messy or cumbersome % math algorithms. % ===================================================================== % This code locks pdfmark commands out of a PostScript printer. /pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse /inches {72 mul} store /pagewide 8.0 inches store /pagehigh 6.2 inches store % code to custom trim to subject... /pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse [/CropBox [0 0 pagewide pagehigh] /PAGES pdfmark [ {Catalog} << /ViewerPreferences << /FitWindow true /CenterWindow true >> /PageLayout /SinglePage % no rolling /Pagemode /FullScreen % fullscreen if not on web /View [/XYZ null null 1 ] % force 100% >> /PUT pdfmark % ///////// (A) WEB FRIENDLY COLOR UTILITIES ///////////// % tintmat is a self-generating list of 216 triple color values /webtintmat [ 0 1 5 { /a exch store 0 1 5 { /b exch store 0 1 5 { 5 div b 5 div a 5 div }for } for } for ] def % setwebtint accepts a color number 0 to 215 and then % sets the PostScript color generator for later use... /setwebtint { abs cvi 216 cvi mod % restrict range webtintmat exch 3 mul 3 getinterval % get values from table aload pop setrgbcolor} def % and set them % The blocks are arranged as red to the right, green % up in order of increasing blue. % Some "pure color" sequences are % red: 0 1 2 3 4 5 % orange: 0 7 8 15 16 23 (sort of) % yellow: 0 7 14 21 28 35 % green: 0 6 12 18 24 30 % aqua: 0 42 84 126 168 210 % blue: 0 36 72 108 144 180 % magenta: 0 37 74 111 148 185 % purple 0 73 73 110 147 183 (sort of) % gray 0 43 86 129 172 215 % /////// (B) WEB FRIENDLY UTILITY DEMO ///////////// % This demo is activated by sending this entire file to % Acrobat Distiller. The routines in part (A) are required, % as are my Gonzo Utilities. % These are gotten from http://www.tinaja.com/psutils/gonzo.ps % Run my gonzo utilities (these are used in the demo only) % The following line needs modified per your gonzo location... % (C:\\Documents and Settings\\don\\Desktop\\gonzo\\gonzo.ps) run % use external gonzo (C:/Users/Don/Desktop/Ghost/gonzo.psl) run /cstretch 0 def /font1 /Arial-BoldMT [9 0 0 9 0 0 ] gonzofont /font2 /Revue 22 gonzofont /font3 /Revue 12 gonzofont font1 /util {gsave translate 0 0 mt 25 pu 25 pr 25 pd closepath curcolor bluval 36 mul add dup 5 string cvs exch setwebtint fill font1 currentcolor add add 1.5 gt {0 0 0 }{1 1 1} ifelse setcolor 12.5 exch 14 exch cc 12.5 5 hexval curcolor bluval 36 mul add get cc grestore}def /showwebcolors { gsave 0 0 translate /bluval 0 store showrg36 grestore gsave 175 0 translate /bluval 1 store showrg36 grestore gsave 350 0 translate /bluval 2 store showrg36 grestore gsave 0 175 translate /bluval 3 store showrg36 grestore gsave 175 175 translate /bluval 4 store showrg36 grestore gsave 350 175 translate /bluval 5 store showrg36 grestore } def /hexval [ (000) (300) (600) (900) (C00) (F00) (030) (330) (630) (930) (C30) (F30) (060) (360) (660) (960) (C60) (F60) (090) (390) (690) (990) (C90) (F90) (0C0) (3C0) (6C0) (9C0) (CC0) (FC0) (0F0) (3F0) (6F0) (9F0) (CF0) (FF0) (003) (303) (603) (903) (C03) (F03) (033) (333) (633) (933) (C33) (F33) (063) (363) (663) (963) (C63) (F63) (093) (393) (693) (993) (C93) (F93) (0C3) (3C3) (6C3) (9C3) (CC3) (FC3) (0F3) (3F3) (6F3) (9F3) (CF3) (FF3) (006) (306) (606) (906) (C06) (F06) (036) (336) (636) (936) (C36) (F36) (066) (366) (666) (966) (C66) (F66) (096) (396) (696) (996) (C96) (F96) (0C6) (3C6) (6C6) (9C6) (CC6) (FC6) (0F6) (3F6) (6F6) (9F6) (CF6) (FF6) (009) (309) (609) (909) (C09) (F09) (039) (339) (639) (939) (C39) (F39) (069) (369) (669) (969) (C69) (F69) (099) (399) (699) (999) (C99) (F99) (0C9) (3C9) (6C9) (9C9) (CC9) (FC9) (0F9) (3F9) (6F9) (9F9) (CF9) (FF9) (00C) (30C) (60C) (90C) (C0C) (F0C) (03C) (33C) (63C) (93C) (C3C) (F3C) (06C) (36C) (66C) (96C) (C6C) (F6C) (09C) (39C) (69C) (99C) (C9C) (F9C) (0CC) (3CC) (6CC) (9CC) (CCC) (FCC) (0FC) (3FC) (6FC) (9FC) (CFC) (FFC) (00F) (30F) (60F) (90F) (C0F) (F0F) (03F) (33F) (63F) (93F) (C3F) (F3F) (06F) (36F) (66F) (96F) (C6F) (F6F) (09F) (39F) (69F) (99F) (C9F) (F9F) (0CF) (3CF) (6CF) (9CF) (CCF) (FCF) (0FF) (3FF) (6FF) (9FF) (CFF) (FFF) ] def /showrg36 { /curcolor 0 store 0 1 5 {/ver exch store 0 1 5 {28 mul ver 28 mul util /curcolor curcolor 1 add store } for } for } def 30 50 translate showwebcolors % these are excerpts from my url insertin utilities.. % This code locks pdfmark commands out of a PostScript printer. /pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse % /surl "start url" marks the beginning of a text sequence to be urled. % It also paints the text blue... /surl {mark /blue cvx 0.33 /setgray cvx % change text to blue /currentpoint cvx % remember box start /urly /exch cvx /store cvx /urlx /exch cvx /store cvx ] cvx % complete deferred command printlist exch 3 index exch put % stuff into gonzo printlist exch 1 add exch % increment gonzo list count } def % /eurl "end url" unmarks the end of a text sequence and sets up % the pdfmark needed to define the Acrobat web link. /eurl {mark % start deferred proc exch % position url string /aqua cvx 0 /setgray cvx % turn blue marker off /makeurl cvx % defer call of url builder ] cvx % complete deferred proc printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } def % /makeurl generates the pdfmark, receiving a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /urlover 0.2 def % fraction of hot area over bounds /makeurl { /cururlname exch store % save the url string mark % start pdfmark currentfont /ScaleMatrix get 3 get /fsize exch store % guess height /Rect [ urlx fsize urlover mul sub % set box left x urly fsize urlover mul sub % set box left y currentpoint exch fsize urlover mul add exch fsize add ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def /webtint1 {(http://www.tinaja.com/psutils/webcolor1.psl)eurl} def font2 255 362 ("Web Friendly" PostScript & CSS Colors) cc font3 255 -27 (See |/surl http://www.tinaja.com/psutils/webcolor1.psl|/webtint1 \ for sourcecode & use details.) cc showpage %%%%%%%%%%%%%%%% % Note that the color number 0-215 is red*5 + green*30 + blue*180 % It is based on permissible RGB hex web colors being $00, $33, $66, $99, $CC, or $FF. % blue value = colornumber 36 idiv 5 div. % red/green residue = colornumber 36 mod. This should be a value from 0 to 35. % green value = red/green residue 6 idiv 5 div % red value = red/green/residude 6 mod 5 div. % color setting command is then R G B setrgbcolor. % This is done automatically by the colornum setwebtint above, using table lookup % instead of a math algorithm. %%%%%%%%%%%%%%%% %% EOF