Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Rattrapmax6 on October 06, 2006
-
:) I was setting around watching demos, and morphing shapes, so I broke some of my bad coders block and got to messing with interpolation effects to make a field of pixels morph into a circle, and explode back agian. Simple, but something to get me out of my no code spell:
OPTION EXPLICIT
WINDOWTITLE "Rattra Roxz!: Morphing!"
SCREENRES 400, 400, 32, 2
DIM AS BYTE P1, P2 = 1
DIM AS INTEGER CENTX = 200, CENTY = 200, MAXPOINTS = 360, InterPol = 70, MORPH = 1, INIT, i, ang
DIM AS INTEGER Count
TYPE TwoD
X AS SINGLE
Y AS SINGLE
END TYPE
DIM AS TwoD Points(MAXPOINTS)
DIM AS TwoD Move(MAXPOINTS)
DIM AS TwoD Points1(MAXPOINTS)
FOR i = 1 TO MAXPOINTS
Points1(i).X = (RND * 1000) - 500
Points1(i).Y = (RND * 1000) - 500
NEXT
DIM AS TwoD Points2(MAXPOINTS)
FOR i = 1 TO MAXPOINTS
Points2(i).X = COS((i*(360/MAXPOINTS)) * 3.14/180)*100 + CENTX'(RND * 400)
Points2(i).Y = SIN((i*(360/MAXPOINTS)) * 3.14/180)*100 + CENTY'(RND * 400)
NEXT
DO
SCREENSET P1, P2
SWAP P1, P2
CLS
IF INIT = 0 THEN
INIT = 1
FOR i = 1 TO MAXPOINTS
Points(i).X = Points1(i).X
Points(i).Y = Points1(i).Y
Move(i).X = (Points1(i).X - Points2(i).X) / InterPol
Move(i).Y = (Points1(i).Y - Points2(i).Y) / InterPol
NEXT
END IF
IF MORPH = 1 THEN
FOR i = 1 TO MAXPOINTS
Points(i).X = Points(i).X - Move(i).X
Points(i).Y = Points(i).Y - Move(i).Y
NEXT
Count += 1
IF Count >= InterPol THEN MORPH = 2: Count = 0
ELSE
FOR i = 1 TO MAXPOINTS
Points(i).X = Points(i).X + Move(i).X
Points(i).Y = Points(i).Y + Move(i).Y
NEXT
Count += 1
IF Count >= InterPol THEN MORPH = 1: Count = 0
END IF
FOR i = 1 TO MAXPOINTS
PSET (Points(i).X, Points(i).Y)
NEXT
SLEEP 100
LOOP UNTIL INKEY = CHR$(27)
And to add to that, I made a small image fade/morph effect also, enjoy! :||
www.random-seed.net/xtrgraphics/Temp/Fade_Images.zip (http://www.random-seed.net/xtrgraphics/Temp/Fade_Images.zip)
-
really enjoyed that mate O0
nice stuff indeed!
-
Looks pretty cool Rattra :) Thanks for posting the code! Would look even more excellent if it morphed between 2 objects, perhaps a logo and the circle?
Looks good though.
-
Okay, remade it with my logo and the circle:
http://www.random-seed.net/xtrgraphics/Temp/Morph_IMG_OBJ.zip
:) Enjoy!..
-
That makes a really nice transition :) Nice one Rattra.
-
That is a really cool effect - well done!
Drew