#! /usr/NeWS/bin/psh
	%
	% This file is a product of Sun Microsystems, Inc. and is provided for
	% unrestricted use provided that this legend is included on all tape
	% media and as a part of the software program in whole or part.
	% Users may copy, modify or distribute this file at will.
	%
	% THIS FILE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
	% WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
	% PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
	%
	% This file is provided with no support and without any obligation on the
	% part of Sun Microsystems, Inc. to assist in its use, correction,
	% modification or enhancement.
	%
	% SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
	% INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS FILE
	% OR ANY PART THEREOF.
	%
	% In no event will Sun Microsystems, Inc. be liable for any lost revenue
	% or profits or other special, indirect and consequential damages, even
	% if Sun has been advised of the possibility of such damages.
	%
	% Sun Microsystems, Inc.
	% 2550 Garcia Avenue
	% Mountain View, California  94043
	%
    % Copyright (c) 1988 by Sun Microsystems, Inc.

systemdict /Item known not { (NeWS/liteitem.ps) run } if
/LabelFont /Times-Bold findfont 14 scalefont def

/barWidth 256 def
/barHeight 30 def
/range 100 def

/hue 1 def /sat 1 def /bri 1 def
/paintBox { can setcanvas gsave 338 75 63 63 rectpath
 hue sat bri sethsbcolor fill grestore} def
/notify { (Notify: Value=%) [ItemValue] /printf messages send } def
/setNP {/DefaultRootGrayOrColor hue sat bri hsbcolor store PaintRoot} def
/hueNP { /hue ItemValue range div store paintBox paintSat paintBri} def
/satNP { /sat ItemValue range div store paintBox paintHue paintBri} def
/briNP { /bri ItemValue range div store paintBox paintHue paintSat} def
/FillColor  1 1 1 rgbcolor def

/paintHSB { paintHue paintSat paintBri } def
/paintHue {
	items /HueSlide get /ItemCanvas get setcanvas
	0 1 barWidth
	  {
		/x exch def
		/val x barWidth div def
		x 2 add 0 moveto val sat bri hsbcolor setcolor 0 22 rlineto stroke
	  } for
} def
/paintSat {
	items /SatSlide get /ItemCanvas get setcanvas
	0 1 barWidth
	  {
		/x exch def
		/val x barWidth div def
		x 2 add 0 moveto hue val bri hsbcolor setcolor 0 22 rlineto stroke
	  } for
} def
/paintBri {
	items /BriSlide get /ItemCanvas get setcanvas
	0 1 barWidth
	  {
		/x exch def
		/val x barWidth div def
		x 2 add 0 moveto hue sat val hsbcolor setcolor 0 22 rlineto stroke
	  } for
} def

/createitems {
/items 50 dict dup begin
    
    /setButton (set) /setNP can 63 63 /new ButtonItem send
        dup /ItemBorderColor .5 .5 .5 rgbcolor put
        338 3 /move 3 index send def
    /HueSlide   () [0 range range] /Top /hueNP can barWidth barHeight
    	/new SliderItem send 73 103 /move 3 index send def
    /SatSlide () [0 range range] /Top /satNP can barWidth barHeight
    	/new SliderItem send 73 53 /move 3 index send def
    /BriSlide  () [0 range range] /Top /briNP can barWidth barHeight
    	/new SliderItem send 73 3 /move 3 index send def
        
end def
} def

/main {
    /win framebuffer /new LiteWindow send def	% Create a window
    {	
		/FrameLabel	(H S B    B a c k g r o u n d) def
		/PaintClient {
			gsave
			FillColor fillcanvas items paintitems
    		LabelFont setfont
			0 setgray		
			5 105 moveto (Hue) show
			5  55 moveto (Saturation) show
			5   5 moveto (Brightness) show
			paintBox
			paintHSB
			stroke
			grestore
		} def
    } win send						% Install my stuff.
%   200 200 412 155 /reshape win send			% Shape it.
    200 200 452 175 /reshape win send			% Shape it.
    /can win /ClientCanvas get def			% Get the window canvas
    
    createitems
    
    /map win send		% Map the window & install window event manager.
    /itemmgr items forkitems def
} def

main


