[View] invisible background
[1/2] from: ingo:2b1 at: 18-Nov-2003 11:39
Hi /Viewers,
I just wrote the following script to create a batch of buttons for
teaching website creation, but how do I set an invisible background on
these buttons?
[REBOL [
Title: "Button Creator"
Author: "Ingo Hohmann"
]
colours: [ red green blue yellow water white forest snow coffee gold]
texts: [ "Home" "About Us" "Info" "Contact" ]
repeat c colours [
repeat t texts [
save/png to-file rejoin [ c "-" trim/all t ".png"] to-image layout
compose [ btn (reduce c) t ]
]
]
]
Thanks for your help!
Ingo
[2/2] from: antonr::iinet::net::au at: 19-Nov-2003 0:58
You want to save the alpha channel.
Good question...
The problem is that to-image render a representation
of the image without alpha channel. The btn style
uses an image with an alpha channel, but when it
is rendered to the screen, the alpha is lost.
Rendering takes the image, applies the extend and colorize
effects and adds text.
I don't have a solution yet, but I think you must
mimic the process of the btn style, layout and to-image.
Seems a lot of work, but maybe there is a way.
Here are some things I did while experimenting:
Let's look at the images that the btn styles uses:
view layout [b: btn]
view layout [image b/images/1 image b/images/2]
Let's create an image as you do below (using to-image) and reload it
(as if we saved and loaded a file).
bin: make binary! 10000
save/png bin img: to-image view center-face layout [origin 0 btn red
pill
]
view center-face layout [backcolor orange pic: image 200x100 (load bin)
effect [merge]]
poke pic/image 1 pic/image/1 + 0.0.0.1 ; add alpha channel
; top-left alpha pixel must be non-zero to see any alpha at all in rebol.
view layout [image pic/image]
layout [b: btn red "pill"]
img: to-image b
view layout [image img]
Anton.