'=========================================================================== ' Subject: DOT MORPHING Date: 05-24-97 (15:20) ' Author: Daniel Davies Code: QB, QBasic, PDS ' Origin: ia53@rapid.co.uk Packet: GRAPHICS.ABC '=========================================================================== '*** DOT MORPHING PROGRAM IN Q-BASIC BY DANIEL DAVIES '*** IF YOU USE THESE ROUTINES IN ANYTHING WOULD YOU PLEASE GIVE ME CREDIT '*** AND E-MAIL ME AT THE ADDRESS BELOW TELLING ME ABOUT IT. '*** E-MAIL: ia53@rapid.co.uk DEFINT A-Z '*** INITIALSE THE SCREEN SCREEN 7, , 0, 1 '*** SET DATA TYPE FOR MOVEMENT OF POINTS AND CO-ORDINATES TYPE pixel x AS INTEGER y AS INTEGER END TYPE TYPE inc x AS DOUBLE y AS DOUBLE END TYPE '*** READ THE NUMBER OF POINTS IN EACH OBJECT READ np '*** DIMENSION ARRAYS TO THE NUMBER OF POINTS DIM start(0 TO np) AS pixel DIM endp(0 TO np) AS pixel DIM current(0 TO np) AS inc DIM increment(0 TO np) AS inc '*** SET THE NUMBER OF FRAMES TO DO THE DOT MORPH OVER frames = 200 '*** SET CURRENT FRAME TO START FRAME FOR x = 1 TO np READ start(x).x, start(x).y current(x).x = start(x).x current(x).y = start(x).y NEXT x '*** SET STUFF REQUIRED TO DRAW POLYGONS. start(0).x = start(1).x start(0).y = start(1).y current(0).x = start(np).x current(0).y = start(np).y '*** READ IN OBJECTS FOR x = 1 TO np READ endp(x).x, endp(x).y NEXT x '*** CALCULATE DISTANCE TO MOVE EACH POINT PER FRAME FOR x = 1 TO np increment(x).x = (endp(x).x - start(x).x) / frames increment(x).y = (endp(x).y - start(x).y) / frames NEXT x '*** THE MAIN LOOP DO '*** MORPH FROM START TO END FRAME FOR Q = 1 TO frames '*** INCREMENT POINTS BY VALUE FOR EACH FRAME FOR x = 1 TO np current(x).x = current(x).x + increment(x).x current(x).y = current(x).y + increment(x).y NEXT x '*** DRAW THE POLYGON FOR y = 1 TO np - 1 LINE (current(y).x, current(y).y)-(current(y + 1).x, current(y + 1).y) NEXT y LINE (current(np).x, current(np).y)-(current(1).x, current(1).y) '*** COPY THE HIDDEN PAGE TO THE VISIBLE PAGE AND BLANK HIDDEN PAGE. PCOPY 0, 1 CLS '*** CHECK FOR KEYPRESSES Z$ = INKEY$: IF Z$ <> "" THEN GOTO ENDIT: NEXT Q '*** THE BOUNCE BACK STAGE FOR Q = 1 TO frames '*** MOVE POINT BACK BY INCREMENT FOR EACH POINT FOR x = 1 TO np current(x).x = current(x).x - increment(x).x current(x).y = current(x).y - increment(x).y NEXT x '*** DRAW POLYGON FOR y = 1 TO np - 1 LINE (current(y).x, current(y).y)-(current(y + 1).x, current(y + 1).y) NEXT y LINE (current(np).x, current(np).y)-(current(1).x, current(1).y) '*** SHOW HIDDEN PAGE THEN BLANK IT PCOPY 0, 1 CLS '*** CHECK FOR KEYPRESS Z$ = INKEY$: IF Z$ <> "" THEN GOTO ENDIT: NEXT Q LOOP '*** END THE PROGRAM ENDIT: SCREEN 0 WIDTH 80, 25 CLS '*** THE OBJECTS '*** THE DESCRIPTIONS FOR OBJECTS ARE VERY SIMPLE THEY ARE A LIST OF THE '*** POINTS CO-ORDINATES AND FROM THESE TWO KEYFRAMES THE COMPUTER GENERATES '*** TWEENS (IN BETWEEN FRAMES) AND DISPLAYS THEM. '*** THE NUMBER OF POINTS IN EACH OBJECT DATA 18 '*** THE FIRST OBJECT DATA 211,184 DATA 256,168 DATA 289,144 DATA 307,115 DATA 307,84 DATA 289,54 DATA 256,31 DATA 211,15 DATA 159,10 DATA 108,15 DATA 63,31 DATA 30,55 DATA 12,84 DATA 12,115 DATA 30,145 DATA 63,168 DATA 108,184 DATA 160,189 '*** THE SECOND OBJECT DATA 80,130 DATA 90,160 DATA 130,160 DATA 140,130 DATA 120,130 DATA 120,100 DATA 140,90 DATA 150,80 DATA 150,60 DATA 140,40 DATA 110,30 DATA 100,30 DATA 80,40 DATA 70,60 DATA 70,80 DATA 80,90 DATA 100,100 DATA 100,130