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

[REBOL] Re: One-Liners back in town!

From: carl:cybercraft at: 23-Nov-2002 11:48

Hi Gerard, On 23-Nov-02, Gerard Cote wrote:
> Hi Ashley and Louis, > since I am realy a REBOL newbie, I tried to adapt your submission to > use only REBOL for display too. And this worked as the following : > save/png %hello.png to-image layout [banner "Hello World!"] view > layout [image %hello.png] > It is a lot more quicker than with the default Web browser !!! > I also tried the following and this doesn't work similarly in the > sense that I can't store the resulting .png file in addition to > displaying it. > view layout [image to-image layout [banner "Hello World!"]] > Can someone optimize (correct it) any more ?
view layout[image(save %hello.png img: to-image layout[banner"Hello World!"]img)] That, I think, does all you want - but is 81 characters. Darn! I'm sure you can get it under 80 though. (;
> Finally I tried to go with : view layout [image img: to-image layout > [banner "Hello World!"]] but the result displayed is an empty image > ... I don't understand why yet but I am looking further for an > answer
Placing the image-creation part in parens will make it work... view layout [image (img: to-image layout [banner "Hello World!"])] VID, being a dialect doesn't parse code in the same way as standard REBOL. To make it do so, place the code in parens like I've done above.
> These other tries don't work either and I am always questioning > myself about them ... I really miss something about the way VID and > REBOL works in the basics, I think! > view layout [img: save/png %hello.png to-image layout [banner "Hello > World!"]]
1) There's no image style in the layout. ie... view layout [image img: save/png %hello.png to-image layout [banner Hello World! ]] 2) and it still doesn't work because save doesn't return the image. You can see this at the Console...
>> to-image layout [banner "Hello World!"]
== make image! [158x68 #{ 6E808E6E808E6E808E6E808E6E808E6E808E6E808E6E808E6E808E6E808E 6E808E6E808E6E808E6E808E6E808E6E808E6E808E6E... There, the image is returned, but if you ssave it...
>> save/png %hello.png to-image layout [banner "Hello World!"]
it isn't. This is why in my length 81 version I've put the img word at the end of the paren, that causing it to be returned. Working at the console's the way to sort out problems with your REBOL code. Start with what's working and add bits, all the time watching for the unexpected with what's being returned.
> or view layout [to-image layout [banner "Hello World!"]]
No image word in the layout block again.
> or view layout [image img: save/png %hello.png to-image layout > [banner "Hello World!"]]
And the save's not returning the image again. That's very close to my 81 characters version though. Just enclose in a paren and add the img word. Hope that explains a bit more about the workings of VID to you. -- Carl Read