Well, for one, all these values are fractions in the range 0 to 1.
If you use 0 in your example, the image will become fully transparent. If you use 1, it will be fully opaque.
Since 16 bit forms store only 1 bit of alpha (and 5 bits each for red, green, and blue), you cannot do more than toggle that bit.
If you want real translucency, create newForm with 32 bits of depth instead of 16. Then each component gets full 8 bits, and e.g. using an alpha of 0.5 will make the whole image half-transparent.
On 25.05.2012, at 20:23, Steve Thomas wrote:
<Screen Shot 2012-05-25 at 2.22.06 PM.png>
I tried setting alpha to 50, but it didn't work, see script below.
recolor
| oldForm newForm old new avg |
oldForm := ErnieRubberDuckie getGraphic.
newForm := Form extent: oldForm extent depth: 16.
0
to: oldForm height - 1
do: [:y | 0
to: oldForm width - 1
do: [:x |
old := oldForm colorAt: x @ y.
avg := old red + old green + old blue / 3.
new := Color
r: old red * 0 + avg
g: old green * 0 + avg
b: old blue * 0 + avg
alpha: 50.
newForm colorAt: x @ y put: new]].
self setGraphic: newForm