TechNote 11: How to use the MakePict() and MakeShape functions -- November 5,1997
---------------------------------------------------------------------------------
Example of MakePict:
[Note: This was contributed by Stefen Kienecker (kienecker@mail.ppp.net) of Hamburg, Germany]
I send you a non optimized program for drawing a verhulst diagram using makepict(). It needs at least 52 kb free heap space and runs about two hours on an MP100.
0010 rem verhulst
0011 dim an[40]
0012 dim xn[40]
0013 let w1spec = {viewbounds: {left: 0, right:100, top: 0, bottom: 100},viewfill:nofill}
0015 GOSUB 8020 //call preload array an
0016 GOSUB 8045 //call preload array xn
0080 rem calculating section
0090 for i = 1 to 39
0100 let const = i*((4-2.7)/39)+2.7
0110 let x = random(0,100)/100
0120 for z = 1 to 139
0130 let x = const * x * (1-x)
0140 let j = ceiling(x*100)
0150 if z>=100 then gosub 0190
0160 next z
0170 next i
0180 end
0190 rem drawroutine
0200 let an[z-100]=makeline(i-1,j-1,i,j)
0210 let xn[i]=makepict(an,nil)
0230 wdraw wr,xn
0240 return
8010 rem preload of the arrays
8020 for ans = 0 to 39
8030 let an[ans]=makeline(3,3,3,3)
8040 next ans
8042 return
8045 for xns = 0 to 39
8050 let xn[xns]=makepict(an,nil)
8052 window wr,w1spec
8053 show wr
8054 wdraw wr,xn[xns]
8060 next xns
8070 return
any attempt to choose a higher dim - say 60 - causes a memory out.
[Additional information: makePict(shapeArray, StyleFrame) returns a picture shape created from a series of drawing operations, as a single entity. The picture shape returned is in PICT format.]
Example of MakeShape:
[Note: This was contributed by Len Lutz (lenlutz@dca.net) of Philadelphia, PA]
0010 rem newarrow
0020 cls
0030 LET ars_x := 280
0040 LET ars_y := 200
0050 LET y_diff = 40
0120 gosub draw_up_arrow //
0130 gosub draw_down_arrow //
0140 for i = 1 to 8
0150 wait 1000
0160 next i
0170 hide
0180 end
0500 draw_up_arrow: REM
0510 LET win_up_spec := { Gosub: 'up_hit, viewbounds:Setbounds(ars_x,ars_y,ars_x + 20,ars_y + 25), Viewformat: Vfframewhite}
0520 window up_win, win_up_spec
0530 show up_win
0540 LET Ar_ar := [3,8,10,0, 0,10, 5,10, 5,24, 15,24, 15,10, 20,10,10,0]
0550 LET points := Arraytopoints(ar_ar)
0560 LET shape := makeshape(points)
0570 wdraw up_win,shape
0580 return
0590 draw_down_arrow: REM
0600 LET win_down_spec := { Gosub: 'down_hit, viewbounds:Setbounds(ars_x,ars_y + y_diff,ars_x + 20,ars_y + y_diff + 25),viewformat: Vfframewhite}
0610 window down_win, win_down_spec
0620 show down_win
0630 LET Ar_ar := [3,8, 5,1, 5,15, 0,15, 10,25, 20,15, 15,15, 15,1, 5,1]
0640 LET points := Arraytopoints(ar_ar)
0650 LET shape := makeshape(points)
0660 wdraw down_win,shape
0670 return
0680 up_hit: REM
0690 print "HIT UP"
0700 return
0710 down_hit: REM
0720 print "HIT DOWN"
0730 return