Archive: Dwah! Crazy random flashing


16th December 2002 22:40 UTC

Dwah! Crazy random flashing
Ok, I'm sure one of you intelligent folks on here can answer this one. I assume this is because of the DM, but... this one preset of mine is plagued by crazy flashing colours. When the music isn't really going (if you know what I mean), all it does is make the screen flash bright colours. If I get my zip utility up and running, I'll post it; or, if it'll help, I'll post my code.

Sorry to keep asking all these questions... but hey, that's how ya learn, right? Right? :weird:


16th December 2002 23:41 UTC

It's your DM :)


16th December 2002 23:55 UTC

Thanks for the help... :p

But seriously, here's the code:

init:
pi=acos(-1); e=exp(1); pie=exp(pi);

beat:
bpie=rand(100*pie)/e;

pixel:
r=r*pie;
d=d*bpie;
Spot anything wrong?

17th December 2002 02:52 UTC

Other than the fact that you're going about this COMPLETELY the wrong way...
r=r*pi*e is going to be really ugly, since pi*e isn't an integer. The rand(var) function ONLY supports integers, so rand(pi*e*100) is pointless and slow. Now the reason it's flashing is because you're multiplying d by a random number from 0 to 314. The only place where it *wouldn't* start flashing is if that number was from 1 to maybe 15, or about 10% of the time. When you multiply d by a number, you're moving the picture 'back' by that number minus one; 0 will move it all the way forward (so you don't see anything except the middle pixel), 1 does nothing, 2 moves it back 1 (makes it half-size), et cetera.


17th December 2002 20:31 UTC

So you're saying that d and r can only be integers? That would explain a lot... :rolleyes:
Ok, I fixed the code up so there's no irrational numbers in the random statement, and made it so that d and r are integers. I also fixed it so that d will never be 0 (which I assume was causing some of the problems I was having). Thanks very much for the help.

If you care, or if you wanna try and spot more errors, here's the updated code.

Init: same as before

Beat:
bpie=(rand(100)+1)*(pie/e);

Pixel:
ppie=bpie%sqrt(bpie);
r=r*ppie;
d=1/(d*ppie);
Have I finally got this right? :igor:

17th December 2002 22:04 UTC

No, I'm saying that if you multiply r by a floating point value then the image is going to be repeated in a circle only partially; for that kind of movement you want to repeat the image n times where n is integral (so you don't get ugly clashing edges).
The modulo function (%) only supports counting numbers (positive integers greater than one).

And you're still coding randomly...think carefully before you type something in.


24th December 2002 01:50 UTC

Yeah, well... coding randomly is what I do, okay? I don't quite *know* how to properly code, but I'm gonna keep on doing it, because it's fun. :p That's my style, so to speak, and I can't change it. And hey, just because you don't understand my lack of proper method, doesn't mean that I don't think about what I code before I do it. I'm not a math and/or programming guru like you guys, nor do I have the patience to sit here for hours on end and teach myself how to use AVS "properly". I just play around, try new things, and see what happens without really knowing why. I know, right about now you're thinking that I'm not a true AVS artist and I don't belong on here, but I honestly don't care what you think. I'm doing this because I enjoy it, and because my presets look neat. I don't make technically proficient presets, or ones that make you go "holy shit, look at that math"; I make flashy, shiny, trippy, cool-looking presets. And I'll just leave it at that. One of these days, I'll finish my pack, and I'll submit it to the website, and you and all the other "true" AVS artists can tear it apart then. Until then, I'll stop bothering you with moronic questions. :)


24th December 2002 07:02 UTC

Looks to me like it's this part.

ppie=bpie%sqrt(bpie);
the modulus of bpie and the square root of bpie is always going to be 0. In the next 2 lines the DM is saying get the colour for r at r=0, the make d equal to whatever's at d=1/0 (which is undefided, but doesn't crash AVS)

24th December 2002 07:11 UTC

Originally posted by Jaheckelsafar
(which is undefided, but doesn't crash AVS)
I should certainly hope not!!! :p

26th December 2002 00:01 UTC

Yeah, I was playing around with it a bit and fixed that up. I just realized that a number divided by its square root IS its square root... damn, I'm stupid. :p For now, I changed it to read ppie=pow(bpie,(2/3)), and it works much better now... although the shapes it produces are a tad different, it doesn't flash anymore. I'm still tweaking it to find something even more interesting.

Thanks for the input and the help, everybody.


26th December 2002 07:05 UTC

That's still going to give you a floating point; which is still going to give you an uneven movement. Use an integer n for r=r*n


1st January 2003 06:21 UTC

Ack... okay, after much drunken messing around, I came up with a way to get an interesting random integer for n in r=r*n:

Beat:
mr=((rand(100)+0.1)%rand(100))+1

Pixel:
r=r*mr

At least, I think that's what I used (I have since closed Winamp, and I don't want to start it up again, because my computer is a piece of crap). I know it's hideously inefficient, but dammit, I really don't care anymore. :p Bah, whatever, at least it works. And now I'm going to bed. You'll all get to see the finished product when I get around to finishing my pack (which I will do soon, I promise, because I only have a couple weeks left of school and will consequently have lots of free time on my hands).

Oh, and sorry for rambling. Happy new year, all. :D


1st January 2003 07:25 UTC

Since the rand(var) function only returns integers in the first place, you don't need to do that. Just use mr=rand(8)+1.