I cansee here no advandtage. But I left out some
details: I need to handle with capital and small letters
and the different letters will get differenz colors (no in groups).
I haven't tried your solution, because I can't find the
solution for the my problem...perhaps you could explane it to me?
Konrad
On Mon, 22 Jul 2002 20:58:20 +0200
"Jenda Krynicky" <[EMAIL PROTECTED]> wrote:
> From: Konrad Foerstner <[EMAIL PROTECTED]>
>
> > I have a strange error in my script. It should
> > paint a column of lines next to each other in
> > colors which are determinated by a given sequence
> > of letters. It works...but only to the position
> > of 251. After this point all lines have the color
> > of the line at position 251...even when I use
> > a different letter sequence.
> >
> > Is this a sign? The 251? ;) Nope, any hints?
> >
> > Here is the basic sheme. I hope I did't kill
> > an impotant detail.
> >
> >
> > my $seq = $_[0];
> > my @seq_s = split ('',$seq);
> >
> > my $length = length $seq;
> >
> > $pic_length = $length +100;
> >
> > my $img = new GD::Image($pic_length,30);
> >
> > for (my $pos = '0'; $pos < ($length-1); ++$pos)
> > {
> > my $aa = $seq_s[$pos];
> >
> > my $color;
> >
> > if ($aa eq 'A')
> > {$color = $img->colorAllocate(255,0,0);}
> > elsif ($aa eq 'B')
> > {$color = $img->colorAllocate(255,0,0);}
> > elsif ($aa eq 'C')
> > {$color = $img->colorAllocate(0,0,255);}
> > elsif ($aa eq 'D')
> > {$color = $img->colorAllocate(0,0,255);}
> >
> > $img->line($pos,1,$pos,21,$color);
> > }
>
> Why do you keep allocating colors you aready have?
>
> I would suggest something like this :
>
> %colors = (
> 'A' => $img->colorAllocate(255,0,0),
> 'B' => $img->colorAllocate(255,0,0),
> 'C' => $img->colorAllocate(0,0,255),
> 'D' => $img->colorAllocate(0,0,255),
> );
>
> for (my $pos = '0'; $pos < ($length-1); ++$pos) {
> my $aa = $seq_s[$pos];
> my $color = $colors{$aa};
> $img->line($pos,1,$pos,21,$color);
> }
>
> HTH, Jenda
> =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
> There is a reason for living. There must be. I've seen it somewhere.
> It's just that in the mess on my table ... and in my brain
> I can't find it.
> --- me
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]