Commit de2ac484 authored by Marc Lehmann's avatar Marc Lehmann
Browse files

see plug-ins/perl/Changes

parent 82f7af66
......@@ -5,6 +5,16 @@ Revision history for Gimp-Perl extension.
- data types for RADIO, SPINNER etc.. are guessed better now.
- added examples/guides_to_selection.
- added examples/burst, without even looking at it ;)
- warn about deprecated :auto behaviour, remove in next version.
- call displays_flush in more cases now.
- always leave a dummy dimension of 1 into the pdl, for gray and
indexed drawables. down the other road lies madness.
- implemented & added examples/map_to_gradient, needed for my next
plug-in ;)
- implemented & added examples/fire. I gained a bit of understanding
now.
- fixed a few bugs in Gimp::Fu. PF_PATTERN & friends confused the
current with the default value and didn't restore it properly.
1.1 Fri Jul 30 07:37:30 CEST 1999
- one of the most successful releases, in terms of features & bugfixes.
......
......@@ -127,7 +127,7 @@ sub import($;@) {
# make a quick but dirty guess ;)
@_=(@_procs,':consts',':auto') unless @_;
@_=(@_procs,':consts',':_auto2') unless @_;
for(@_) {
if ($_ eq ":auto") {
......@@ -138,6 +138,15 @@ sub import($;@) {
*{$AUTOLOAD} = sub { Gimp->$name(@_) };
goto &$AUTOLOAD;
};
} elsif ($_ eq ":_auto2") {
push(@export,@_consts,@_procs);
*{"$up\::AUTOLOAD"} = sub {
warn "$function: calling $AUTOLOAD without specifying the :auto import tag is deprecated!\n";
croak "Cannot call '$AUTOLOAD' at this time" unless initialized();
my ($class,$name) = $AUTOLOAD =~ /^(.*)::(.*?)$/;
*{$AUTOLOAD} = sub { Gimp->$name(@_) };
goto &$AUTOLOAD;
};
} elsif ($_ eq ":consts") {
push(@export,@_consts);
} elsif ($_ eq ":param") {
......
......@@ -300,7 +300,7 @@ sub interact($$$$@) {
} elsif($type == PF_FONT) {
my $fs=new Gtk::FontSelectionDialog "Font Selection Dialog ($desc)";
my $def = "-*-helvetica-medium-r-normal-*-24-*-*-*-p-*-iso8859-1";
my $def = "-*-helvetica-medium-r-normal-*-34-*-*-*-p-*-iso8859-1";
my $val;
my $l=new Gtk::Label "!error!";
......@@ -431,8 +431,8 @@ sub interact($$$$@) {
if ($gimp_10) {
&new_PF_STRING;
} else {
$a=new Gimp::UI::PatternSelect -active => $default;
push(@setvals,sub{$a->set('active',$default)});
$a=new Gimp::UI::PatternSelect -active => defined $value ? $value : (Gimp->gradients_get_pattern)[0];
push(@setvals,sub{$a->set('active',$_[0])});
push(@getvals,sub{$a->get('active')});
}
......@@ -440,8 +440,8 @@ sub interact($$$$@) {
if ($gimp_10) {
&new_PF_STRING;
} else {
$a=new Gimp::UI::BrushSelect -active => $default;
push(@setvals,sub{$a->set('active',$default)});
$a=new Gimp::UI::BrushSelect -active => defined $value ? $value : (Gimp->gradients_get_brush)[0];
push(@setvals,sub{$a->set('active',$_[0])});
push(@getvals,sub{$a->get('active')});
}
......@@ -449,8 +449,8 @@ sub interact($$$$@) {
if ($gimp_10) {
&new_PF_STRING;
} else {
$a=new Gimp::UI::GradientSelect -active => $default;
push(@setvals,sub{$a->set('active',$default)});
$a=new Gimp::UI::GradientSelect -active => defined $value ? $value : (Gimp->gradients_get_active)[0];
push(@setvals,sub{$a->set('active',$_[0])});
push(@getvals,sub{$a->get('active')});
}
......@@ -1160,26 +1160,28 @@ sub register($$$$$$$$$;@) {
my @imgs = &$code(@pre,@_);
$old_trace = Gimp::set_trace (0);
if (@imgs && $menupath !~ /^<Load>\//) {
for my $i (0..$#imgs) {
my $img = $imgs[$i];
next unless defined $img;
if (ref $img eq "Gimp::Image") {
if ($outputfile) {
my $path = sprintf $outputfile,$i;
if ($#imgs and $path eq $outputfile) {
$path=~s/\.(?=[^.]*$)/$i./; # insert image number before last dot
if ($menupath !~ /^<Load>\//) {
if (@imgs) {
for my $i (0..$#imgs) {
my $img = $imgs[$i];
next unless defined $img;
if (ref $img eq "Gimp::Image") {
if ($outputfile) {
my $path = sprintf $outputfile,$i;
if ($#imgs and $path eq $outputfile) {
$path=~s/\.(?=[^.]*$)/$i./; # insert image number before last dot
}
print "saving image $path\n" if $Gimp::verbose;
save_image($img,$path);
$img->delete;
} elsif ($run_mode != &Gimp::RUN_NONINTERACTIVE) {
$img->display_new unless $input_image && $$img == $$input_image;
}
print "saving image $path\n" if $Gimp::verbose;
save_image($img,$path);
$img->delete;
} elsif ($run_mode != &Gimp::RUN_NONINTERACTIVE) {
$img->display_new unless $input_image && $$img == $$input_image;
} elsif (!@$retvals) {
warn "WARNING: $function returned something that is not an image: \"$img\"\n";
}
} elsif (!@$retvals) {
warn "WARNING: $function returned something that is not an image: \"$img\"\n";
}
}
}
Gimp->displays_flush;
}
......
......@@ -103,7 +103,7 @@ static pdl *new_pdl (int a, int b, int c)
PDL_Long dims[3];
int ndims = 0;
if (c > 1) dims[ndims++] = c;
if (c > 0) dims[ndims++] = c;
if (b > 0) dims[ndims++] = b;
if (a > 0) dims[ndims++] = a;
......@@ -2152,23 +2152,21 @@ gimp_pixel_rgn_data(pr,newdata=0)
}
else
{
int ndims = 2 + (pr->bpp > 1);
pdl *p = PDL->new();
PDL_Long dims[3];
dims[0] = pr->bpp;
dims[ndims-2] = pr->rowstride / pr->bpp;
dims[ndims-1] = pr->h;
dims[1] = pr->w;/*D*/
dims[2] = pr->h;
PDL->setdims (p, dims, ndims);
PDL->setdims (p, dims, 3);
p->datatype = PDL_B;
p->data = pr->data;
p->state |= PDL_DONTTOUCHDATA | PDL_ALLOCATED;
PDL->add_deletedata_magic(p, pixel_rgn_pdl_delete_data, 0);
if (pr->w != dims[ndims-2])
p = redim_pdl (p, ndims-2, pr->w);
if (pr->w != dims[1])
p = redim_pdl (p, 1, pr->w);
RETVAL = p;
}
......
......@@ -2,8 +2,9 @@
Gimp::Pixel - how to operate on raw pixels.
***WARNING*** this manpage is no longer up-to-date. See C<examples/colourtoalpha>
for a simple raw-piyxel-manipulating plug-in.
***WARNING*** this manpage is no longer up-to-date. See
C<examples/map_to_gradient> for a simple raw-pixel-manipulating
plug-in. If you bug me enough I'll rewrite this document.
=head1 SYNOPSIS
......
......@@ -158,7 +158,7 @@ sub GTK_OBJECT_INIT {
$l->set_selection_mode(-browse);
$self->{list}=$l;
for($self->get_list) {
for(sort $self->get_list) {
$l->add(new Gtk::ListItem $_);
}
......
......@@ -112,3 +112,5 @@ examples/guide_remove
examples/glowing_steel
examples/guides_to_selection
examples/burst
examples/map_to_gradient
examples/fire
......@@ -5,7 +5,6 @@ use Config;
$|=1;
@examples =
# not yet: magick
qw(windy.pl prep4gif.pl webify.pl PDB alpha2color.pl tex-to-float ditherize.pl
border.pl view3d.pl feedback.pl xachlego.pl xachshadow.pl parasite-editor
scratches.pl blowinout.pl terral_text xachvision.pl perlcc gouge
......@@ -13,7 +12,8 @@ $|=1;
perlotine randomblends innerbevel fit-text guidegrid roundrectsel
repdup centerguide stampify goldenmean triangle billboard mirrorsplit
oneliners randomart1 pixelmap glowing_steel frame_reshuffle frame_filter
logulator miff magick guide_remove guides_to_selection burst
logulator miff magick guide_remove guides_to_selection burst map_to_gradient
fire
);
@shebang = (map("examples/$_",@examples),
qw(Perl-Server examples/example-net.pl examples/homepage-logo.pl
......
......@@ -8,18 +8,18 @@ gimp ~/pix/ka001.jpg -b "(extension-perl-server 0 0 0)"
file:///usr/app/lib/perl5/site_perl/i686-linux/PDL/HtmlDocs/PDL/
make test TEST_VERBOSE=1
aaron sherman email schicken(!!!!) wegen logulator
API generalization
guide ->
gimp_desaturate -> drawable
paint_funcs.h convolve.h gimpdrawable.h gimpimage.h lut_funcs.h paint_core.h plug_in.h flip_tool.h
Guides->To Selection
firetext!
firetext! AND _grayscale_ for map_gradient(!)
script-fu 4.9 vs. 3.3
bugs
* /root/gimprelease && TODO -> publish!
* map_to_gradient does not work on GRAYA thingies. Argh.
[DONE] * /root/gimprelease && TODO -> publish!
* perl_require_pv with _59?
* scroll behaviour, use clist instead of list?
[DONE] * can_Default for oter OK-buttons
......
......@@ -48,8 +48,6 @@ am not responsible for your data-loss!
None ;)
=back
=head1 AUTHOR
Marc Lehmann <pcg@goof.com>
......
......@@ -9,7 +9,7 @@ register "center_guide",
"Claes G Lindblad <claesg\@algonet.se>",
"Claes G Lindblad",
"990323",
"<Image>/Center Guide",
"<Image>/Guides/Center Guide",
"*",
[
[PF_RADIO,
......
#!/usr/bin/perl
use Gimp;
use Gimp::Fu;
sub fire {
my ($image, $drawable, $threshold, $strength, $gradient, $displace) = @_;
my ($w,$h) = ($drawable->width, $drawable->height);
$drawable->layer or die "sorry, this function needs to call functions that work only for layers :(\n";
$image->undo_push_group_start;
$drawable->wind($threshold, 0, $strength, 0, 1);
$drawable->wind($threshold, 1, $strength, 0, 1);
$drawable->layer_rot270;
$drawable->wind($threshold, 0, $strength, 0, 1);
$drawable->wind($threshold, 1, $strength, 0, 1);
$drawable->layer_rot90;
$drawable->gauss_rle(($w**2+*$h**2)**0.5*0.003+1,1,1);
$drawable->desaturate if $drawable->color;
$drawable->ripple($w*0.05,$w*0.002,0,2,1,1,0);
$drawable->ripple($h*0.05,$h*0.002,1,2,1,1,0);
$drawable->displace($w*0.05,$w*0.05,1,1,$drawable,$drawable,BLACK) if $displace;
$drawable->c_astretch;
$drawable->map_to_gradient($gradient);
$image->undo_push_group_end;
();
}
register "fire",
"Create a burning (depending on the gradient) halo around an object.",
"=pod(DESCRIPTION)",
"Marc Lehmann <pcg\@goof.com>",
"Marc Lehmann",
"19990802",
"<Image>/Filters/Colors/Fire",
"*",
[
[PF_SLIDER, "threshold", "Intensity at which to start smearing", 10, [0,255,1]],
[PF_SLIDER, "strength", "The strength (length) of the bursts", 30, [1,300,5]],
[PF_GRADIENT, "gradient", "The gradient to use for the colour, e.g. 'Incandescent' or 'Burning_Paper'", 'Burning_Transparency'],
[PF_TOGGLE, "displace", "Additionally displace with itself?", 0],
],
[],
['gimp-1.1'],
\&fire;
register "firetext",
"Create a burning (depending on the gradient) halo around a string (see <Image>/Filters/Color/Fire).",
"=pod(DESCRIPTION)",
"Marc Lehmann <pcg\@goof.com>",
"Marc Lehmann",
"19990802",
"<Toolbox>/Xtns/Render/Logos/Firetext",
"*",
[
[PF_TEXT, "text", "The text to render (can be multi-line)", "burn,\nBurn,\nBURN!"],
[PF_FONT, "font", "The font to use"],
[PF_TOGGLE, "inverse", "Invert source mask?", 1],
[PF_SLIDER, "strength", "The strength (length) of the bursts", 50, [1,300,5]],
[PF_GRADIENT, "gradient", "The gradient to use for the colour, e.g. 'Incandescent' or 'Burning_Paper'", 'Burning_Transparency'],
[PF_TOGGLE, "displace", "Additionally displace with itself?", 0],
],
[[PF_IMAGE, "image", "The resulting image"]],
['gimp-1.1'],
sub {
my ($text, $font, $inverse, $strength, $gradient, $displace) = @_;
if ($inverse) {
Palette->set_foreground('black');
Palette->set_background('white');
} else {
Palette->set_foreground('white');
Palette->set_background('black');
}
my ($w,$h) = Gimp->text_get_extents_fontname($text, xlfd_size $font, $font);
my $image = new Image $w+40, $h+40, RGB;
$image->disable_undo;
my $layer = new Layer $image, $w+40, $h+40, RGBA_IMAGE, "text layer", 100, NORMAL_MODE;
$layer->fill(BG_IMAGE_FILL);
$layer->add_layer(0);
$layer->text_fontname(20,20, $text,0, 1, xlfd_size $font, $font)->anchor;
fire($image,$layer,5,$strength,$gradient,$displace);
Palette->set_foreground('black');
$image->text_fontname(-1,20-10*$displace,20-10*$displace, $text,0, 1, xlfd_size $font, $font);
$image->enable_undo;
$image->clean_all;
($image);
};
exit main;
=head1 DESCRIPTION
This plug-in creates a kind of "burning" effect around a drawable. Both
black-on-white and white-on-black source images make sense and create
different effects (do not use displace with black-on-white drawables,
though ;).
Although the original colour of the image does not matter, supplying a
greyscale drawable (though working) does not look very cool.
......@@ -24,15 +24,13 @@ sub iterate {
my $src = new PixelRgn ($drawable,@bounds[0,1],$bounds[2]+1,$bounds[3]+1,0,0);
my $dst = new PixelRgn ($drawable,@bounds,1,1);
my $bpp = $src->bpp > 1 ? ":," : "";
my $iter = Gimp->pixel_rgns_register ($dst);
my $area = $bounds[2]*$bounds[3];
my $progress = 0;
do {
my ($x,$y,$w,$h)=($dst->x,$dst->y,$dst->w,$dst->h);
$dst->data($kernel->($bpp,$src->get_rect($x,$y,$w+1,$h+1)->convert(short)));
$dst->data($kernel->($src->get_rect($x,$y,$w+1,$h+1)->convert(short)));
$progress += $w*$h/$area;
Gimp->progress_update ($progress);
} while (Gimp->pixel_rgns_process ($iter));
......@@ -60,10 +58,10 @@ register "blur_2x2",
iterate $drawable,
"2x2 smoothing...",
sub {
($_[1]->slice("$_[0]0:-2,0:-2")+
$_[1]->slice("$_[0]1:-1,0:-2")+
$_[1]->slice("$_[0]1:-1,1:-1")+
$_[1]->slice("$_[0]0:-2,1:-1"))>>2;
($_[0]->slice(":,0:-2,0:-2")+
$_[0]->slice(":,1:-1,0:-2")+
$_[0]->slice(":,1:-1,1:-1")+
$_[0]->slice(":,0:-2,1:-1"))>>2;
};
};
......@@ -82,8 +80,8 @@ register "contrast_enhance_2x2",
iterate $drawable,
"2x2 contrast enhancing...",
sub {
my $T = $_[1]->slice("$_[0]0:-2,0:-2");
my $D = $_[1]->slice("$_[0]1:-1,1:-1");
my $T = $_[0]->slice(":,0:-2,0:-2");
my $D = $_[0]->slice(":,1:-1,1:-1");
(($T<<1)-$D)->clip(0,255);
};
......@@ -100,19 +98,18 @@ register "edge_detect_2x2",
[],
sub {
my($image,$drawable)=@_;
my $bpp = 3-!!($drawable->gray);
iterate $drawable,
"2x2 cross gradient...",
sub {
my $T = $_[1]->slice("$_[0]0:-2,0:-2");
my $R = $_[1]->slice("$_[0]1:-1,0:-2");
my $D = $_[1]->slice("$_[0]1:-1,1:-1");
255-abs(cat($T-$R,$T-$D))
->convert(byte)
->mv($bpp,0)
->maximum;
my $T = $_[0]->slice(":,0:-2,0:-2");
my $R = $_[0]->slice(":,1:-1,0:-2");
my $D = $_[0]->slice(":,1:-1,1:-1");
abs(cat($T-$R,$T-$D))
->convert(byte)
->mv(3,0)
->maximum;
};
};
......
#!/usr/bin/perl
use Gimp::Feature 'pdl';
use Gimp 1.1;
use Gimp::Fu;
use Gimp::Util;
use PDL::LiteF;
# convert to greyscale. could be improved, but should still be fast!
sub togrey {
my $pdl = shift;
$pdl->convert(ushort);
$pdl=$pdl->inner(pdl[54,183,18])/256;
$pdl->convert(byte);
$pdl;
}
register "map_to_gradient",
"map grayscale values to gradient",
"Map all the pixels to the colours of a gradient according to their greyscale value.",
"Marc Lehmann",
"Marc Lehmann <pcg\@goof.com>",
"19990802",
"<Image>/Filters/Colors/Map To Gradient",
"RGB*, GRAY",
[
[PF_GRADIENT, "gradient", "The gradient to map to"],
],
sub {
my($image,$drawable,$gradient)=@_;
Gimp->progress_init ("Mapping to '$gradient'");
my $grad = pdl byte, map $_*255, @{(Gimp->gradients_get_gradient_data($gradient,256))[1]};
$grad->reshape(4,256);
my $alpha = $drawable->has_alpha;
$grad = $grad->slice('0:-2') unless $alpha;
$grad = togrey($grad)->dummy(0) unless $drawable->color;
my $depth = ($grad->dims)[0]; # precalculcate
$grad = $grad->xchg(0,1); # this form is later needed in index, so do it now
my @bounds = $drawable->bounds;
my @off = $drawable->offsets;
{
my $src = new PixelRgn ($drawable,@bounds,0,0);
my $dst = new PixelRgn ($drawable,@bounds,1,1);
my $iter = Gimp->pixel_rgns_register($src,$dst);
my $area = $bounds[2]*$bounds[3];
my $progress = 0;
do {
my $data = $src->data;
$data = $data->slice("0:-2") if $alpha; # get rid of alpha
$data = $src->bpp > 2 ? togrey($data) : $data->clump(2);
# now map from grey values to gradient
$dst->data( index($grad,$data->dummy(0,$depth)) );
$progress += ($src->w*$src->h)/$area;
Gimp->progress_update ($progress);
} while (Gimp->pixel_rgns_process ($iter));
}
Gimp->progress_update (1);
$drawable->merge_shadow (1);
$drawable->update (@bounds);
();
};
exit main;
......@@ -26,7 +26,7 @@
#[terral] input levels of 0, .24, 113 [22:11]
#[terral] --end of script [22:12]
use Gimp 1.06;
use Gimp ':auto';
use Gimp::Fu;
use Gimp::Util;
......
......@@ -25,7 +25,7 @@ sub {
my $regn = $dwb->pixel_rgn (0, 0, $w, $h, 0, 0);
my $surf = $regn->get_rect (0, 0, $w, $h);
$surf=$surf->slice("(0)") if $surf->getndims>2;
$surf=$surf->slice("(0)");
imag3d [ $polar ? 'POLAR2D' : 'SURF2D', $surf ],
{ 'Lines' => $lines, 'Smooth' => $smooth };
......
......@@ -3,7 +3,7 @@
# sent to me by Seth Burgess <sjburges@gimp.org>
# small changes my Marc Lehmann <pcg@goof.com>
use Gimp;
use Gimp ':auto';
use Gimp::Fu;
#Gimp::set_trace(TRACE_CALL);
......@@ -21,11 +21,11 @@ sub windify {
gimp_image_add_layer($out,$windlayer,0);
my $windlayercopy = gimp_layer_copy($windlayer, 1);
gimp_image_add_layer($out,$windlayercopy,0);
plug_in_noisify(1,$out,$windlayercopy,0,$density/255,
plug_in_noisify($windlayercopy,0,$density/255,
$density/255,
$density/255,1);
plug_in_mblur(1,$out,$windlayercopy,0,15,$angle);
plug_in_mblur($windlayercopy,0,15,$angle);
gimp_layer_set_mode($windlayercopy, 10); # Lighten Only
gimp_image_merge_visible_layers($out,0);
......@@ -33,7 +33,7 @@ sub windify {
# gimp_image_merge_visible_layers bug
my $newlay = gimp_image_get_active_layer ($out);
plug_in_displace(1,$img,$drawable,-$distance*cos($angle*180/3.14159),
plug_in_displace($drawable,-$distance*cos($angle*180/3.14159),
$distance*sin($angle*180/3.14159),
1,1, $newlay,$newlay, $wrap);
gimp_image_remove_layer($out,$newlay);
......
......@@ -29,7 +29,7 @@
# in a directory more suitable than the lame "Misc"
# Here's the boring start of every script...
use Gimp;
use Gimp ':auto';
use Gimp::Fu;
register "xach_blocks",
......
......@@ -22,7 +22,7 @@
#
# Here's the boring start of every script...
use Gimp;
use Gimp ':auto';
use Gimp::Fu;
register "xach_shadows",
......
Markdown is supported
0% or .