Documention for: oneliner-paint-drops.r Created by: vincentecuye on: 29-Jan-2013 Last updated by: vincentecuye on: 29-Jan-2013 Format: text/editable Downloaded on: 28-Mar-2024 oneliner-paint-drops.r Author: Vincent Ecuyer Date: 29-Jan-2013 ===Purpose Simple demo showing color drops fading in the background as more are added. ===Note Not compatible with current REBOL releases - REBOL/View 1.2.x is needed. This oneliner used a trick with the draw block in the face effect: when a time delay or a frequency is specified in older versions of /View, the draw block is evaluated at each tick, and words coming from the parent context are allowed. Nearly any code can be used inside a paren! ( ), as long as the value of the last element is legit in the draw block. This doesn't work anymore because the draw dialect only does words lookup, but not a full evalution, which is a good thing security-wise. ===Usage Just launch the script, or copy/paste the line in the /View console. ===Commented Code ; builds and shows a window view layout [ ; a 100x100 box updated 9 times a second b: box rate 9 effect [ ; the effect is based on the interaction between the effect ; block and the image attribute ; paints a small circle filled with a random color ; (0.0.0 to 240.240.240) in a random place in the box draw [pen (random snow) circle (random 99x99) 2] ; mixes the new drop with the already blurred ones in b/image blur ] ; a very small box (just visible enough to receive event) ; updated 9 times a second box 1x1 rate 9 effect [ ; makes a copy of the other box as it's displayed ; before it changes its content ; and places this copy in the background draw [(b/image: to-image b)] ] ] ===Updated Version Not as short (154 chars at best when removing spaces and comments), but this does work in REBOL/View 2.7.8: ; draw block: ; in any color between 0.0.0 and 240.240.240, ; draws a filled circle anywhere inside the 100x100 default box d: [pen (random snow) circle (random 99x99) 2] ; builds and shows a window view layout [ ; a box with an effect: the draw block and the blur for fading b: box rate 9 effect [draw [] blur] feel [ engage: does [ ; paints a new drop (changes the draw block) b/effect/2: compose d ; saves the blurred result as a background b/image: to-image b ; updates the box show b ] ] ]