diff --git a/extra/processing/processing.factor b/extra/processing/processing.factor index acad02363b..02a8325663 100644 --- a/extra/processing/processing.factor +++ b/extra/processing/processing.factor @@ -1,6 +1,6 @@ USING: kernel namespaces threads combinators sequences arrays - math math.functions + math math.functions math.ranges random opengl.gl opengl.glu vars multi-methods shuffle ui ui.gestures @@ -16,6 +16,18 @@ IN: processing ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +: 2random ( a b -- num ) 2dup swap - 100 / random ; + +: 1random ( b -- num ) 0 swap 2random ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: chance ( fraction -- ? ) 0 1 2random > ; + +: percent-chance ( percent -- ? ) 100 / chance ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + VAR: fill-color VAR: stroke-color