'=========================================================================== ' Subject: ROTATE PICTURE 360 DEGREES Date: 01-28-98 (10:33) ' Author: David A. Wicker Code: QB, QBasic, PDS ' Origin: pyramax@fastlane.net Packet: GRAPHICS.ABC '=========================================================================== DEFINT A-Z '$DYNAMIC ' Free Rotate v0.23 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ' Thought up and Written by David A. Wicker Jan 28, 1998 ' pyramax@fastlane.net ' http://www.fastlane.net/~pyramax ' --------------------------------------------------------------------------- ' As always, if you borrow anything from any source code for your ' shareware projects, please give credit to the original author! ' --------------------------------------------------------------------------- ' DEFINT A-Z and '$DYNAMIC as the first two lines of every QBasic program ' ensure maximum speed and maximum memory capability. ' They are chiseled in every single program I write. DEF FNN$ (A) = MID$(STR$(A), 2) ' Easy way to convert a number to a string without the preceding space. SCREEN 13 ' Many a good graphic program and game are written in this favorite of all ' resolution modes, 320x200x256. You could be the next grand prize winner! ' :) PRINT PRINT CIRCLE (28, 28), 24, 13 PAINT (28, 28), 5, 13 ' Yes, we're using fixed size images for this example, but you can modify ' it to work with an image of any size, especially if you store the ' "string" as a random access file. PRINT " Hello" PRINT " There!" ' There is a preceding SPACE before each printed item because we want a ' little bit of BLACK pixel space to pad the rotation. Try taking out ' the spaces to see what happens. A$ = "H28" ' Jump UP and to the LEFT 28 spaces from our beginning start position. FOR I = 0 TO 55 FOR J = 0 TO 55 ' This LOOP will include J for horizontal position, and I for vertical. C = POINT(J, I) ' Read our pixel starting from LEFT to RIGHT. IF I MOD 2 = 1 THEN C = POINT(55 - J, I) ' Read our pixel starting from RIGHT to LEFT. A$ = A$ + "C" + FNN$(C) ' Change the color to the one selected. Note the use of FNN$. ' Type out DRAW on a blank line and hit F1 to see how this complex ' image drawing command works. Be sure to press [PGDN] once the help is ' up because there's more. IF J < 55 THEN IF I MOD 2 = 0 THEN A$ = A$ + "R" ELSE A$ = A$ + "L" ' Add our PLOT to the RIGHT or LEFT depending upon our vertical stepping. ' Please get in the habit of using ELSE in your programming instead of GOTO. END IF NEXT IF I < 55 THEN A$ = A$ + "BD" ' Move our plotter down one pixel WITHOUT drawing a dot behind it. NEXT LOCATE 8, 10 PRINT "Munched " + FNN$(LEN(A$)) + " string space!" ' See how much string space can get eaten with a DRAW pixel image! FOR I = 0 TO 720 STEP 4 ' Variable "I" represents the rotation factor, valued 0 to 359. DRAW "s4BM160,100TA" + FNN$(I MOD 360) + A$ ' Scale 4 (or 1 as QBasic divides by 4), plot in center of screen, ' Horizontal=160, Vertical=100, and then rotation plus the actual ' Image. ' NO DELAY is needed! It's quite slow enough on my pentium! :) NEXT