If you are unfamiliar with the term inbetweening, you will probably have seen the effect as it is used not infrequently on television in title sequences and the like. In essence, inbetweening involves defining two shapes, and then generating a series of intermediate shapes so that one object appears to be transformed step by step into the other. Visually it is often only quite near the end of the process that the new shape reveals itself meaningfully to the watcher.
Of course, the larger the number of steps taken, and the smaller the change from one position to the next, the smoother and more impressive the transformation appears. That's where the power of the Archimedes comes in.
The program listed here is really only a demonstration of the technique using wire-frame shapes, and can be developed considerably if required. Type the program in and save it away. When run, it asks you to define the first shape using the mouse. Move the pointer to a suitable starting position and press Select. Now continue to move the pointer, pressing Select at each corner, until you reach the last point you want to include in your definition, when you should press Adjust.
Once you have completed the first shape, you will be asked to define the second. The second shape MUST have the same number of defined points as the first. For this reason, there is no need to press Adjust rather than Select on the last point, as the program will have been counting the number of points entered.
Once both shapes have been defined, the program immediately commences transforming from one to the other, and then back again, repeating the whole process indefinitely. Pressing any mouse button during this time will return you to the starting point of the program ready to define two new shapes. Pressing Escape will exit from the program altogether.
If you define both shapes in the same position on the screen then one object gradually turns into the other. If you define one shape to the left of the screen, and the other to the right then you will see the object moving across the screen as the changes occur. If you find you need fewer points in one shape than the other, then several points can all be defined in the same position and will appear as a single point on the screen.
In the program, the arrays are dimensioned sufficient for 100 points, and 100 steps are used in transforming from one to the other. Both values are set near the start of the program, and may be changed as required. The speed of transformation is artificially slowed down by the procedure PROCwait. Change the parameter used (smaller numbers mean faster speed), or the definition itself if you wish.
Our illustration shows a Christmas tree being transformed into a castle, but we are sure you will be able to find many more ingenious applications.
10 REM >Morph
20 REM Program Inbetweening
30 REM Version A 1.02
40 REM Author S.S.Pardesi
50 REM RISC User September 1989
60 REM Program Subject to Copyright
70 :
80 MODE 0:OFF
90 ON ERROR MODE12:PRINT REPORT$;" at line ";ERL:END
100 lim=100:sec=100
110 DIM X1(lim,1),Y1(lim,1),X2(lim,1),Y2(lim,1),SX(lim,1),SY(lim,1)
120 *POINTER
130 MOUSE RECTANGLE 0,0,1279,800
140 REPEAT
150 CLS:p1=0:p2=0:f=0
160 PRINT TAB(2,1);"This program allows you to draw two pictures, the computer will then animate"
170 PRINT TAB(2,2);"one picture into the other. To begin drawing, press the Select button to plot"
180 PRINT TAB(2,3);"the points of your picture, to end press the Adjust button."
190 PRINT TAB(10,5);"Number of points so far: "
200 REPEAT
210 PROCdraw(X1(),Y1(),p1)
220 UNTIL bu=1
230 REM * DRAW SECOND SHAPE *
240 exit=FALSE:CLS:f=0
250 PRINT TAB(20,2);"Number of points in FIRST picture: ";p1
260 PRINT TAB(20,4);"Number of points in SECOND picture: "
270 REPEAT
280 PROCdraw(X2(),Y2(),p2)
290 UNTIL p2=p1
300 REM * CALC STEP SIZES *
310 FOR I=1 TO p1
320 SX(I,1)=((X1(I,1)-X2(I,1))/sec)
330 SY(I,1)=((Y1(I,1)-Y2(I,1))/sec)
340 NEXT I
350 REM * TRANSFORM SHAPES *
360 exit=FALSE
370 REPEAT
380 PROCtransform(1,sec-1,1,1,p1-1,1)
390 IF NOT exit PROCtransform(sec-1,1,-1,p1-1,1,-1)
400 UNTIL exit
410 UNTIL FALSE
420 END
430 :
440 DEF PROCtransform(I1,I2,IS,J1,J2,JS)
450 FOR I=I1 TO I2 STEP IS
460 FOR J=J1 TO J2 STEP JS
470 LINE X2(J,1)+(SX(J,1)*I),Y2(J,1)+(SY(J,1)*I),X2(J+1,1)+(SX(J+1,1)*I),Y2(J+1,1)+(SY(J+1,1)*I)
480 MOUSE xpos,ypos,bu
490 IF bu<>0 THEN J=JS+1:I=IS+1:exit=TRUE
500 NEXT J
510 WAIT:PROCwait(0.3):CLS
520 NEXT I
530 ENDPROC
540 :
550 DEF PROCdraw(X(),Y(),RETURN p)
560 MOUSE xpos,ypos,bu
570 IF f=0 THEN MOVE xpos,ypos
580 IF bu=4 OR bu=1 THEN
590 DRAW xpos,ypos
600 p=p+1:f=1
610 X(p,1)=xpos:Y(p,1)=ypos
620 PROCwait(5)
630 PRINT TAB(36,5);p
640 ENDIF
650 ENDPROC
660 :
670 DEF PROCwait(t):endt=4*t
680 TIME=0:REPEAT:UNTIL TIME>endt
690 ENDPROC