From e67978b759bf3403e0cb6487418137f7051c7206 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Tue, 8 Apr 2008 02:26:02 -0500 Subject: [PATCH] processing: Move some items from the bubble-chamber demo --- extra/processing/processing.factor | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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