%%BeginResource: procset colours % % See http://www.pjb.com.au/comp/colours.html % % (/home/wherever/ps/lib/line_drawing.ps) run % (/home/wherever/ps/lib/colours.ps) run % palegreen setrgbcolor % blue 0.6 grey 0.4 rgbmix setrgbcolor % /darkskin paleorange 0.4 brown 0.6 rgbmix rgbdef % darkskin setrgbcolor % /contourcolour [ 0 blue 50 yellow 100 green 150 grey 200 white ] % altitude rgbinterpolate rgbdef % /equivalentgray palegreen rgb2gray def % orange equivalentgray adjustbrightness setrgbcolor % orange palegreen rgb2gray adjustbrightness setrgbcolor % % See also line_drawing.ps, see www.pjb.com.au/comp/line_drawing.html % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This Postscript is Copyright (c) 2000, Peter J Billam % % c/o P J B Computing, GPO Box 669, Hobart TAS 7001, Australia % % % % Permission is granted to any individual or institution to use, copy, % % modify or redistribute this software, so long as it is not resold for % % profit, and provided this notice is retained. Neither Peter Billam % % nor P J B Computing make any representations about the suitability % % of this software for any purpose. It is provided "as is", without any % % express or implied warranty. http://www.pjb.com.au % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 20060121 adjustbrightness defends against division by 0 /white { 1 1 1 } def /lightgrey { 0.95 0.95 0.95 } def /lightgray { 0.95 0.95 0.95 } def /grey { 0.9 0.9 0.9 } def /gray { 0.9 0.9 0.9 } def /mediumgrey { 0.8 0.8 0.8 } def /mediumgray { 0.8 0.8 0.8 } def /darkgrey { 0.6 0.6 0.6 } def /darkgray { 0.6 0.6 0.6 } def /black { 0 0 0 } def /darkred { 0.6 0 0 } def /red { 1 0 0 } def /palered { 1 0.75 0.75 } def /pink { 1 0.75 0.75 } def /orange { 1 0.7 0.0 } def /paleorange { 1 0.85 0.75 } def /darkbrown { 0.5 0.4 0.4 } def /brown { 0.7 0.55 0.55 } def /palebrown { 0.88 0.84 0.82 } def /yellow { 1 1 0 } def /darkgreen { 0 .6 0 } def /green { 0 1 0 } def /palegreen { 0.75 1 0.75 } def /darkblue { 0 0 0.6 } def /blue { 0 0 1 } def /paleblue { 0.75 0.75 1 } def /darkviolet { 0.5 0.15 0.5 } def /violet { 0.7 0.2 0.7 } def /paleviolet { 1 0.75 1 } def /rgbmix { % usage : colour1 weight1 colour2 weight2 rgbmix /rgbmix_w2 exch def /rgbmix_b2 exch def /rgbmix_g2 exch def /rgbmix_r2 exch def /rgbmix_w1 exch def /rgbmix_b1 exch def /rgbmix_g1 exch def /rgbmix_r1 exch def % normalise weights ... rgbmix_w1 0.0 lt { /rgbmix_w1 0.0 def } if rgbmix_w2 0.0 lt { /rgbmix_w2 0.0 def } if /rgbmix_tot rgbmix_w1 rgbmix_w2 add def /rgbmix_w1 rgbmix_w1 rgbmix_tot div def /rgbmix_w2 rgbmix_w2 rgbmix_tot div def % leave mixed colour on stack ... rgbmix_r1 dup mul rgbmix_w1 mul rgbmix_r2 dup mul rgbmix_w2 mul add sqrt rgbmix_g1 dup mul rgbmix_w1 mul rgbmix_g2 dup mul rgbmix_w2 mul add sqrt rgbmix_b1 dup mul rgbmix_w1 mul rgbmix_b2 dup mul rgbmix_w2 mul add sqrt } bind def /rgbinterpolate { % usage: [ a1 colour1 .. aN colourN ] a rgbinterpolate % It is expected that a1,a2..aN are in ascending order ! % If a is a1 or less, colour1 will be returned, % if a is between a1 and a2, rgbmix is used to interpolate between them, % If a is a2 colour2 will be returned, % if a is between a2 and a3, rgbmix is used to interpolate between them, % if a is aN or more, colourN will be returned. eg: % [ .5 paleblue .51 white 1.0 mediumgray ] z rgbinterpolate setrgbcolor % would transform a brownian landscape into sky with clouds ... /colours_a exch def /colours_array exch def /colours_n colours_array length def colours_a colours_array 0 get le { colours_array 1 get colours_array 2 get colours_array 3 get } { colours_a colours_array colours_n 4 sub get ge { colours_array colours_n 3 sub get colours_array colours_n 2 sub get colours_array colours_n 1 sub get } { /colours_i 0 def { colours_i colours_n ge { exit } if colours_a colours_array colours_i get ge colours_a colours_array colours_i 4 add get le and { colours_array colours_i 1 add get colours_array colours_i 2 add get colours_array colours_i 3 add get colours_array colours_i 4 add get colours_a sub colours_array colours_i 5 add get colours_array colours_i 6 add get colours_array colours_i 7 add get colours_a colours_array colours_i get sub rgbmix exit } if /colours_i colours_i 4 add def } loop } ifelse } ifelse } bind def % currentcolorspace 0 get 256 string cvs % e.g. DeviceGray or DeviceRGB /nonlinearise { % usage: weight halfpoint nonlinearise % weight is 0..1 halfpoint is 0..1 % weight=0 returns 0 weight=halfpoint returns 0.5 weight=1 returns 1 0.5 ln exch abs ln div exp % BUG must defend exp against out-of-range args } bind def /nonlinearrgbmix { % usage : colour1 colour2 weight halfpoint nonlinearrgbmix % eg. red blue weight .75 nonlinearrgbmix produces mostly reddish % red blue weight .25 nonlinearrgbmix produces mostly blueish nonlinearise dup 3 1 roll 1.0 exch sub rgbmix } bind def /rgbdef { % usage: /name_of_colour r g b rgbdef /rgbdef_b exch def /rgbdef_g exch def /rgbdef_r exch def % This is Really Ugly stuff; Postscript is not made for string handling. /rgbdef_s 60 string def ( ) rgbdef_s copy 0 rgbdef_r 60 string cvs dup length /rgbdef_l exch def putinterval rgbdef_s 20 rgbdef_g 40 string cvs putinterval rgbdef_s 40 rgbdef_b 20 string cvs putinterval rgbdef_s 60 string copy cvx def } bind def /callibrate_rgb2gray 0.15 def % user-settable 0..1 /rgb2gray { % usage: /equivalentgray r g b rgb2gray def callibrate_rgb2gray 0.0 eq { .11 mul 3 1 roll .59 mul 3 1 roll .3 mul add add } { /rgb2gray_b exch def /rgb2gray_g exch def /rgb2gray_r exch def rgb2gray_r rgb2gray_g ge rgb2gray_r rgb2gray_b ge and { /rgb2gray_g rgb2gray_r rgb2gray_g sub callibrate_rgb2gray mul rgb2gray_g add def /rgb2gray_b rgb2gray_r rgb2gray_b sub callibrate_rgb2gray mul rgb2gray_b add def } { rgb2gray_g rgb2gray_r ge rgb2gray_g rgb2gray_b ge and { /rgb2gray_r rgb2gray_g rgb2gray_r sub callibrate_rgb2gray mul rgb2gray_r add def /rgb2gray_b rgb2gray_g rgb2gray_b sub callibrate_rgb2gray mul rgb2gray_b add def } { /rgb2gray_r rgb2gray_b rgb2gray_r sub callibrate_rgb2gray mul rgb2gray_r add def /rgb2gray_g rgb2gray_b rgb2gray_g sub callibrate_rgb2gray mul rgb2gray_g add def } ifelse } ifelse rgb2gray_r .3 mul rgb2gray_g .59 mul rgb2gray_b .11 mul add add } ifelse } bind def /rgbdup { % usage: r g b rgbdup -> r g b r g b 3 copy } bind def /adjustbrightness { % usage: r g b graylevel adjustbrightness % find rgb2gray, and scale. If any component is >1, then scale back % to set it =1, then mix with white to get desired graylevel. /adjbr_gray exch def adjbr_gray 1.0 gt { /adjbr_gray 1.0 def } if adjbr_gray 0.01 lt { /adjbr_gray 0.01 def } if 3 copy rgb2gray adjbr_gray div /adjbr_a exch def adjbr_a 0.01 lt { /adjbr_a 0.01 def } if /adjbr_b exch adjbr_a div def /adjbr_g exch adjbr_a div def /adjbr_r exch adjbr_a div def /adjbr_max adjbr_r def adjbr_max adjbr_g lt { /adjbr_max adjbr_g def } if adjbr_max adjbr_b lt { /adjbr_max adjbr_b def } if adjbr_max 1.0 gt { % we must decrease the saturation (mix with white) /adjbr_r adjbr_r adjbr_max div def /adjbr_g adjbr_g adjbr_max div def /adjbr_b adjbr_b adjbr_max div def % we mix linearly :-( % could also 2) binary search using rgbmix or 3) explicitly callibrate_rgb2gray .98 gt { /callibrate_rgb2gray .98 def } if /adjbr_w 1.0 adjbr_gray sub 1.0 0.3 adjbr_r mul .59 adjbr_g mul .11 adjbr_b mul add add sub div 1.0 callibrate_rgb2gray sub div def /adjbr_r adjbr_r adjbr_w mul 1.0 add adjbr_w sub def /adjbr_g adjbr_g adjbr_w mul 1.0 add adjbr_w sub def /adjbr_b adjbr_b adjbr_w mul 1.0 add adjbr_w sub def } if adjbr_r adjbr_g adjbr_b % return } def % not bind in case the user wants to overwrite rgb2gray ... %%EndResource