mirror of https://github.com/GNOME/gimp.git
Changed burst to use newest version; change in interface
(Hope you don't mind Marc)
This commit is contained in:
parent
bcd9899101
commit
f4b469efb8
|
@ -1,5 +1,6 @@
|
||||||
Revision history for Gimp-Perl extension.
|
Revision history for Gimp-Perl extension.
|
||||||
|
|
||||||
|
- updated burst <sjburges@gimp.org>
|
||||||
1.20
|
1.20
|
||||||
- image types updated to reflect gimp's reality.
|
- image types updated to reflect gimp's reality.
|
||||||
- updated perlotine.
|
- updated perlotine.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# <sjburges@gimp.org> (original release)
|
# <sjburges@gimp.org>
|
||||||
#
|
#
|
||||||
use Gimp;
|
use Gimp qw(:auto N_ __);
|
||||||
use Gimp::Fu;
|
use Gimp::Fu;
|
||||||
use Gimp::Util;
|
use Gimp::Util;
|
||||||
|
|
||||||
|
@ -16,17 +16,35 @@ use Gimp::Util;
|
||||||
# Enjoy,
|
# Enjoy,
|
||||||
# Seth Burgess <sjburges@gimp.org>
|
# Seth Burgess <sjburges@gimp.org>
|
||||||
|
|
||||||
|
####-----
|
||||||
|
# Revision 03/18/2000
|
||||||
|
# Changed second angle to be a sweep measurement, not an absolute angle (I
|
||||||
|
# found that I was calculating a lot more by hand than I should be when
|
||||||
|
# using it)
|
||||||
|
#
|
||||||
|
# Also fixed up a bug that I'd covered up, and did a decent for loop for
|
||||||
|
# a change. Fixed up rectangle to not mess up on corner areas.
|
||||||
|
#
|
||||||
|
# Lastly, I added a special case for 360 degrees - don't redraw the last
|
||||||
|
# line for a full circle; instead re-adjust end point. I'm not entirely
|
||||||
|
# happy with this solution, but its close to what I expect to happen. I
|
||||||
|
# don't desire to litter the interface with more strange options if possible
|
||||||
|
# and I suspect most users will never notice.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Gimp::set_trace(TRACE_ALL);
|
# Gimp::set_trace(TRACE_ALL);
|
||||||
|
|
||||||
# find an equivalent polar value in the range of 0 to 2 pi
|
# find an equivalent polar value in the range of 0 to 2 pi
|
||||||
sub find_in_2pi
|
sub find_in_2pi
|
||||||
{
|
{
|
||||||
my ($ang) = @_;
|
my ($ang) = @_;
|
||||||
if ($ang < 0)
|
if ($ang < 0)
|
||||||
{
|
{
|
||||||
return ($ang - int($ang/(2*3.1415926))*2*3.1415926 + 2*3.1415926);
|
return ($ang - int($ang/(2*3.1415926))*2*3.1415926 + 2*3.1415926);
|
||||||
}
|
}
|
||||||
return ($ang - int($ang/(2*3.1415926))*2*3.1415926);
|
return ($ang - int($ang/(2*3.1415926))*2*3.1415926);
|
||||||
}
|
}
|
||||||
|
|
||||||
# actual script
|
# actual script
|
||||||
|
@ -50,16 +68,27 @@ fades from if you have Fade set\n",
|
||||||
[PF_VALUE, 'spokes', "How many spokes", 16],
|
[PF_VALUE, 'spokes', "How many spokes", 16],
|
||||||
[PF_VALUE, 'inside_pixels', "Inside Pixels", 10],
|
[PF_VALUE, 'inside_pixels', "Inside Pixels", 10],
|
||||||
[PF_VALUE, 'outside_pixels', "Outside Pixels", 10],
|
[PF_VALUE, 'outside_pixels', "Outside Pixels", 10],
|
||||||
[PF_SLIDER, 'start_angle', "Angle to start at, with 0 being left sweeping counter-clockwise.", 0, [-360, 360, 1]],
|
[PF_SLIDER, 'start_angle', "Angle to start at, with 0 being left, and sweeping counter-clockwise.", 0, [-360, 360, 1]],
|
||||||
[PF_SLIDER, 'end_angle', "Angle to end at, with 0 being left sweeping counter-clockwise.", 360, [-360, 360, 1]]
|
[PF_SLIDER, 'arc_angle', "How many degrees to arc through.", 360, [-360, 360, 1]]
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
[],
|
[],
|
||||||
sub {
|
sub {
|
||||||
my($img,$layer, $shape, $fade_dir, $points,
|
my($img,$layer, $shape, $fade_dir, $points,
|
||||||
$inside_pixels, $outside_pixels, $start_angle, $end_angle) =@_;
|
$inside_pixels, $outside_pixels, $start_angle, $arc_angle) =@_;
|
||||||
|
|
||||||
$pi = 3.1415927;
|
$pi = 3.1415927;
|
||||||
|
|
||||||
|
# Special case 360
|
||||||
|
if (abs($arc_angle) == 360)
|
||||||
|
{
|
||||||
|
$end_angle = $start_angle + $arc_angle - abs ($arc_angle/$points);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$end_angle = $start_angle + $arc_angle;
|
||||||
|
}
|
||||||
|
|
||||||
eval { $img->undo_push_group_start };
|
eval { $img->undo_push_group_start };
|
||||||
|
|
||||||
Gimp->progress_init("Burst");
|
Gimp->progress_init("Burst");
|
||||||
|
@ -67,7 +96,7 @@ fades from if you have Fade set\n",
|
||||||
$progress = 0;
|
$progress = 0;
|
||||||
|
|
||||||
($dumb, $x1, $y1, $x2, $y2) = $img->selection_bounds;
|
($dumb, $x1, $y1, $x2, $y2) = $img->selection_bounds;
|
||||||
$img->selection_none;
|
# $img->selection_none;
|
||||||
|
|
||||||
$width = $x2 - $x1;
|
$width = $x2 - $x1;
|
||||||
$height = $y2 - $y1;
|
$height = $y2 - $y1;
|
||||||
|
@ -85,12 +114,13 @@ fades from if you have Fade set\n",
|
||||||
|
|
||||||
if ($shape == 0)
|
if ($shape == 0)
|
||||||
{ #ellipse
|
{ #ellipse
|
||||||
# the for loop just increments $i until $angle is big enough
|
# do $points worth
|
||||||
for ($i = 0, $angle=$start_angle*$pi/180;
|
for ($i = 0;
|
||||||
$angle <$end_angle*$pi/180-0.01;
|
$i < $points;
|
||||||
|
#$angle <$end_angle*$pi/180-0.01;
|
||||||
$i++ )
|
$i++ )
|
||||||
{
|
{
|
||||||
$angle = $i * abs($start_angle-$end_angle)*$pi/$points/180;
|
$angle = $i * abs($start_angle-$end_angle)*$pi/($points-1)/180;
|
||||||
$angle += $start_angle*$pi/180;
|
$angle += $start_angle*$pi/180;
|
||||||
|
|
||||||
# use the major/minor axis description of an ellipse:
|
# use the major/minor axis description of an ellipse:
|
||||||
|
@ -124,7 +154,8 @@ fades from if you have Fade set\n",
|
||||||
$y_start = sqrt(1/((1/($m*$m*$c*$c))+(1/$d/$d)));
|
$y_start = sqrt(1/((1/($m*$m*$c*$c))+(1/$d/$d)));
|
||||||
|
|
||||||
# pick the right solution of the quadratic
|
# pick the right solution of the quadratic
|
||||||
if ((find_in_2pi($angle) < $pi/2) || (find_in_2pi($angle) > 3*$pi/2))
|
if ((find_in_2pi($angle) < $pi/2) ||
|
||||||
|
(find_in_2pi($angle) > 3*$pi/2))
|
||||||
{
|
{
|
||||||
$x = -$x;
|
$x = -$x;
|
||||||
$x_start = -$x_start;
|
$x_start = -$x_start;
|
||||||
|
@ -140,8 +171,6 @@ fades from if you have Fade set\n",
|
||||||
$x_start = $x_start + $center_x;
|
$x_start = $x_start + $center_x;
|
||||||
$y_start = $y_start + $center_y;
|
$y_start = $y_start + $center_y;
|
||||||
|
|
||||||
# print "X = $x, Y = $y, M = $m\n";
|
|
||||||
|
|
||||||
if ($fade_dir == 1)
|
if ($fade_dir == 1)
|
||||||
{
|
{
|
||||||
$layer->paintbrush_default(4, [$x, $y, $x_start, $y_start]);
|
$layer->paintbrush_default(4, [$x, $y, $x_start, $y_start]);
|
||||||
|
@ -162,41 +191,41 @@ fades from if you have Fade set\n",
|
||||||
|
|
||||||
#print "width = $width, height = $height\n";
|
#print "width = $width, height = $height\n";
|
||||||
|
|
||||||
for ($i = 0, $angle=$start_angle*$pi/180;
|
for ($i = 0;
|
||||||
$angle <$end_angle*$pi/180-0.01;
|
$i < $points;
|
||||||
$i++ )
|
$i++ )
|
||||||
{
|
{
|
||||||
$angle = $i * abs($start_angle-$end_angle)*$pi/$points/180;
|
$angle = $i * abs($start_angle-$end_angle)*$pi/($points-1)/180;
|
||||||
$angle += $start_angle*$pi/180;
|
$angle += $start_angle*$pi/180;
|
||||||
|
|
||||||
# get the slope
|
# get the slope
|
||||||
$m = sin($angle)/cos($angle);
|
$m = sin($angle)/cos($angle);
|
||||||
# print "M = $m\n";
|
if (abs($m*$width/2) < $height/2)
|
||||||
if (abs($m*$width/2) < $height/2-$outside_pixels)
|
|
||||||
{ # draw on the right/left borders
|
{ # draw on the right/left borders
|
||||||
$x = $width/2-$outside_pixels;
|
$x = $width/2-$outside_pixels;
|
||||||
$y = $m*($width/2-$outside_pixels);
|
$y = $m*($width/2-$outside_pixels);
|
||||||
$x_start = ($width>$height)
|
$x_start = ($width>$height)
|
||||||
?$inside_pixels
|
?($inside_pixels)
|
||||||
:$inside_pixels*$width/$height;
|
:($inside_pixels*$width/$height);
|
||||||
$y_start = ($width>$height)
|
$y_start = ($width>$height)
|
||||||
?$m*$inside_pixels
|
?($m*$inside_pixels)
|
||||||
:$m*$inside_pixels*$width/$height;
|
:($m*$inside_pixels*$width/$height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ # draw on the top/bottom borders
|
{ # draw on the top/bottom borders
|
||||||
$y = $height/2-$outside_pixels;
|
$y = $height/2-$outside_pixels;
|
||||||
$x = ($height/2-$outside_pixels)/$m;
|
$x = ($height/2-$outside_pixels)/$m;
|
||||||
$y_start = ($width>$height)
|
$y_start = ($width>$height)
|
||||||
?$inside_pixels*$height/$width
|
?($inside_pixels*$height/$width)
|
||||||
:$inside_pixels;
|
:($inside_pixels);
|
||||||
$x_start = ($width>$height)
|
$x_start = ($width>$height)
|
||||||
?$inside_pixels*$height/$width/$m
|
?($inside_pixels*$height/$width/$m)
|
||||||
:$inside_pixels/$m;
|
:($inside_pixels/$m);
|
||||||
}
|
}
|
||||||
# the method of finding points by lines like above makes picking right
|
# the method of finding points by lines like above makes picking right
|
||||||
# values kinda icky, as shown by these if statements.
|
# values kinda icky, as shown by these if statements.
|
||||||
if ((find_in_2pi($angle) <= $pi/2) || (find_in_2pi($angle) > 3*$pi/2))
|
if ((find_in_2pi($angle) <= $pi/2) ||
|
||||||
|
(find_in_2pi($angle) > 3*$pi/2))
|
||||||
{
|
{
|
||||||
$x = -abs($x);
|
$x = -abs($x);
|
||||||
$x_start = -abs($x_start);
|
$x_start = -abs($x_start);
|
||||||
|
@ -236,5 +265,6 @@ fades from if you have Fade set\n",
|
||||||
}
|
}
|
||||||
eval { $img->undo_push_group_end };
|
eval { $img->undo_push_group_end };
|
||||||
return();
|
return();
|
||||||
};
|
};
|
||||||
|
|
||||||
exit main;
|
exit main;
|
||||||
|
|
Loading…
Reference in New Issue