Randomizing Images

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
Music2000
Posts: 26
Joined: Mon Oct 10, 2005 3:38 pm
Location: London

Randomizing Images

Post by Music2000 »

Is it possible to make randomized images? So for example you just fill an image with a load of dots but each time you render they are randomized and in a different place.

aqua_scummm
Posts: 17
Joined: Sat Jun 11, 2005 5:44 am
Location: Redwood City, CA
Contact:

Post by aqua_scummm »

Yes, you can.

Have multiple versions of the same rule. Inside, make the offset for the cirlce different


example, with comments:

Code: Select all

startshape lotsadots

//each of these are different, but have the same name.
//these all have the same odds of being used for a call
//of lotsadots{}

rule lotsadots {
     CIRCLE{}
     lotsadots { x -1 y -3 }
}
rule lotsadots {
     CIRCLE{}
     lotsadots { x 1 y 2 }
}
rule lotsadots {
     CIRCLE{}
     lotsadots { x -2 y 3 }
}
rule lotsadots {
     CIRCLE{}
     lotsadots { x 1 y -2 }
}


//this is our end case aka base case, it
//will not make any more calls, ending
//the program
//the numbers at the top represent the
//odds of it being called

rule lotsadots .01 {
     CIRCLE{}
}

you can have something like 3 rules, two of them with .25 and one with .5 . the one with .5 as its randomness setting will be twice as likely to be called as one of the either two, or the odds of hitting it will be 50%

Theres a bit more, but thats the jist of it. unnumbered rules get divided up evenly, numbered rules get the rest

Post Reply