Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Partly transparent rectangle on Canvas?

1,301 views
Skip to first unread message

Josef Moellers

unread,
Dec 19, 2011, 6:00:24 AM12/19/11
to
Hi,

I'd like to render a rectangle which should be partly transparent, i.e.
whatever lies below the rectengle should gleam through the rectangle.
I know of "-stipple => 'transparent'", but that just makes the rectangle
completely transparent, but I'd rather have it 25% or so transparent.

Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html

Jack

unread,
Dec 20, 2011, 3:53:44 AM12/20/11
to
On 19/12/2011 4:00 AM, Josef Moellers wrote:
> Hi,
>
> I'd like to render a rectangle which should be partly transparent, i.e.
> whatever lies below the rectengle should gleam through the rectangle.
> I know of "-stipple => 'transparent'", but that just makes the rectangle
> completely transparent, but I'd rather have it 25% or so transparent.
>
> Josef

You are looking for the built-in bitmaps (gray10, gray25, gray50,
gray75). Here is a small script that shows it working. Move your mouse
over the red rectangle.

use Tk;
use strict;
my $mw = tkinit;
my $c = $mw->Canvas->pack;
$c->create('rectangle',0,0,100,100,-fill=>'blue');
$c->create('rectangle',50,50,150,150, -fill=>'red',
-activestipple=>'gray50');
MainLoop;

--Jack

Josef Moellers

unread,
Dec 20, 2011, 8:14:52 AM12/20/11
to
Am 20.12.2011 schrub Jack:

> use Tk;
> use strict;
> my $mw = tkinit;
> my $c = $mw->Canvas->pack;
> $c->create('rectangle',0,0,100,100,-fill=>'blue');
> $c->create('rectangle',50,50,150,150, -fill=>'red',
> -activestipple=>'gray50');
> MainLoop;

Yepp ... thanks ... and "Happy Holidays" (if you celebrate).
0 new messages