[comp.windows.news] A whimsical memorial

sjs@spectral.ctt.bellcore.com (Stan Switzer) (01/30/89)

In memory of Salvador Dali I submit a modification of the standard
"roundclock" tool.

The enclosed shar file contains only the differences between the
standard "roundclock" and the Daliesque version.  The Makefile already
knows how to edit in the changes so you don't have to bother with it
but you'll have to change the CLSRC macro if your client source is
installed in an unususl place.

NOTE: Since the shar file creates a file named "Makefile", you'll
probably want to run it in a new directory.

This turned out to be a bit more tedious than I expected because it's
difficult to create a path which is the union of the intersections of
paths.

Stan Switzer  sjs@ctt.bellcore.com
  "I do not use drugs. I _am_ drugs." -- Salvador Dali

------- cut here -------
#!/bin/sh
CLSRC=/usr/NeWS/clientsrc/client
if test -f Makefile; then echo File Makefile exists!; exit 1; fi
sed -e 's/^X//' <<'EOF' >Makefile
XCLSRC=/usr/NeWS/clientsrc/client
X
X.SUFFIXES: .h .cps .diff
X
X.cps.h:
X	cps $*.cps
X
XCFLAGS = -O -I/usr/NeWS/include
X
XALL: daliclock
X
Xdaliclock: daliclock.o
X	cc -o $@ daliclock.o /usr/NeWS/lib/libcps.a
X
Xdaliclock.o: daliclock.c daliclock.h
X
Xdaliclock.cps:
X	cat $(CLSRC)/roundclock.cps >daliclock.cps
X	ed daliclock.cps <cps.diff
X
Xdaliclock.c:
X	cat $(CLSRC)/roundclock.c >daliclock.c
X	ed daliclock.c <c.diff
X	
Xshar: Makefile daliclock.c daliclock.cps
X	{ { diff -e $(CLSRC)/roundclock.cps daliclock.cps||true;};echo w;} >cps.diff
X	{ { diff -e $(CLSRC)/roundclock.c daliclock.c||true;};echo w;} >c.diff
X	{ echo "#!/bin/sh"; \
X	  echo CLSRC="$(CLSRC)"; \
X	  for F in Makefile c.diff cps.diff; do \
X	    echo "if test -f $$F; then echo "File $$F exists!"; exit 1; fi"; \
X	    echo "sed -e 's/^X//' <<'EOF' >$$F"; \
X	    sed -e 's/^/X/' <$$F; \
X	    echo "EOF"; \
X	  done; \
X	} > shar
X
EOF
if test -f c.diff; then echo File c.diff exists!; exit 1; fi
sed -e 's/^X//' <<'EOF' >c.diff
X48c
X#include "daliclock.h"
X.
Xw
EOF
if test -f cps.diff; then echo File cps.diff exists!; exit 1; fi
sed -e 's/^X//' <<'EOF' >cps.diff
X99c
X    fill } dopaint
X.
X97c
X    { rot rotate newpath -5 0 moveto 0 0 5 180 360 arc
X.
X88,89c
X    { rot rotate 0 0 moveto 0 rad rlineto stroke } dopaint
X.
X72c
X	calctransform
X	{ drawclockframe } dopaint
X	clipcanvas
X.
X66c
X	{ FrameWidth 100 div FrameHeight 100 div } window send scale
X.
X55,56c
X	    KeyFocus? {KeyFocusColor} {backgroundcolor} ifelse setcolor
X	    calctransform
X	    { 0 0 40 0 360 arc stroke } dopaint
X.
X46,47c
X	    FrameWidth 100 div FrameHeight 100 div scale
X	    50 50 translate
X	    0 0 50 A1 A2 arc
X	    xform
X	    0 0 50 A2 A1 arc
X	    FrameCanvas setcanvasshape
X.
X44a
X	    /FrameHeight FrameHeight
X	        50 rY sub H mul 50 rY add add 100 div div cvi def   
X.
X40c
X	/IconLabel (DaliClock) def
X	/IconImage /iconedit def
X	/ClientMinWidth 4 def /ClientMinHeight 4 def
X.
X37a
X    % /rX 50 def /rY -20 def /Ang -30 def /A1 141 def /A2 338 def /Sk .7 def /H 1 def
X    % /rX 50 def /rY 15 def /Ang 0 def /A2 17.5 def /A1 180 A2 sub def /Sk 1.2 def /H .5 def
X    % /rX 50 def /rY 15 def /Ang 0 def /A2 17.5 def /A1 180 A2 sub def /Sk 1.5 def /H .4 def
X    /rX 50 def /rY 15 def /Ang 0 def /A2 17.5 def /A1 180 A2 sub def /Sk 1.7 def /H .3 def
X    /xform {
X	rX rY translate
X	Ang rotate
X	[ 1 0 Sk H 0 0 ] concat
X	Ang neg rotate
X	rX neg rY neg translate
X    } def
X    /lowclip {
X	matrix currentmatrix
X	-50 -50 moveto 100 0 rlineto 0 50 rY add rlineto
X	Ang rotate -200 0 rlineto closepath clip
X	setmatrix
X    } def
X    /hiclip {
X	matrix currentmatrix
X	-50 50 moveto 100 0 rlineto 0 -50 rY add rlineto
X	Ang rotate -200 0 rlineto closepath clip
X	setmatrix
X    } def
X    /dopaint { % proc =>
X	dup gsave lowclip exec grestore
X	gsave xform hiclip exec grestore
X    } def
X.
X36a
X% Daliesque modifications by Stan Switzer sjs@ctt.bellcore.com 1/28/89
X%   Explaination of parameters:
X%     Assuming circle inscribes a square in [-50,50]X[-50,50] square
X%	(rX,rY) intersection of bend line with right edge of boundin square
X%	Ang	angle of intersection
X%	A1	angle from (0,0) to left intersection of bend with circle
X%	A2	angle from (0,0) to right intersection of bend with circle
X%	Sk	skew factor above bend
X%	H	height factor above bend
X% Each set of parameters below gives interesting results.
X% The first is the most complex, but the last (in my opinion) gives the
X% most realistinc 3D effect as it can be "draped" over the edge of another
X% window for comic/artictic effect.
X
X.
Xw
EOF

sjs@spectral.ctt.bellcore.com (Stan Switzer) (01/30/89)

One more thing:

The effect is most (sur)realistic when the clock is draped over the
edge of some other window.

Stan Switzer  sjs@ctt.bellcore.com
 "The Exterminator does a good job," said the Sailor.
 "Almost too good sometimes."