Commit 7db2e701 authored by Marc Lehmann's avatar Marc Lehmann
Browse files

see plug-ins/perl/Changes

parent d76e551c
......@@ -22,6 +22,8 @@ Revision history for Gimp-Perl extension.
- move perl-intl.h include below the other includes. William Sebok
finally came up with a nice problem analysis.
- try to get rid of -Wall, if possible.
- shield more sections against -w dumbness.
- updated many of seth's scripts.
1.17 Wed Nov 24 21:25:19 CET 1999
- re-fitted i18n translation for most plug-ins.
......
......@@ -395,36 +395,48 @@ sub callback {
local $function = shift;
local $in_run = 1;
_initialized_callback;
@cb = (
@{$callback{run}},
@{$callback{lib}},
@{$callback{$function}},
);
{
local $^W = 0;
@cb = (
@{$callback{run}},
@{$callback{lib}},
@{$callback{$function}},
);
}
die_msg __"required callback 'run' not found\n" unless @cb;
for (@cb) { &$_ }
} elsif ($type eq "-net") {
local $in_net = 1;
_initialized_callback;
@cb = (
@{$callback{run}},
@{$callback{net}},
@{$callback{$function}},
);
{
local $^W = 0;
@cb = (
@{$callback{run}},
@{$callback{net}},
@{$callback{$function}},
);
}
die_msg __"required callback 'net' not found\n" unless @cb;
for (@cb) { &$_ }
} elsif ($type eq "-query") {
local $in_query = 1;
_initialized_callback;
@cb = (
@{$callback{query}},
);
{
local $^W = 0;
@cb = (
@{$callback{query}},
);
}
die_msg __"required callback 'query' not found\n" unless @cb;
for (@cb) { &$_ }
} elsif ($type eq "-quit") {
local $in_quit = 1;
@cb = (
@{$callback{quiet}},
);
{
local $^W = 0;
@cb = (
@{$callback{quiet}},
);
}
for (@cb) { &$_ }
}
}
......
......@@ -192,7 +192,7 @@ static int gdrawable_free (SV *obj, MAGIC *mg)
{
GDrawable *gdr = (GDrawable *)SvIV(obj);
g_hash_table_remove (gdrawable_cache, &gdr->id);
g_hash_table_remove (gdrawable_cache, (gpointer)gdr->id);
gimp_drawable_detach (gdr);
return 0;
......@@ -206,9 +206,11 @@ static SV *new_gdrawable (gint32 id)
SV *sv;
if (!gdrawable_cache)
gdrawable_cache = g_hash_table_new (g_int_hash, g_int_equal);
gdrawable_cache = g_hash_table_new (g_direct_hash, g_direct_equal);
if ((sv = (SV*)g_hash_table_lookup (gdrawable_cache, &id)))
assert (sizeof (gpointer) >= sizeof (id));
if ((sv = (SV*)g_hash_table_lookup (gdrawable_cache, (gpointer)id)))
SvREFCNT_inc (sv);
else
{
......@@ -224,7 +226,7 @@ static SV *new_gdrawable (gint32 id)
sv_magic (sv, 0, '~', 0, 0);
mg_find (sv, '~')->mg_virtual = &vtbl_gdrawable;
g_hash_table_insert (gdrawable_cache, &id, (gpointer)sv);
g_hash_table_insert (gdrawable_cache, (gpointer)id, (void *)sv);
}
return sv_bless (newRV_noinc (sv), stash);
......
......@@ -18,32 +18,54 @@ use Gimp::Util;
# Gimp::set_trace(TRACE_ALL);
# find an equivalent polar value in the range of 0 to 2 pi
sub find_in_2pi
{
my ($ang) = @_;
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);
}
# actual script
register "burst",
"Bursts from a central location",
"Bursts from a central location\n",
"Creates a Burst of various sizes from the center of the currently
selected areas. Can create either an elliptical burst, or go to sqare
spots. Also, you can specify how much (in pixels) to leave blank on
the inside and the outside of the burst.",
selected areas. Can create either an elliptical burst, or some portion
of said burst. Also, you can specify how much (in pixels) to leave blank on
the inside and the outside of the burst. This uses whatever the current
brush settings are, and lets you control which direction to have it draw the
fades from if you have Fade set\n",
"Seth Burgess",
"Seth Burgess <sjburges\@gimp.org>",
"1999-07-31",
N_"<Image>/Filters/Misc/Burst",
N_"<Image>/Filters/Render/Burst...",
"*",
[
[PF_RADIO, "shape", "Shape To Burst Into", 0, [Rectangle => 1, Ellipse=> 0]],
[PF_RADIO, "fade_dir", "Fade Direction (if set)", 0, [In => 1, Out => 0]],
[PF_VALUE, 'points', "How many points", "16"],
[PF_VALUE, 'inside_pixels', "Inside Pixels", "10"],
[PF_VALUE, 'outside_pixels', "Outside Pixels", "10"]
[PF_RADIO, "fade_dir", "Fade Direction (if fade is set)", 0, [In => 1, Out => 0]],
[PF_VALUE, 'spokes', "How many spokes", 16],
[PF_VALUE, 'inside_pixels', "Inside 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, 'end_angle', "Angle to end at, with 0 being left sweeping counter-clockwise.", 360, [-360, 360, 1]]
],
[],
[],
sub {
my($img,$layer,$shape, $fade_dir, $points, $inside_pixels, $outside_pixels) =@_;
my($img,$layer, $shape, $fade_dir, $points,
$inside_pixels, $outside_pixels, $start_angle, $end_angle) =@_;
$pi = 3.1415927;
eval { $img->undo_push_group_start };
Gimp->progress_init("Burst");
$progress_increment = 1/$points;
$progress = 0;
($dumb, $x1, $y1, $x2, $y2) = $img->selection_bounds;
$img->selection_none;
......@@ -54,133 +76,162 @@ the inside and the outside of the burst.",
$center_x = $x1 + $width/2;
$center_y = $y1 + $height/2;
if ($start_angle > $end_angle)
{ # swap them
$angle = $end_angle;
$end_angle = $start_angle;
$start_angle = $angle;
}
if ($shape == 0)
{ #ellipse
$angle = 0;
for ($i = 0; $angle <2*$pi-0.01; $i++ )
{
$angle = $i * 2*$pi/$points;
# use the major/minor axis description of an ellipse:
# x^2 y^2
# --- + --- = 1
# a^2 b^2
#
# where a is the x axis, b is the y axis, and the equation of
# a line passing through 0 (y=mb). Solve for x&y, and pick the
# correct one for the angle.
$a = $width/2 - $outside_pixels;
$b = $height/2 - $outside_pixels;
# dimensions for an "inside ellipse"
$c = ($a>$b)?$inside_pixels:$inside_pixels*$a/$b;
$d = ($a>$b)?$inside_pixels*$b/$a:$inside_pixels;
# get the slope
$m = sin($angle)/cos($angle);
if ($m ==0) { $m = 0.000000000001; } #avoid div by 0
if ($c ==0) { $c = 0.000000000001; } #avoid div by 0
if ($d ==0) { $d = 0.000000000001; } #avoid div by 0
# find the positive solution of the quadratic for the endpoints
$x = sqrt(1/((1/$a/$a)+($m*$m/$b/$b)));
$y = sqrt(1/((1/($m*$m*$a*$a))+(1/$b/$b)));
# and find the starting points in the same manner
$x_start = sqrt(1/((1/$c/$c)+($m*$m/$d/$d)));
$y_start = sqrt(1/((1/($m*$m*$c*$c))+(1/$d/$d)));
# pick the right solution of the quadratic
if ($angle < $pi/2 || $angle > 3*$pi/2)
{
$x = -$x;
$x_start = -$x_start;
}
if ($angle > $pi)
{
$y = -$y;
$y_start = -$y_start;
}
# do translations to center stuff
$x = $x + $center_x;
$y = $y + $center_y;
$x_start = $x_start + $center_x;
$y_start = $y_start + $center_y;
# print "X = $x, Y = $y, M = $m\n";
if ($fade_dir == 1)
{
$layer->paintbrush_default(4, [$x, $y, $x_start, $y_start]);
}
else
{
$layer->paintbrush_default(4, [$x_start, $y_start, $x, $y]);
}
# the for loop just increments $i until $angle is big enough
for ($i = 0, $angle=$start_angle*$pi/180;
$angle <$end_angle*$pi/180-0.01;
$i++ )
{
$angle = $i * abs($start_angle-$end_angle)*$pi/$points/180;
$angle += $start_angle*$pi/180;
# use the major/minor axis description of an ellipse:
# x^2 y^2
# --- + --- = 1
# a^2 b^2
#
# where a is the x axis, b is the y axis, and the equation of
# a line passing through 0 (y=mb). Solve for x&y, and pick the
# correct one for the angle.
$a = $width/2 - $outside_pixels;
$b = $height/2 - $outside_pixels;
# dimensions for an "inside ellipse"
$c = ($a>$b)?$inside_pixels:$inside_pixels*$a/$b;
$d = ($a>$b)?$inside_pixels*$b/$a:$inside_pixels;
# get the slope
$m = sin($angle)/cos($angle);
if ($m ==0) { $m = 0.000000000001; } #avoid div by 0
if ($c ==0) { $c = 0.000000000001; } #avoid div by 0
if ($d ==0) { $d = 0.000000000001; } #avoid div by 0
# find the positive solution of the quadratic for the endpoints
$x = sqrt(1/((1/$a/$a)+($m*$m/$b/$b)));
$y = sqrt(1/((1/($m*$m*$a*$a))+(1/$b/$b)));
# and find the starting points in the same manner
$x_start = sqrt(1/((1/$c/$c)+($m*$m/$d/$d)));
$y_start = sqrt(1/((1/($m*$m*$c*$c))+(1/$d/$d)));
# pick the right solution of the quadratic
if ((find_in_2pi($angle) < $pi/2) || (find_in_2pi($angle) > 3*$pi/2))
{
$x = -$x;
$x_start = -$x_start;
}
if (find_in_2pi($angle) > $pi)
{
$y = -$y;
$y_start = -$y_start;
}
# do translations to center stuff
$x = $x + $center_x;
$y = $y + $center_y;
$x_start = $x_start + $center_x;
$y_start = $y_start + $center_y;
# print "X = $x, Y = $y, M = $m\n";
if ($fade_dir == 1)
{
$layer->paintbrush_default(4, [$x, $y, $x_start, $y_start]);
}
else
{
$layer->paintbrush_default(4, [$x_start, $y_start, $x, $y]);
}
$progress += $progress_increment;
Gimp->progress_update($progress);
}
}
else
{ #rectangle
# The idea here is to see where the line intersects with the
# rightmost line. If the abs of that is higer than the height,
# see where it intersects the top instead.
#print "width = $width, height = $height\n";
$angle = 0;
for ($i = 0; $angle <2*$pi-0.01; $i++ )
{
$angle = $i * 2*$pi/$points;
# get the slope
$m = sin($angle)/cos($angle);
# print "M = $m\n";
if (abs($m*$width/2) < $height/2-$outside_pixels)
{ # draw on the right/left borders
$x = $width/2-$outside_pixels;
$y = $m*($width/2-$outside_pixels);
$x_start = ($width>$height)
?$inside_pixels
:$inside_pixels*$width/$height;
$y_start = ($width>$height)
?$m*$inside_pixels
:$m*$inside_pixels*$width/$height;
}
else
{ # draw on the top/bottom borders
$y = $height/2-$outside_pixels;
$x = ($height/2-$outside_pixels)/$m;
$y_start = ($width>$height)
?$inside_pixels*$height/$width
:$inside_pixels;
$x_start = ($width>$height)
?$inside_pixels*$height/$width/$m
:$inside_pixels/$m;
}
if ($angle > $pi)
{
$x = -$x;
$y = -$y;
$x_start = -$x_start;
$y_start = -$y_start;
}
# print "X = $x, Y = $y\n";
# do translations to center stuff
$x = $x + $center_x;
$y = $y + $center_y;
$x_start = $x_start + $center_x;
$y_start = $y_start + $center_y;
if ($fade_dir == 1)
{
$layer->paintbrush_default(4, [$x, $y, $x_start, $y_start]);
}
else
{
$layer->paintbrush_default(4, [$x_start, $y_start, $x, $y]);
}
# The idea here is to see where the line intersects with the
# rightmost line. If the abs of that is higer than the height,
# see where it intersects the top instead.
#print "width = $width, height = $height\n";
for ($i = 0, $angle=$start_angle*$pi/180;
$angle <$end_angle*$pi/180-0.01;
$i++ )
{
$angle = $i * abs($start_angle-$end_angle)*$pi/$points/180;
$angle += $start_angle*$pi/180;
# get the slope
$m = sin($angle)/cos($angle);
# print "M = $m\n";
if (abs($m*$width/2) < $height/2-$outside_pixels)
{ # draw on the right/left borders
$x = $width/2-$outside_pixels;
$y = $m*($width/2-$outside_pixels);
$x_start = ($width>$height)
?$inside_pixels
:$inside_pixels*$width/$height;
$y_start = ($width>$height)
?$m*$inside_pixels
:$m*$inside_pixels*$width/$height;
}
else
{ # draw on the top/bottom borders
$y = $height/2-$outside_pixels;
$x = ($height/2-$outside_pixels)/$m;
$y_start = ($width>$height)
?$inside_pixels*$height/$width
:$inside_pixels;
$x_start = ($width>$height)
?$inside_pixels*$height/$width/$m
:$inside_pixels/$m;
}
# the method of finding points by lines like above makes picking right
# values kinda icky, as shown by these if statements.
if ((find_in_2pi($angle) <= $pi/2) || (find_in_2pi($angle) > 3*$pi/2))
{
$x = -abs($x);
$x_start = -abs($x_start);
}
else
{
$x = abs($x);
$x_start = abs($x_start);
}
if (find_in_2pi($angle) > $pi)
{
$y = -abs($y);
$y_start = -abs($y_start);
}
else
{
$y = abs($y);
$y_start = abs($y_start);
}
# do translations to center stuff
$x = $x + $center_x;
$y = $y + $center_y;
$x_start = $x_start + $center_x;
$y_start = $y_start + $center_y;
if ($fade_dir == 1)
{
$layer->paintbrush_default(4, [$x, $y, $x_start, $y_start]);
}
else
{
$layer->paintbrush_default(4, [$x_start, $y_start, $x, $y]);
}
$progress += $progress_increment;
Gimp->progress_update($progress);
}
}
eval { $img->undo_push_group_end };
......
......@@ -120,7 +120,8 @@ generally do not care for the url length.
Browser compatibility list (send more results to pcg@goof.com ;)
Netscape 3.x displays broken image icons
Netscape 4.x works on some configurations, not on others
Netscape 4.x works on some configurations (communicator!),
not on others (navigator!)
Lynx displays the base64 code as text :(
MSIE 4 thousands of error messages in dialog boxes ;->
MSIE 5 shows broken image icon
......
......@@ -53,7 +53,7 @@ register "firetext",
"Marc Lehmann <pcg\@goof.com>",
"Marc Lehmann",
"19990802",
__"<Toolbox>/Xtns/Render/Logos/Firetext",
N_"<Toolbox>/Xtns/Render/Logos/Firetext",
"*",
[
[PF_TEXT, "text", "The text to render (can be multi-line)", "burn,\nBurn,\nBURN!"],
......
......@@ -39,7 +39,7 @@ register "fit_text",
"Seth Burgess",
"Seth Burgess <sjburges\@gimp.org>",
"1999-03-21",
N_"<Image>/Filters/Render/Fit Text",
N_"<Image>/Filters/Render/Fit Text...",
"*",
[
[PF_FONT, "font", "What font type to use - size will be ignored", $defaultfont],
......@@ -51,25 +51,25 @@ register "fit_text",
$width = $x2-$x1;
$height = $y2-$y1;
@extents=gimp_text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
@extents=Gimp->text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
$growsize = ($extents[0]<$width && $extents[1]<$height) ? 288 : -288;
if ($growsize > 0 ) {
while ($extents[0]<$width && $extents[1]<$height) {
$xlfd = growfont($xlfd,$growsize);
@extents=gimp_text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
@extents=Gimp->text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
}
$xlfd = growfont($xlfd, -$growsize);
}
else {
while ($extents[0]>$width || $extents[1]>$height) {
$xlfd = growfont($xlfd,$growsize);
@extents=gimp_text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
@extents=Gimp->text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
}
}
while ($extents[0]<$width && $extents[1]<$height) {
$xlfd = growfont($xlfd,144); # precision for the last bit
@extents=gimp_text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
@extents=Gimp->text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
}
$xlfd = growfont($xlfd, -144);
......
......@@ -71,7 +71,7 @@ register "contrast_enhance_2x2",
"Marc Lehmann",
"Marc Lehmann <pcg\@goof.com>",
"19990725",
__"<Image>/Filters/Enhance/2x2 Contrast Enhance",
N_"<Image>/Filters/Enhance/2x2 Contrast Enhance",
"RGB*, GRAY*",
[],
sub {
......@@ -93,7 +93,7 @@ register "edge_detect_2x2",
"Marc Lehmann",
"Marc Lehmann <pcg\@goof.com>",
"19990725",
__"<Image>/Filters/Edge-Detect/2x2 Edge Detect",
N_"<Image>/Filters/Edge-Detect/2x2 Edge Detect",
"RGB*, GRAY*",
[],
sub {
......
#!/usr/bin/perl
# <sjburges@gimp.org>
# This is tigert's request. I suppose it'll be useful to those that do
# this sort of thing. Personally I'll probably only run it to test and
......@@ -8,11 +9,17 @@
#
# Bruce Miller (fixed to accomdate 1.1.x changes)
# Brendon and Wendy Humphrey <brendy@swipnet.se> (progress bar, nice comments)
#
# Tuomas Kuosmanen <tigert@gimp.org>
# Fixed some things to make this work with cvs gimp. Fixed calls to
# gimp_get_guide_orientation() (guide types that changed from
# GUIDE_VERTICAL to VERTICAL and horizontal, respectively. Should
# work now). Also convert to indexed parameters changed, fixed them too.
#
# If you have more additions, etc please don't hesitate to send them in!
use Gimp qw(:auto N_);
use Gimp;
use Gimp::Fu;
use Gimp::Util;
......@@ -28,7 +35,7 @@ sub get_vguides {
$i=0;
my @vguides;
while ($i=$img->find_next_guide($i)) {
if ($img->get_guide_orientation($i) == &Gimp::VERTICAL_GUIDE){
if ($img->get_guide_orientation($i) == &Gimp::VERTICAL){
$keyval = sprintf("%4d", $img->get_guide_position($i));
$vkeys{$keyval} = $i;
}
......@@ -49,7 +56,7 @@ sub get_hguides {
$i=0;
my @hguides;
while ($i=$img->find_next_guide($i)) {
if ($img->get_guide_orientation($i) == &Gimp::HORIZONTAL_GUIDE){
if ($img->get_guide_orientation($i) == &Gimp::HORIZONTAL){
$keyval = sprintf("%4d", $img->get_guide_position($i));
$hkeys{$keyval} = $i;
}
......@@ -73,9 +80,12 @@ sub dosel {
# print "Cropping from $l to $r, $t to $b\n";
$tmpimg->crop($r-$l, $b-$t, $l, $t);
$tmplay = $tmpimg->active_drawable;
if (! $tmplay->indexed) {
$tmpimg->convert_indexed(1,256);
}
if (! $tmplay->is_indexed) {
# do this: fs/low-bleed dither, make palette, 256 colors,
# dont dither alpha, do remove unused (is 1 "true" here?),
# custom palette is ignored (we create our own, thus "duck" works).
$tmpimg->convert_indexed (2,0,256,0,1,duck)
}
$tmpimg->gimp_file_save(-1,"$savepath$imgpath$imgname","$savepath$imgpath$imgname");
$tmpimg->delete;
return "$imgpath$imgname"; # what I want printed in html
......@@ -134,7 +144,7 @@ register "perlotine",
"Seth Burgess",
"Seth Burgess <sjburges\@gimp.org>",
"1999-03-19",
N_"<Image>/Guides/Perl-o-tine",
N_"<Image>/Filters/Web/Perl-o-tine...",
"*",
[
[PF_STRING, "save_path", "The path to export the HTML to",$ENV{HOME}],
......@@ -159,7 +169,7 @@ register "perlotine",
# Progress Bar
#
gimp_progress_init("Perl-o-Tine");
Gimp->progress_init("Perl-o-Tine");
$progress_increment = 1/(scalar(@horz) * scalar(@vert));
$progress = 0.0;
......@@ -200,7 +210,7 @@ register "perlotine",