diff --git a/Prima/Drawable/Gradient.pm b/Prima/Drawable/Gradient.pm index af89abc75..1262c1bef 100644 --- a/Prima/Drawable/Gradient.pm +++ b/Prima/Drawable/Gradient.pm @@ -162,9 +162,14 @@ sub calculate_single $d1 += ($_ - $l) * ($_ - $l); $d2 += ($r - $l) * ($r - $l); } - $fp = int(sqrt($d1) / sqrt($d2) * 64 ); - $c1 = ( $l[0] << 16 ) | ( $l[1] << 8 ) | $l[2]; - $c2 = ( $r[0] << 16 ) | ( $r[1] << 8 ) | $r[2]; + if ( $d2 > 0 ) { + $fp = int(sqrt($d1 / $d2) * 64 ); + $c1 = ( $l[0] << 16 ) | ( $l[1] << 8 ) | $l[2]; + $c2 = ( $r[0] << 16 ) | ( $r[1] << 8 ) | $r[2]; + } else { + $c1 = $c2 = ( $l[0] << 16 ) | ( $l[1] << 8 ) | $l[2]; + $fp = 0; + } } my $new_stripe = 1; if ( @ret ) {