Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!astroatc.UUCP!tenaglia From: tenaglia@astroatc.UUCP (Chris Tenaglia) Newsgroups: comp.lang.icon Subject: (none) Message-ID: <8908011255.AA05853@astroatc.UUCP> Date: 1 Aug 89 12:55:25 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 81 Dear Icon-Group, ( I recently mailed this to icon-group but had it bounce back as undeliverable. I don't know if it made it or not, so I'm resending it. If it already has been posted, just ignore it. ) Here's a sample icon program that takes advantage of the drawing procedures I recently posted. It will generate the recursive Sierpinski triangle. You need a unix system, a tektronix 4014 compatible terminal or emulator, icon, and the drawing procedures compiled to ucode. Step 1. Cut the rest of this file from the # banner on down. Step 2. Compile it (icont triang). draw.u1 & draw.u2 should also be in the same directory. Step 3. Run it. (iconx triang | plot). Step 4. Answer the question and enjoy the picture. Yours truly, Chris Tenaglia Astronautics Corporation of America 4115 N. Teutonia Avenue Milwaukee, Wi 53209 USA (414) 447-8200 X-421 ######################################################### # # # TRIANG.ICN 7/19/89 BY TENAGLIA # # # # SIERPINSKI TRIANGLE GENERATOR USING RANDOM FRACTALS # # # ######################################################### link draw global kbd,crt procedure main(p) # # INITIALIZATION # crt := open("/dev/tty","w") ; kbd := open("/dev/cons") &random := map(&clock,":","0") (points := numeric(p[1])) | (points:=numeric(input("_Points>"))) | stop("Points must be integer > 1") px := [] ; py := [] w := 4000 ; h := 3200 window(0,0,w,h) clear() every 1 to 3 do { put(px,?w) put(py,?h) } px |||:= px ; py |||:= py # # ILLUSTRATE # plot(px[1],py[1],px[2],py[2]) drawto(px[3],py[3]) ; drawto(px[1],py[1]) x := ?w ; y := ?h every 1 to points do { p := ?6 x1 := px[p] ; y1 := py[p] x2 := integer((x1 - x) / 2.0 + x) y2 := integer((y1 - y) / 2.0 + y) dot(x2,y2) ; x := x2 ; y := y2 } label("\007Done.") ; read() end # # GET INPUT FROM CONSOLE # procedure input(prompt) writes(crt,prompt) ; value := read(kbd) return value end # END OF PROGRAM