'=========================================================================== ' Subject: TWISTED BAR EFFECT Date: 06-20-97 (11:00) ' Author: The ABC Programmer Code: QB, QBasic, PDS ' Origin: voxel@freenet.edmonton.ab.ca Packet: GRAPHICS.ABC '=========================================================================== ' _______________________________________________________________________ ' / \ ' | TWISTED BAR EFFECT (or whatever) Pascal version | ' | | ' | Coded by me (inopia) when i had nothing to do (again?!). This time NO | ' | thanx to CONO, i did it all on my own! No small line routines ripped | ' | from your sources this time. This is the STRIPPED version. I also have | ' | one with a writer, but you don't care about all that. The public only | ' | wants the plain effect... So here you have it! It's probably the worst | ' | compilation of this well known effect ever, but don't come kick my ass | ' | around about it! | ' \_______________________________________________________________________/ ' ' Converted to BASIC code by William Yu (06-20-97) Public Domain. DECLARE SUB pal (colr%, red%, green%, blue%) DECLARE SUB sortx () DEFINT A-Z CONST pi = 3.141 DIM CosTab(0 TO 90) AS SINGLE 'Sinetable DIM SinTab(0 TO 90) AS SINGLE 'Cosinetable DIM SHARED x(0 TO 2) AS INTEGER 'Some X-values DIM SHARED x1(0 TO 399) AS INTEGER DIM SHARED x2(0 TO 399) AS INTEGER DIM SHARED x3(0 TO 399) AS INTEGER DIM SHARED L AS INTEGER DIM turntab(0 TO 825) AS INTEGER 'Table DIM origin(0 TO 2, 0 TO 1) AS INTEGER origin(0, 0) = -30 'The origin of the three points (x and z values) origin(0, 1) = -30 origin(1, 0) = 30 origin(1, 1) = -30 origin(2, 0) = 30 origin(2, 1) = 30 FOR I = 0 TO 90 CosTab(I) = (COS(I * (pi / 180))) ' Calculate NEXT I FOR I = 0 TO 90 SinTab(I) = (SIN(I * (pi / 180))) NEXT I FOR L = 0 TO 359 ' Calculate 360 possible rotations cnt = cnt + 1 IF cnt > 90 THEN cnt = 0 ' It's a cube, only two sides needed} 'Now calculate the x-values FOR I = 0 TO 2 x(I) = INT(CosTab(cnt) * origin(I, 0) + SinTab(cnt) * origin(I, 1)) + 50 NEXT I sortx ' Sort them NEXT L SCREEN 13 FOR I = 0 TO 127 CALL pal(I + 127, I, 0, 0) ' Nice palette (duh!) NEXT I FOR I = 0 TO 127 CALL pal(I, 0, 0, I) NEXT I ' Now calculate a table of rotations, this wil make the bar "twist" FOR J = 0 TO 825 turntab(J) = INT(COS(J / 100) * 100) + 100 NEXT J DO L = L + 3 ' If this goes too fast for ya, try increasing l by less than 3 IF L > 625 THEN L = 0 ' Make sure the table loops FOR I = 0 TO 199 J = turntab(L + I) ' Grab a value from the Turn-Table ' after 20 lines change color IF clr = 20 THEN IF S = 128 THEN S = 0 ELSE S = 128 clr = 0 END IF clr = clr + 1 LINE (x1(J), I)-(x3(J), I), (x3(J) - x1(J)) / 2 + S LINE (x3(J), I)-(x2(J), I), (x2(J) - x3(J)) / 2 + S LINE (0, I)-(x1(J), I), 0 LINE (x2(J), I)-(100, I), 0 NEXT I LOOP UNTIL INKEY$ <> "" END SUB pal (colr, red, green, blue) '{ sets palette } OUT &H3C8, colr OUT &H3C9, red OUT &H3C9, green OUT &H3C9, blue END SUB SUB sortx 'This sorts the xvalues from small -> big x1(L) = x(0) IF x(1) < x1(L) THEN x1(L) = x(1) IF x(2) < x1(L) THEN x1(L) = x(2) x2(L) = x(0) IF x(1) > x2(L) THEN x2(L) = x(1) IF x(2) > x2(L) THEN x2(L) = x(2) x3(L) = x(0) IF (x3(L) = x1(L)) OR (x3(L) = x2(L)) THEN x3(L) = x(1) IF (x3(L) = x1(L)) OR (x3(L) = x2(L)) THEN x3(L) = x(2) END SUB