ios - How do you get different random images from the `CIRandomGenerator` filter? -


it appears me output of cifilter(name: "cirandomgenerator") same, regardless of whether 1 references outputimage of instance multiple times or whether 1 instantiates new filter:

import coreimage let randomfilter = cifilter(name: "cirandomgenerator") let outputimage = randomfilter!.outputimage!.cropped(to: (cgrect(x: 0, y: 0, width: 100, height: 100))) let outputimage2 = randomfilter!.outputimage!.cropped(to: (cgrect(x: 0, y: 0, width: 100, height: 100))) // pause amount of time it's not  // instantiating prng same timestamp let rf2 = cifilter(name: "cirandomgenerator") rf2!.outputimage!.cropped(to: (cgrect(x: 0, y: 0, width: 100, height: 100))) 

leads to: playground output

which, if examine pixels, same.

i not see kind of seed parameter can passed in initialize pseudo-random number generator properly.

since cifilter has infinite extent, can randomly offset location in call cropped , appears work, seems hack. missing proper way initialize / getnext random filter?

i put comment, feel it's answer worthy.

that seems you've correctly described me. consider - random number generator? sure may take "seed", generators will provide predictable number if ran time , time again. (provided don't start adding other things equation.)

so output of cirandomgenerator may thought of same kind of thing. taken (0,0) it's "random" out infinity. once you've "seeded" things - given origin other (0,0) - you've "captured" consider "random".


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -