Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

EVOScript

 [1/6] from: g:santilli:tiscalinet:it at: 25-Nov-2002 21:19


Hello all, ok, so now the scroller is properly updated. :-) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r REBOL [ Title: "Evolving Script" Date: 25-Nov-2002/21:17:55+1:00 Name: none Version: 1.18.0 File: %evoscript.r Home: none Author: "Gabriele Santilli" Owner: none Rights: none Needs: [view 1.2.8] Tabs: none Usage: none Purpose: "To make the definitive quine!" Comment: "This can be addictive. You have been warned." History: [not yet implemented] Language: "English" Type: 'Script Content: true Layout: [ Do [trebuchet: [name: "Trebuchet MS" size: 14]] Style Button Btn font trebuchet font-size 16 bold -1x28 Banner center 600 font trebuchet font-size 38 bold yellow "The REBOL evolving script" Text right 600 font trebuchet font-size 16 "by Gabriele Santilli" Pad -10 Text right 600 font trebuchet italic "(original idea by Baron R.K. Von Wolfsheild)" Text 600 font trebuchet {Maybe I'm just crazy, but this is so much fun! It is amazing to see how easy I can be amazed by these short things... I wonder if any other language could do this in so few lines of code, and with this readability...} Across a: Area para [] font trebuchet 583x300 system/script/header/content feel [ engage': :engage last-scroll: none engage: func [face action event] [ engage' face action event if all [event/type = 'key face/para/scroll/y <> last-scroll] [ last-scroll: face/para/scroll/y rescroll ] ] ] Pad -8 s: Scroller 17x300 [ tsize: size-text a a/para/scroll/y: 280 - tsize/y * face/data show a ] do [rescroll] Return Button "Update Layout" 255.200.50 [ attempt [ attempt [ set reduce [in system/script 'header 'content] load/header/next a/text system/script/header/date: now system/script/header/version: system/script/header/version + 0.1.0 system/script/header/content: join "REBOL " [ find mold make system/script/header [content: true] "[" content ] ] lay2: system/words/layout system/script/header/layout lay/pane: lay2/pane lay/size: lay2/size show lay lay/text: system/script/header/title lay/changes: 'text show lay ] ] Button "Copy Script" [ write clipboard:// system/script/header/content ] Button "Save Script" 50.240.100 [ write system/script/header/file system/script/header/content ] Button "Send to [giesse--rebol--it]" [ send/subject [giesse--rebol--it] system/script/header/content join "[EVOScript] " system/script/header/title ] Return Button "Pretty-print" [ attempt [ set reduce [in system/script 'header 'content] load/header/next a/text a/text: system/script/header/content: join "REBOL " [ find mold make system/script/header [content: true] "[" mold/only/all load content ] show a ] ] ] ] rescroll: func [/only] [ tsize: size-text a if not only [s/redrag min 1 a/size/y - 15 / tsize/y] s/data: min 1 max 0 a/para/scroll/y / (a/size/y - 15 - tsize/y) show s ] system/view/window-feel/detect: func [face event] [ if event/type = 'scroll-line [ a/para/scroll/y: event/offset/y * -15 + a/para/scroll/y show a rescroll/only ] event ] view lay: layout system/script/header/layout

 [2/6] from: ronaldoff:free at: 26-Nov-2002 10:50


Hello Gabriele, Monday, November 25, 2002, 9:19:16 PM, you wrote: GS> Hello all, GS> ok, so now the scroller is properly updated. GS> :-) GS> Regards, GS> Gabriele. Very nice indeed !! I'm also amazed by scripts like that, and playing a little with it, I added an effect to one button, and after update, was very surprised by the result : the button changed to round button !! here the change for the "prettyPrint" button : Button "Pretty-print" effect [multiply 255.150.0] [ Why does this change of shape happen ? -- Best regards, Ronald [ronaldoff--free--fr]

 [3/6] from: g:santilli:tiscalinet:it at: 26-Nov-2002 10:52


Hi Ronald, On Tuesday, November 26, 2002, 10:50:23 AM, you wrote: r> Why does this change of shape happen ? Because you're overwriting the button effect:
>> b: get-style 'btn >> print mold b/init
[ if size/x = -1 [ either text [ size/x: 1000 state: size-text self size/x: either state [state/x + font/offset/x] [50] state: none ] [ size/x: 50 ] ] if font/colors [font/color: first font/colors] if not images [ images: reduce [btn-up.png btn-dn.png] if not any [colors color] [color: 220.220.220] ] if images [image: images/1] if colors [color: colors/1] if all [image not effect] [ effect: reduce ['extend image/size/2] if color [append effect reduce ['colorize color]] ] color: none ] Look at the part: if all [image not effect] [ effect: reduce ['extend image/size/2] if color [append effect reduce ['colorize color]] ] you already provided an effect, so it is no more adding the EXTEND effect. Try with: Button "Pretty-print" effect [extend 22 multiply 255.150.0] [ Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

 [4/6] from: ronaldoff::free::fr at: 27-Nov-2002 1:53


Hello Gabriele, Tuesday, November 26, 2002, 10:52:42 AM, you wrote: GS> Hi Ronald, GS> On Tuesday, November 26, 2002, 10:50:23 AM, you wrote: r>> Why does this change of shape happen ? GS> Because you're overwriting the button effect:
>>> b: get-style 'btn >>> print mold b/init
GS> [ GS> if size/x = -1 [ GS> either text [ GS> size/x: 1000 GS> state: size-text self GS> size/x: either state [state/x + font/offset/x] [50] GS> state: none GS> ] [ GS> size/x: 50 GS> ] GS> ] GS> if font/colors [font/color: first font/colors] GS> if not images [ GS> images: reduce [btn-up.png btn-dn.png] GS> if not any [colors color] [color: 220.220.220] GS> ] GS> if images [image: images/1] GS> if colors [color: colors/1] GS> if all [image not effect] [ GS> effect: reduce ['extend image/size/2] GS> if color [append effect reduce ['colorize color]] GS> ] GS> color: none GS> ] GS> Look at the part: GS> if all [image not effect] [ GS> effect: reduce ['extend image/size/2] GS> if color [append effect reduce ['colorize color]] GS> ] GS> you already provided an effect, so it is no more adding the EXTEND GS> effect. Not really a newbie, but far away from gurus, I'll have to dig into the code to understand clearly what is happening, but to tired to do it tonight ;-) GS> Try with: GS> Button "Pretty-print" effect [extend 22 multiply 255.150.0] [ GS> Regards, GS> Gabriele. Thanks and @+ -- Best regards, Ronald

 [5/6] from: anton:lexicon at: 27-Nov-2002 17:11


I think Gabriele means that using colorize after extend will stop extend working. But if this is true he is wrong. :) Have a look at this example: img: to-image layout [box red effect [oval]] view layout [ image (img/size + 40x40) img effect reduce [ 'extend (img/size / 2) 40x40 'colorize 0.0.255 ] ] You can see that colorize and extend are both in effect. Now remove the 'colorize 0.0.255 Your original problem I think was that extend needs two pair types (e.g 1x2 is a pair!). The first pair is the offset to start the extending. The second pair specifies how much to extend. Another problem is that by using img/size/2 you actually specified img/size/y, that is the height of the image, which is an integer, not a pair, so it would have been ignored by extend. I am sure you meant img/size / 2, which would have given half the size of the image, ie. the centre. So in the above code I asked to extend the image from the centre of the image 40 pixels in each direction, horizontally and vertically. And I also made sure that the size of the image style in the layout was large enough to show the extended image. Anton.

 [6/6] from: g:santilli:tiscalinet:it at: 27-Nov-2002 11:04


Hi Anton, On Wednesday, November 27, 2002, 7:11:59 AM, you wrote: A> I think Gabriele means that using colorize after A> extend will stop extend working. A> But if this is true he is wrong. :) I wasn't saying that. It's just that the Btn style does not add EXTEND to the effects block if you have already provided an effect block. Have a look at Btn/init... (I posted that, did you miss it?) A> Your original problem I think was that extend needs A> two pair types (e.g 1x2 is a pair!). A> The first pair is the offset to start the extending. A> The second pair specifies how much to extend. RT is not using it like that, in Btn/init... A> Another problem is that by using img/size/2 you A> actually specified img/size/y, that is the height of That's RT, not me. And it appears to work. :-) A> I am sure you meant img/size / 2, which would have A> given half the size of the image, ie. the centre. I can confirm you that my version of REBOL/View 1.2.8.3.1 has the following code in the init block for the Btn style: effect: reduce ['extend image/size/2] Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r