• Welcome to Dark Bit Factory & Gravity.
 

Morphing Stuff....

Started by Rattrapmax6, October 06, 2006

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rattrapmax6

 :) 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
-Rattra (x.t.r.GRAPHICS)

ninogenio

really enjoyed that mate   O0

nice stuff indeed!
Challenge Trophies Won:

Shockwave

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.
Shockwave ^ Codigos
Challenge Trophies Won:

Rattrapmax6

-Rattra (x.t.r.GRAPHICS)

Shockwave

That makes a really nice transition :) Nice one Rattra.
Shockwave ^ Codigos
Challenge Trophies Won:

DrewPee

That is a really cool effect - well done!

Drew
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk