package Pastel
::GradientStop
;
@ISA = qw
(Pastel
::Mixin
::Mixin
);
use Pastel
::Mixin
::Mixin
;
# Perl module for Pastel::Color
# Cared for by Malay<curiouser@ccmb.ap.nic.in>
# Copyright 2001, Malay Kumar Basu
# You may distribute this module under the same terms as perl itself
Each of these gradient paint classes holds several of GradientStop classes.
The GradientStop classes represents the "stop" element under Linear
or radialGradient element in SVG.
There are only two fields in Pastel::GradientStop: "offset" and "color".
The values of "offset" can vary from 0 to 100%, basically reflect at what
point along the GradientVector the gradient stops. The "color" is supplied
#Create a Gradient object
my $linearGradient = Pastel::LinearGradient->new(...);
my $color1 = Pastel::Color->red();
my $firstGradientStop = Pastel::GradientStop->new(-offset=>5,
# my $firstGradientStop = Pastel::GradientStop->new(5, $color1);
# Add the stop to gradient
$linearGradient->add_stop($firstGradientStop);
# Set the gradient to graphics object
$graphics->set_paint($linearGradient);
=head3 Pastel::GradientStop->new(-offset=>$int, -color=>$color)
$int is integer between 0 and 100, $color is a Pastel::Color object.
=head3 Pastel::GradientStop->new($int, $color)
Orthodox parameter styles.
bless $self, ref($class) || $class;
if ( (@args < 2) || (@args >4)){
croak
"Parameter problems in Pastel::GradientStop::new\n";
my ($offset, $color) = $self->_rearrange(["OFFSET","COLOR"],@args);
if(!defined($offset) || !defined($color) ){
croak
"Parameter problem in Pastel::GradientStop::new\n";
if( ($offset <0) || ($offset >100)){
croak
"Offset value in Pastel::GradientStop::new is out of range\n";
if (! $color->isa("Pastel::Color") ){
croak
"Wrong color parameter in Pastel::GradientStop\n";
$self->{offset
} = $offset;
$s .= "<stop offset=\"". $self->get_offset()."\%\" stop-color=\"".
$self->get_color(). "\" stop-opacity=\"". $self->get_opacity(). "\" />";
return $_[0]->{color
}->to_hex();
if ( $_[0]->{color
}->get_alpha() ){
return $_[0]->{color
}->get_alpha();