Suggested Module Tk::Canvas::GradientColor (Namespace) ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I am writing a Canvas composite widget Tk::Canvas::GradientColor that
I allow to create a Canvas widget width gradient background color
(linear horizontal, linear  vertical, radial, corner type).

Do you know a canvas widget composite in CPAN which allow this ? If
not, I can add it in CPAN. Do you think that the Module Name is ok ?

Best Regards,


Re: Suggested Module Tk::Canvas::GradientColor (Namespace) ?

I have added 3 types of background gradient color:
- corner left
- cornerright
- losange

=head1 NAME Tk::Canvas::GradientColor - To create a Canvas widget with
background gradient color.


use strict;
use warnings;

use Tk;
use Tk::Canvas::GradientColor;

my $mw = new MainWindow(
  -title      => 'Tk::Canvas::GradientColor',
  -background => 'white',

my $canvas = $mw->GradientColor(
  -width  => 400,
  -height => 400,
)->pack(qw/ -fill both -expand 1 /);

sleep 3;

# Change color
  -start_color => '#000000',
  -end_color   => '#00CDFF',

sleep 3;

# Change type
  -start       => 50,
  -end         => 100,
  -type        => 'mirror_vertical'


=head1 DESCRIPTION Tk::Canvas::GradientColor is an extension of the
Canvas widget. It is an easy way to build a canvas widget with
gradient background color.

The module allows to use 7 types of background gradient color :
linear_horizontal, linear_vertical, mirror_horizontal,
mirror_vertical, radial, corner_right and corner_left.


    * disabled_gradientcolor
    * enabled_gradientcolor
    * get_gradientcolor
    * set_gradientcolor
    * RGBtoHex
    * HextoRGB

I am looking for comments or complaints about the name-space or
anything else.

Best regards,

Re: Suggested Module Tk::Canvas::GradientColor (Namespace) ?


Quoted text here. Click to load it
Sounds fine to me. One question though. If you are going to the trouble of
digging into the C code, can you not make it available for *all widgets? Not
just the canvas.


Re: Suggested Module Tk::Canvas::GradientColor (Namespace) ?

Quoted text here. Click to load it

Hi Jack,

Thank you for your answer.
Tk::Canvas::GradientColor is not written in C. I have just write a
composite widget. Tk::Canvas::GradientColor is an extension of canvas
widget, then it is written entirely in Perl.
The idea for all widgets is good, but I have not a good experience to
write it in C. For the moment, with canvas or
Tk::Canvas::GradientColor, it very esay to do some beautiful windows.
For example, to create some graphs. I am updating
Tk::ForDummies::Graph to allow user to set a background gradient color
with graph line, spline, bar, etc.
For all widgets, the only way is to use Tk::Zinc, but this module is
not yet maintained and updated since 2006 :-( !!


Site Timeline