Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: One-shot random



On 21/09/2005, at 3:17 am, email@hidden wrote:

One solution is to manipulate Math.random() using some component of
Date() to get some other result. Maybe looping over Math.random() X
times, where X is the value of milliseconds in the date it the start
of your composition (this was suggested by Dave Hayden to me a while
ago). This is fine if you just want a seed for an integer between 0
and maybe 100, but doesn't cut it if you need some *real* randomness
in your screen-saver. Reason being that any N iterations of
Math.random() will always have the same result when run as a screen-
saver (my guess is that it isn't being seeded correctly in that
mode). It also causes a slow-down on initialisation of the
composition to do anywhere up to 1000 calls to Math.random(). But
here's the code anyway...

There's another way. Use a modified version of the System Time as the Max input on the Random patch, then modulo that output down to whatever you need. In this composition the time is fed through Math (mod 100000 plus 100000) then fed on. Works well for this one (as a screen saver) though of course it's not "true" randomness.


http://funwithstuff.com/quartz/Abstracted.qtz

-iain

http://funwithstuff.com - email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.