Closed Thread Icon

Topic awaiting preservation: A little random fun... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=24477" title="Pages that link to Topic awaiting preservation: A little random fun... (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: A little random fun... <span class="small">(Page 1 of 1)</span>\

 
Iron Wallaby
Paranoid (IV) Inmate

From: USA
Insane since: May 2004

posted posted 12-23-2004 02:50

http://www.rpi.edu/~laporj2/media/code/flag.html

Not bad for a 2D, flat-colored flag effect.

"Any sufficiently advanced technology is indistinguishable from magic." -- Arthur C. Clarke
"Any sufficiently arcane magic is indistinguishable from technology." -- P. David Lebling

Ensellitis
Bipolar (III) Inmate

From: New York, USA
Insane since: Feb 2002

posted posted 12-23-2004 03:50

Ok, that was pretty cool. =)

____________________________________________________

lallous
Maniac (V) Inmate

From: Lebanon
Insane since: May 2001

posted posted 12-23-2004 14:59

Very nice....where/how one learns what these forumulas do and how they work?

--
Regards,
Elias

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 12-23-2004 15:12

lallous: I can only speak for myself, but I ( and hope everybody ) know what shape has a sinus or cosinus function, so it's just a matter of mixing them, dephasing some functions, weighing them. When I code an effect, either I exactly know what I want and thus quickly throw a combination of sinus and cosinus, or I have an idea of what I want and thus mix some sinus and cosinus and tweak the parameters and refine the combinations until I get a good looking effect.

In the current case, the amplitude of the movement increases with the distance to the first slice. This is done by :

var displacement = sin_noise((i * 2 - t * 3) / 1024) * i / 8;

The waving movement is done by the combination of several sinus functions ( though one could be enough ) summed in the sin_noise( ) function. The parameter ( i*2-t*3)/1024 is here to have a different angle for each of the 32 slices of the flag and of course have a temporal parameter with the variable t.

Hope that helps.



(Edited by poi on 12-23-2004 15:14)

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 12-23-2004 15:31

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Iron Wallaby
Paranoid (IV) Inmate

From: USA
Insane since: May 2004

posted posted 12-23-2004 17:26
quote:
lallous said:

Very nice....where/how one learns what these forumulas do and how they work?


Basically a matter of toying around. The reason why it's (i*2 + t*3)/1024, is because the flag wouldn't wave smoothly enough (or was too smooth). I started with i + t, and tweaked from there based on how it looked when I did.

I originally used a simple sin wave instead of the sin_noise function to produce the movement, but it was too boring and didn't look realistic. The sin_noise function is one that I came up with a while ago, as a way to give results similiar to Perlin Noise, only with a lot less computation. The results aren't quite as nice, but it is good enough for most purposes. In this case, we needed waviness, so sin functions are definitely the way to go. This exact function was also found through tweaking, though not in a program like this. I used the commercial program Maple (a symbolic algebra program) to plot a number of different, but similar, functions until I found one I liked.

The best programs aren't those you get right the first time, but the ones you refine slowly over time.

Another decision was the French flag. I'm not French, so why use it? For one, a tribute to P01, but the main reason is that an American flag is just too darn complex.

All in all, it was a quick, 5-minute hack. Fun to do, but not as clean as it should be (I should be using DOM methods to create/move these divs, not redrawing them each frame... it would remove the blink in Firefox and be a bit cleaner, but I'm lazy).

"Any sufficiently advanced technology is indistinguishable from magic." -- Arthur C. Clarke
"Any sufficiently arcane magic is indistinguishable from technology." -- P. David Lebling

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 12-24-2004 00:04

Yeah, I forgot to thank you for the tribute and the French flag.
Btw it's not flickering with FireFox 1.0RC1 on my laptop ( WinXP SP1, AMD 2600+, 256Mb with 64Mb dedicated to a Savage 3D )

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 12-24-2004 17:56

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Iron Wallaby
Paranoid (IV) Inmate

From: USA
Insane since: May 2004

posted posted 12-24-2004 18:28

Sorry, InI.

By "best" program, I am referring to one that works exactly the way as your mind's eye sees it; the one that is ideal in your own mind (some people go for speed, some for elegance, some for short code... everyone's idea of best is different). I see programming as something to be refined; you start with a rough initial state, and slowly bring it together to the state of "perfection." I am a very bottom-up programmer in this respect. I fully understand that some people don't work this way; and I'm not saying that other ways are bad, but I wanted to communicate to lallous that there is nothing magical going on here. This is all done by tweaking, not some mystical knowledge he is unaware of. There is no magic in what I do, just smoke and mirrors.

I would disagree with your second statement; for me, if there is something that works immediately, with no fiddling, I see it as myself doing something wrong, and I will promptly tweak it to prove to myself that it was, indeed, correct.

I think you take my opinions for more than what they are: opinions. Everything I say is, of course, my opinion. Whether you agree or not, that's up to you. I never said I was the voice of God or anything.

Sorry if I have offended you, InI, it's Christmas and it's the last thing I'd want to do (any time of the year).

"Any sufficiently advanced technology is indistinguishable from magic." -- Arthur C. Clarke
"Any sufficiently arcane magic is indistinguishable from technology." -- P. David Lebling

(Edited by Iron Wallaby on 12-24-2004 18:31)

« BackwardsOnwards »

Show Forum Drop Down Menu