Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!agate!ucbvax!astroatc.UUCP!tenaglia From: tenaglia@astroatc.UUCP (Chris Tenaglia) Newsgroups: comp.lang.icon Subject: (none) Message-ID: <8907231327.AA07154@astroatc.UUCP> Date: 23 Jul 89 13:27:43 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 149 Dear Icon-Group, Here is another goodie. It's targetted to unix machines and the unix plot utility. I use it with a TEK4014 emulation. One can do graphics using icon. This collection of procedures should be made into a ucode type library. Your graphics application would have a link statement to pull them together. Later I may include a sample program using this. Have fun ! Chris Tenaglia Astronautics Corporation of America 4115 N. Teutonia Avenue Milwaukee, Wi 53209 USA (414) 447-8200 X-421 ########################################################################## # # # draw.icn 5/23/89 by tenaglia # # # # this is a plotting library routine for icon in unix. # # use these procedures to generate plotting commands # # that can be piped into the unix plot command. # # # # usage: icont draw -c # generate the ucode library # # link draw # include routines when linking # # icont prog -x | plot # compile, run, & pipe into plot # # # ########################################################################## # # move to a given x,y screen location # procedure moveto(x,y) write("m",hex(x),hex(y)) return end # # draw to a given x,y screen location # procedure drawto(x,y) write("n",hex(x),hex(y)) return end # # dot at an x,y screen location # procedure dot(x,y) write("p",hex(x),hex(y)) return end # # plot from x1,y1 to x2,y2 # procedure plot(x1,y1,x2,y2) write("l",hex(x1),hex(y1),hex(x2),hex(y2)) return end # # label text to the screen at current location # procedure label(data) write("t",data,"\n") return end # # arc with x,y center sx,sy beginning point and # fx,fy finishing point. draws counterclockwise. # procedure arc(x1,y1,sx,sy,fx,fy) write("a",hex(x1),hex(y1),hex(sx),hex(sy),hex(fx),hex(fy)) return end # # circle with center at x,y and radius r # procedure circle(x,y,r) write("c",hex(x),hex(y),hex(r)) return end # # clear screen # procedure clear() write("e") return end # # this polyline routine takes a list as its parameter. # the list must have an even number of elements. # procedure polyline(pairs) if *pairs%2 = 1 then fail case *pairs of { 0 : return 2 : write("p",hex(pairs[1]),hex(pairs[2])) default : { write("m",hex(pairs[1]),hex(pairs[2])) every i := 3 to *pairs by 2 do write("n",hex(pairs[i]),hex(pairs[i+1])) } } return end # # style of line. parameter is a string that is either 'dotted', # 'solid', 'longdashed', 'shortdashed', or 'dotdashed' # procedure style(method) case method of { "dotted" : &null "solid" : &null "longdashed" : &null "shortdashed" : &null "dotdashed" : &null default : fail } write("f",method) return end # # window to set up coordinate space with x1,y1 as ll corner # and x2,y2 as ur corner. tek 4014 is (0,0,3120,3120) # procedure window(x1,y1,x2,y2) write("s",hex(x1),hex(y1),hex(x2),hex(y2)) return end # # hex converts a number to a 32 bit binary value # procedure hex(n) n := integer(n) n %:= 65536 if n < 0 then n+:=65536 return (char(integer(n%256)) || char(integer(n/256))) end # end of the graphics program