see plug-ins/perl/Changes
This commit is contained in:
@ -10,7 +10,9 @@ Revision history for Gimp-Perl extension.
|
|||||||
- do not install examples/gap-vcr.
|
- do not install examples/gap-vcr.
|
||||||
- added new sethspin, with slight changes.
|
- added new sethspin, with slight changes.
|
||||||
- do not install "feedback".
|
- do not install "feedback".
|
||||||
- updated xachlego.
|
- updated examples/xachlego.
|
||||||
|
- added examples/blended2, examples/translogo.
|
||||||
|
- removed examples/giflogo.
|
||||||
|
|
||||||
1.19 Thu Jan 6 00:21:58 CET 2000
|
1.19 Thu Jan 6 00:21:58 CET 2000
|
||||||
- used N_ to mark all the menu paths, since gimp now tries to
|
- used N_ to mark all the menu paths, since gimp now tries to
|
||||||
|
@ -122,8 +122,12 @@ examples/bricks
|
|||||||
examples/dataurl
|
examples/dataurl
|
||||||
examples/colorhtml
|
examples/colorhtml
|
||||||
examples/gap-vcr
|
examples/gap-vcr
|
||||||
examples/giflogo
|
examples/translogo
|
||||||
examples/sethspin
|
examples/sethspin
|
||||||
|
examples/roundsel
|
||||||
|
examples/visual
|
||||||
|
examples/billboard
|
||||||
|
examples/blended2
|
||||||
pxgettext
|
pxgettext
|
||||||
po/ChangeLog
|
po/ChangeLog
|
||||||
po/gimp-perl.pot
|
po/gimp-perl.pot
|
||||||
@ -131,3 +135,4 @@ po/de.po
|
|||||||
po/it.po
|
po/it.po
|
||||||
po/cs.po
|
po/cs.po
|
||||||
po/no.po
|
po/no.po
|
||||||
|
po/update.sh
|
||||||
|
@ -28,8 +28,8 @@ if ($ARGV[0] ne "--writemakefile") {
|
|||||||
|
|
||||||
@pins =
|
@pins =
|
||||||
qw(windify prep4gif webify PDB tex-to-float ditherize
|
qw(windify prep4gif webify PDB tex-to-float ditherize
|
||||||
xachlego xachshadow parasite-editor roundsel
|
xachlego xachshadow parasite-editor roundsel blended2
|
||||||
scratches blowinout terral_text xachvision perlcc giflogo
|
scratches blowinout terral_text xachvision perlcc translogo
|
||||||
animate_cells image_tile yinyang stamps font_table sethspin
|
animate_cells image_tile yinyang stamps font_table sethspin
|
||||||
perlotine randomblends innerbevel fit-text guidegrid roundrectsel
|
perlotine randomblends innerbevel fit-text guidegrid roundrectsel
|
||||||
repdup centerguide stampify goldenmean triangle mirrorsplit
|
repdup centerguide stampify goldenmean triangle mirrorsplit
|
||||||
@ -248,10 +248,7 @@ autoconf:
|
|||||||
|
|
||||||
# merge messages into potfile
|
# merge messages into potfile
|
||||||
msgmerge:
|
msgmerge:
|
||||||
./pxgettext `find . -name '*.pm' -o -name '*.xs' -o -path './examples/*'` Perl-Server | \\
|
./po/update.sh
|
||||||
msgmerge -w 83 po/gimp-perl.pot - >gimp-perl.pot~ && \\
|
|
||||||
mv gimp-perl.pot~ po/gimp-perl.pot
|
|
||||||
for po in po/*.po; do msgmerge -w 83 \$\$po po/gimp-perl.pot >\$\$po~ && mv \$\$po~ \$\$po; done
|
|
||||||
|
|
||||||
# set \$VERSION in all modules
|
# set \$VERSION in all modules
|
||||||
setver:
|
setver:
|
||||||
|
@ -488,7 +488,6 @@ sub _new_adjustment {
|
|||||||
$adj[3]||=($adj[1]-$adj[0])*0.01;
|
$adj[3]||=($adj[1]-$adj[0])*0.01;
|
||||||
$adj[4]||=0;
|
$adj[4]||=0;
|
||||||
|
|
||||||
print "new adjustment $_[0], @adj\n";
|
|
||||||
new Gtk::Adjustment $_[0],@adj;
|
new Gtk::Adjustment $_[0],@adj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
186
plug-ins/perl/examples/billboard
Executable file
186
plug-ins/perl/examples/billboard
Executable file
@ -0,0 +1,186 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
# This one's all mine. Well, its GPL/Artisitic but I"m the author and creator. # I think you need gimp 1.1 or better for this - if you don't, please let
|
||||||
|
# me know
|
||||||
|
|
||||||
|
# I'm hacking this on top of my sethspin script, so this is doing even more
|
||||||
|
# stuff it wasn't really designed to do. Hence if you thought sethspin was
|
||||||
|
# a bit ugly, look at this one...
|
||||||
|
|
||||||
|
# I think it was tigert that suggested this. It turned out to be less
|
||||||
|
# complex than I orginally thought so I figured I'd give it a spin.
|
||||||
|
|
||||||
|
# Seth Burgess
|
||||||
|
# <sjburges@gimp.org>
|
||||||
|
|
||||||
|
use Gimp qw(:auto);
|
||||||
|
use Gimp::Fu;
|
||||||
|
use Gimp::Util;
|
||||||
|
|
||||||
|
# Uncomment below to spew forth much data about whats going on.
|
||||||
|
#Gimp::set_trace(TRACE_ALL);
|
||||||
|
|
||||||
|
sub saw { # a sawtooth function on PI
|
||||||
|
($val) = @_;
|
||||||
|
if ($val < 3.14159/2.0) {
|
||||||
|
return ($val/3.14159) ;
|
||||||
|
}
|
||||||
|
elsif ($val < 3.14159) {
|
||||||
|
return (-1+$val/3.14159);
|
||||||
|
}
|
||||||
|
elsif ($val < 3.14159+3.14159/2.0) {
|
||||||
|
return ($val/3.14159) ;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (-1+$val/3.14159);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub spin_layer { # the function for actually spinning the layer
|
||||||
|
my ($img, $spin, $dest, $numframes, $prp, $blinds) = @_;
|
||||||
|
# Now lets spin it!
|
||||||
|
$stepsize = 3.14159/$numframes; # in radians
|
||||||
|
for ($i=0; $i<=3.14159; $i+=$stepsize) {
|
||||||
|
Gimp->progress_update ($i/3.14159);
|
||||||
|
# create a new layer for spinning
|
||||||
|
$framelay = ($i < 3.14159/2.0) ? $spin->copy(1) : $dest->copy(1);
|
||||||
|
$img->add_layer($framelay, 0);
|
||||||
|
# spin it a step
|
||||||
|
# Here I need to make the proper selection, repeatedly if necessary
|
||||||
|
$blindheight = $img->height/$blinds;
|
||||||
|
for ($j=0; $j<$blinds; $j++) {
|
||||||
|
# select a section
|
||||||
|
$img->rect_select(0, $j*$blindheight, $img->width, $blindheight, 2, 0, 0.13);
|
||||||
|
@x = $img->selection_bounds();
|
||||||
|
# x[1],x[2] x[3],x[2]
|
||||||
|
# x[1],x[4] x[3],x[4]
|
||||||
|
$floater = $framelay->perspective(1,
|
||||||
|
$x[1]+saw($i)*$prp*$framelay->width,$x[2]+$blindheight *sin($i)/2,
|
||||||
|
$x[3]-saw($i)*$prp*$framelay->width,$x[2]+$blindheight *sin($i)/2,
|
||||||
|
$x[1]-saw($i)*$prp*$framelay->width,$x[4]-$blindheight *sin($i)/2,
|
||||||
|
$x[3]+saw($i)*$prp*$framelay->width,$x[4]-$blindheight *sin($i)/2);
|
||||||
|
|
||||||
|
# Gimp Perspective Functionality has changed. It used to create a floating
|
||||||
|
# selection if there was a selection active already. Now it only does that
|
||||||
|
# in interactive - PDB makes it a new layer. Fine by me, wish the docs had
|
||||||
|
# changed though.
|
||||||
|
# $floater->floating_sel_anchor;
|
||||||
|
|
||||||
|
} # end for ($j=0;...
|
||||||
|
|
||||||
|
# I need to create another layer beind this spun one now
|
||||||
|
$backlayer = $framelay->layer_copy(0);
|
||||||
|
$img->add_layer($backlayer, 1);
|
||||||
|
$backlayer->fill(1); # BG-IMAGE-FILL
|
||||||
|
}
|
||||||
|
for ($i=0; $i<$numframes; $i++) {
|
||||||
|
@all_layers = $img->get_layers();
|
||||||
|
$img->set_visible($all_layers[$i],$all_layers[$i+1]);
|
||||||
|
$img->merge_visible_layers(0);
|
||||||
|
}
|
||||||
|
@all_layers = $img->get_layers();
|
||||||
|
$destfram = $all_layers[$numframes]->copy(0);
|
||||||
|
$img->add_layer($destfram,0);
|
||||||
|
|
||||||
|
# clean up my temporary layers
|
||||||
|
$img->remove_layer($all_layers[$numframes]);
|
||||||
|
$img->remove_layer($all_layers[$numframes+1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
register "billboard",
|
||||||
|
"Billboard",
|
||||||
|
"Take one image. Spin it about the multiple axes, and end up with another image. I made it for easy web buttons, mostly because somebody suggested to me.",
|
||||||
|
"Seth Burgess",
|
||||||
|
"Seth Burgess <sjburges\@gimp.org>",
|
||||||
|
"1.3",
|
||||||
|
N_"<Toolbox>/Xtns/Animation/Billboard",
|
||||||
|
"*",
|
||||||
|
[
|
||||||
|
[PF_DRAWABLE, "source", "What drawable to spin from?"],
|
||||||
|
[PF_DRAWABLE, "destination","What drawable to spin to?"],
|
||||||
|
[PF_INT8, "frames", "How many frames to use?", 16],
|
||||||
|
[PF_COLOR, "background", "What color to use for background if not transparent", [0,0,0]],
|
||||||
|
[PF_SLIDER, "perspective", "How much perspective effect to get", 40, [0,255,5]],
|
||||||
|
[PF_TOGGLE, "spin_back", "Also spin back?" , 0],
|
||||||
|
[PF_TOGGLE, "convert_indexed", "Convert to indexed?", 1],
|
||||||
|
[PF_SPINNER, "billboard_slats", "Number of shades", 3, [1,50,1]],
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
['gimp-1.1'],
|
||||||
|
sub {
|
||||||
|
my($src,$dest,$frames,$color,$psp,$spinback,$indexed, $shadenum) =@_;
|
||||||
|
$maxwide = ($src->width > $dest->width) ? $src->width : $dest->width;
|
||||||
|
$maxhigh = ($src->height > $dest->height) ? $src->height: $dest->height;
|
||||||
|
$img = gimp_image_new($maxwide, $maxhigh, RGB);
|
||||||
|
|
||||||
|
|
||||||
|
$tmpimglayer = $img->add_new_layer(0,3,1);
|
||||||
|
$img->display_new;
|
||||||
|
Gimp->progress_init("Billboard...",-1);
|
||||||
|
$oldbackground = gimp_palette_get_background();
|
||||||
|
Palette->set_background($color);
|
||||||
|
$src->edit_copy();
|
||||||
|
$spinlayer = $tmpimglayer->edit_paste(1);
|
||||||
|
$spinlayer->floating_sel_to_layer();
|
||||||
|
|
||||||
|
$dest->edit_copy();
|
||||||
|
$destlayer = $tmpimglayer->edit_paste(1);
|
||||||
|
$destlayer->floating_sel_to_layer();
|
||||||
|
|
||||||
|
$tmpimglayer->remove_layer;
|
||||||
|
|
||||||
|
$spinlayer->resize($maxwide, $maxhigh, $spinlayer->offsets);
|
||||||
|
$destlayer->resize($maxwide, $maxhigh, $destlayer->offsets);
|
||||||
|
# work around for PF_SLIDER when < 1
|
||||||
|
$psp = $psp/255.0;
|
||||||
|
|
||||||
|
# need an even number of frames for spinback
|
||||||
|
if ($frames%2 && $spinback) {
|
||||||
|
$frames++;
|
||||||
|
gimp_message("An even number of frames is needed for spin back.\nAdjusted frames up to $frames");
|
||||||
|
}
|
||||||
|
|
||||||
|
spin_layer($img, $spinlayer, $destlayer, $spinback ? $frames/2 : $frames-1, $psp, $shadenum);
|
||||||
|
$img->set_visible($img->add_new_layer(1),($img->get_layers)[0]);
|
||||||
|
$img->merge_visible_layers(0);
|
||||||
|
|
||||||
|
if ($spinback) {
|
||||||
|
@layerlist = $img->get_layers();
|
||||||
|
$img->add_layer($layerlist[$frames/2]->copy(0),0);
|
||||||
|
@layerlist = $img->get_layers();
|
||||||
|
spin_layer($img, $layerlist[1], $layerlist[0], $frames/2, $psp, $shadenum);
|
||||||
|
$img->remove_layer(($img->get_layers)[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
# unhide and name layers
|
||||||
|
@all_layers = $img->get_layers;
|
||||||
|
$img->set_visible(@all_layers);
|
||||||
|
for ($i=1; $i<=$frames ; $i++) {
|
||||||
|
$all_layers[$i-1]->set_name("Spin Layer $i (50ms)");
|
||||||
|
}
|
||||||
|
$all_layers[$frames-1]->set_name("Spin Layer SRC (250ms)");
|
||||||
|
|
||||||
|
if ($spinback) {
|
||||||
|
$all_layers[$frames/2-1]->set_name("Spin Layer DEST (250ms)");
|
||||||
|
}
|
||||||
|
else { $all_layers[0]->set_name("Spin Layer DEST (250ms)")}
|
||||||
|
|
||||||
|
|
||||||
|
# indexed conversion wants a display for some reason
|
||||||
|
if ($indexed) {
|
||||||
|
$img->convert_indexed(1, # dither type = fs
|
||||||
|
MAKE_PALETTE, # palette type
|
||||||
|
255, # number of colors
|
||||||
|
0, # don't dither transparency
|
||||||
|
1, # (ignored)
|
||||||
|
"Custom" # custom palette name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Palette->set_background($oldbackground);
|
||||||
|
gimp_displays_flush();
|
||||||
|
return();
|
||||||
|
};
|
||||||
|
|
||||||
|
exit main;
|
||||||
|
|
88
plug-ins/perl/examples/blended2
Executable file
88
plug-ins/perl/examples/blended2
Executable file
@ -0,0 +1,88 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use Gimp qw(:auto __ N_);
|
||||||
|
use Gimp::Fu;
|
||||||
|
use Gimp::Util;
|
||||||
|
|
||||||
|
#Gimp::set_trace(TRACE_CALL);
|
||||||
|
|
||||||
|
sub my_innerbevel {
|
||||||
|
my ($image, $drawable, $bg_col, $bl1, $bl2, $elev, $depth, $rad_tog) = @_;
|
||||||
|
$drawable->has_alpha or die "You can't run this script without an ALPHA CHANNEL!!";
|
||||||
|
my $img = gimp_image_new (256, 100, RGB_IMAGE);
|
||||||
|
$drawable->image->selection_all;
|
||||||
|
$drawable->edit_copy;
|
||||||
|
gimp_selection_none ($image);
|
||||||
|
if ($rad_tog == 0) {
|
||||||
|
my $bg_layer;
|
||||||
|
$bg_layer=$img->layer_new($drawable->width,$drawable->height,$image->layertype(1), "Background", 100, NORMAL_MODE);
|
||||||
|
gimp_palette_set_background ($bg_col);
|
||||||
|
$bg_layer->drawable_fill(BG_IMAGE_FILL);
|
||||||
|
$img->add_layer($bg_layer,0);
|
||||||
|
}
|
||||||
|
$img->resize($drawable->width,$drawable->height, 0, 0);
|
||||||
|
my $text1_lay;
|
||||||
|
$text1_lay=$img->layer_new($drawable->width,$drawable->height,$image->layertype(1), "Text -1-", 100, NORMAL_MODE);
|
||||||
|
$img->add_layer($text1_lay,-1);
|
||||||
|
gimp_edit_clear ($text1_lay);
|
||||||
|
$text1_lay->edit_paste(0)->floating_sel_anchor;
|
||||||
|
$text1_lay->set_preserve_trans(1);
|
||||||
|
gimp_palette_set_foreground ($bl1);
|
||||||
|
gimp_palette_set_background ($bl2);
|
||||||
|
@start = ($text1_lay->width / 2 - 5, 0);
|
||||||
|
@end = ($text1_lay->width / 2 + 5, $text1_lay->height);
|
||||||
|
gimp_blend ($text1_lay, 0, 0, 0, 100, 0, 0, 0, 2, 0.30, @start, @end);
|
||||||
|
my $text2_lay;
|
||||||
|
$text2_lay=$text1_lay->copy(1);
|
||||||
|
$img->add_layer($text2_lay, -1);
|
||||||
|
gimp_palette_set_background ([255, 255, 255]);
|
||||||
|
$text2_lay->edit_fill;
|
||||||
|
$text2_lay->set_preserve_trans(0);
|
||||||
|
$text1_lay->set_preserve_trans(0);
|
||||||
|
plug_in_gauss_rle ($text2_lay, 6, 1, 1);
|
||||||
|
plug_in_bump_map ($img, $text1_lay, $text2_lay, 110.0, $elev, $depth, 0, 0, 0, 0, 0, 0, 0);
|
||||||
|
$text2_lay->invert;
|
||||||
|
$img->lower_layer($text2_lay);
|
||||||
|
$text2_lay->translate(2, 3);
|
||||||
|
$text2_lay->set_opacity(75);
|
||||||
|
if ($rad_tog == 1) {
|
||||||
|
$img->flatten;
|
||||||
|
gimp_convert_indexed ($img, 0, MAKE_PALETTE, 256, 0, 0, "");
|
||||||
|
my $new = gimp_image_active_drawable ($img);
|
||||||
|
gimp_layer_add_alpha ($new);
|
||||||
|
gimp_by_color_select ($new, [255, 255, 255], 55, ADD, 0, 0, 0.0, 0);
|
||||||
|
gimp_edit_clear ($new);
|
||||||
|
gimp_selection_none ($img);
|
||||||
|
} else {
|
||||||
|
$img->flatten;
|
||||||
|
}
|
||||||
|
gimp_display_new ($img);
|
||||||
|
exit main;
|
||||||
|
}
|
||||||
|
$help=<<EOF.$help;
|
||||||
|
This script will produce a nice blended beveled logo from your alpha
|
||||||
|
layer, which must have a black text. You can choose the initial and finals colours
|
||||||
|
of the blend, the background, and how to tweak the bevel effect.
|
||||||
|
It uses a techinque quite similar to that in the Inner Bevel Logo.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
register "make_bevel_logos",
|
||||||
|
"A script to get blended beveled logos",
|
||||||
|
$help,
|
||||||
|
"Michele Gherlone <mikem\@enet.it>",
|
||||||
|
"(c) 2000 M. Gherlone",
|
||||||
|
"20000130",
|
||||||
|
N_"<Image>/Filters/Logulator/Blended II",
|
||||||
|
"*",
|
||||||
|
[
|
||||||
|
[PF_COLOUR , 'choose_bg_colour', "Choose the background colour", [255, 255, 255]],
|
||||||
|
[PF_COLOUR , 'blend_start', "Choose the 1st blend colour", [247, 231, 9]],
|
||||||
|
[PF_COLOUR , 'blend_stop', "Choose the 2nd blend colour", [255, 0, 0]],
|
||||||
|
[PF_SLIDER , 'strength_of_bevel', "Strength of bevel", 45.00, [0.00, 60.00, 0.50]],
|
||||||
|
[PF_SLIDER , 'depth_of_bevel', "Depth of bevel", 4, [0, 60, 1]],
|
||||||
|
[PF_RADIO , 'user_choice', "The user's choice", 0, [Background => 0, Transparent => 1]],
|
||||||
|
],
|
||||||
|
\&my_innerbevel;
|
||||||
|
exit main;
|
||||||
|
|
@ -42,7 +42,6 @@ register "map_to_gradient",
|
|||||||
$grad = $grad->xchg(0,1); # this form is later needed in index, so do it now
|
$grad = $grad->xchg(0,1); # this form is later needed in index, so do it now
|
||||||
|
|
||||||
my @bounds = $drawable->bounds;
|
my @bounds = $drawable->bounds;
|
||||||
my @off = $drawable->offsets;
|
|
||||||
{
|
{
|
||||||
my $src = new PixelRgn ($drawable,@bounds,0,0);
|
my $src = new PixelRgn ($drawable,@bounds,0,0);
|
||||||
my $dst = new PixelRgn ($drawable,@bounds,1,1);
|
my $dst = new PixelRgn ($drawable,@bounds,1,1);
|
||||||
|
39
plug-ins/perl/examples/roundsel
Executable file
39
plug-ins/perl/examples/roundsel
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
# Use gaussian blur and levels to round selection corners
|
||||||
|
|
||||||
|
use Gimp qw(:auto __ N_);
|
||||||
|
use Gimp::Fu;
|
||||||
|
use Gimp::Util;
|
||||||
|
|
||||||
|
# Gimp::set_trace(TRACE_ALL);
|
||||||
|
|
||||||
|
register "round_sel",
|
||||||
|
"Rounds a selection.",
|
||||||
|
"Rounds a selection.",
|
||||||
|
"Uri Zarfaty",
|
||||||
|
"Uri Zarfaty <udz20\@cam.ac.uk>",
|
||||||
|
"1999-03-25",
|
||||||
|
N_"<Image>/Select/Round...",
|
||||||
|
"*",
|
||||||
|
[
|
||||||
|
[PF_SPINNER, "roundness", "How much to round, in pixels", 16, [1,1000,1]],
|
||||||
|
], sub {
|
||||||
|
my($img,$drawable,$round) = @_;
|
||||||
|
|
||||||
|
eval { $img->undo_push_group_start };
|
||||||
|
|
||||||
|
my $channel = gimp_selection_save($img);
|
||||||
|
gimp_selection_none($img);
|
||||||
|
plug_in_gauss_iir($img, $channel, $round, 1, 1);
|
||||||
|
gimp_levels($channel, 0, 123, 133, 1.0, 0, 255);
|
||||||
|
gimp_selection_load($channel);
|
||||||
|
gimp_image_remove_channel($img, $channel);
|
||||||
|
# gimp_channel_delete($channel);
|
||||||
|
|
||||||
|
eval { $img->undo_push_group_end };
|
||||||
|
|
||||||
|
();
|
||||||
|
};
|
||||||
|
|
||||||
|
exit main;
|
||||||
|
|
@ -1,6 +1,12 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
# This one's all mine. Well, its GPL/Artisitic but I"m the author and creator.
|
#
|
||||||
|
# Note: Seth has transferred the maintainer `position' to me, so bother me
|
||||||
|
# instead of him now :-)
|
||||||
|
# - Steinar H. Gunderson <sgunderson@bigfoot.com>
|
||||||
|
|
||||||
|
|
||||||
|
# This one's all mine. Well, its GPL/Artisitic but I'm the author and creator.
|
||||||
# You need gimp 1.1 or better for this; too much has changed, and I don't think
|
# You need gimp 1.1 or better for this; too much has changed, and I don't think
|
||||||
# 1.0.x had a perspective PDB function anyway
|
# 1.0.x had a perspective PDB function anyway
|
||||||
|
|
||||||
@ -25,6 +31,11 @@
|
|||||||
# make sure you're logging to console since the Gtk messagebox will never show
|
# make sure you're logging to console since the Gtk messagebox will never show
|
||||||
# up due to a rapid segfault).
|
# up due to a rapid segfault).
|
||||||
#
|
#
|
||||||
|
# Just a comment on that: We fixed the bug, so height=0 no longer segfaults, but
|
||||||
|
# gives the error message it should. However, if GIMP segfaults, you should try
|
||||||
|
# logging to console to make sure you get all applicable error messages. This
|
||||||
|
# will make it _much_ easier to find the bug. - Steinar
|
||||||
|
#
|
||||||
# Revision History:
|
# Revision History:
|
||||||
# 1.0 - Initial (too early) release
|
# 1.0 - Initial (too early) release
|
||||||
# 1.1 - Second (still ugly) release: Made the perspective setting actually do
|
# 1.1 - Second (still ugly) release: Made the perspective setting actually do
|
||||||
@ -34,6 +45,7 @@
|
|||||||
# Filters->Animations-> menu to Xtns->Animations. I think its
|
# Filters->Animations-> menu to Xtns->Animations. I think its
|
||||||
# clearer whats going on this way. It also works w/ any 2 layers now.
|
# clearer whats going on this way. It also works w/ any 2 layers now.
|
||||||
# 1.5 - Some debugging by Steinar and myself to make it work again.
|
# 1.5 - Some debugging by Steinar and myself to make it work again.
|
||||||
|
# 1.6 - Moved some renaming into the main loop, more cleanups.
|
||||||
#
|
#
|
||||||
# TODO: Clean it up; allow for other effects (skewing, ripples?) while spinning;
|
# TODO: Clean it up; allow for other effects (skewing, ripples?) while spinning;
|
||||||
|
|
||||||
@ -49,15 +61,12 @@ use Gimp::Util;
|
|||||||
sub saw { # a sawtooth function on PI
|
sub saw { # a sawtooth function on PI
|
||||||
($val) = @_;
|
($val) = @_;
|
||||||
if ($val < 3.14159/2.0) {
|
if ($val < 3.14159/2.0) {
|
||||||
return ($val/3.14159) ;
|
return ($val/3.14159);
|
||||||
}
|
} elsif ($val < 3.14159) {
|
||||||
elsif ($val < 3.14159) {
|
|
||||||
return (-1+$val/3.14159);
|
return (-1+$val/3.14159);
|
||||||
}
|
} elsif ($val < 3.14159+3.14159/2.0) {
|
||||||
elsif ($val < 3.14159+3.14159/2.0) {
|
return ($val/3.14159);
|
||||||
return ($val/3.14159) ;
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
return (-1+$val/3.14159);
|
return (-1+$val/3.14159);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,17 +75,21 @@ sub spin_layer { # the function for actually spinning the layer
|
|||||||
my ($img, $spin, $dest, $numframes, $prp) = @_;
|
my ($img, $spin, $dest, $numframes, $prp) = @_;
|
||||||
|
|
||||||
my $floater, # The transformed image
|
my $floater, # The transformed image
|
||||||
$framelay; # The background color
|
$framelay, # The background color
|
||||||
|
$frameno; # The current frame
|
||||||
|
|
||||||
# Now lets spin it!
|
# Now let's spin it!
|
||||||
$stepsize = 3.14159/$numframes; # in radians
|
$stepsize = 3.14159/$numframes; # in radians
|
||||||
|
$frameno = 0;
|
||||||
for ($i=0; $i<=3.14159; $i+=$stepsize) {
|
for ($i=0; $i<=3.14159; $i+=$stepsize) {
|
||||||
Gimp->progress_update ($i/3.14159);
|
Gimp->progress_update ($i/3.14159);
|
||||||
|
|
||||||
# create a new layer for spinning
|
# create a new layer for spinning
|
||||||
$framelay = ($i < 3.14159/2.0) ? $spin->copy(1) : $dest->copy(1);
|
$framelay = ($i < 3.14159/2.0) ? $spin->copy(1) : $dest->copy(1);
|
||||||
$img->add_layer($framelay, 0);
|
$img->add_layer($framelay, 0);
|
||||||
$floater = $framelay->copy(1);
|
$floater = $framelay->copy(1);
|
||||||
$img->add_layer($floater, 0);
|
$img->add_layer($floater, 0);
|
||||||
|
|
||||||
# spin it a step
|
# spin it a step
|
||||||
$img->selection_all();
|
$img->selection_all();
|
||||||
@x = $img->selection_bounds();
|
@x = $img->selection_bounds();
|
||||||
@ -88,9 +101,9 @@ sub spin_layer { # the function for actually spinning the layer
|
|||||||
$y1 = int($x[2]+$spin->height *sin($i)/2);
|
$y1 = int($x[2]+$spin->height *sin($i)/2);
|
||||||
$y3 = int($x[4]-$spin->height *sin($i)/2);
|
$y3 = int($x[4]-$spin->height *sin($i)/2);
|
||||||
|
|
||||||
|
# height must be != 0
|
||||||
$y3++ if ($y1 == $y3);
|
$y3++ if ($y1 == $y3);
|
||||||
|
|
||||||
$floater->set_name("First-floater $i");
|
|
||||||
$floater = Gimp->perspective($floater, 1,
|
$floater = Gimp->perspective($floater, 1,
|
||||||
$x[1]+saw($i)*$prp*$framelay->width,$y1,
|
$x[1]+saw($i)*$prp*$framelay->width,$y1,
|
||||||
$x[3]-saw($i)*$prp*$framelay->width,$y1,
|
$x[3]-saw($i)*$prp*$framelay->width,$y1,
|
||||||
@ -98,11 +111,12 @@ sub spin_layer { # the function for actually spinning the layer
|
|||||||
$x[3]+saw($i)*$prp*$framelay->width,$y3);
|
$x[3]+saw($i)*$prp*$framelay->width,$y3);
|
||||||
$framelay->fill(1); # BG-IMAGE-FILL
|
$framelay->fill(1); # BG-IMAGE-FILL
|
||||||
|
|
||||||
|
# merge the two layers together before we continue
|
||||||
$img->set_visible($floater, $framelay);
|
$img->set_visible($floater, $framelay);
|
||||||
|
$framelay = $img->merge_visible_layers(0);
|
||||||
|
|
||||||
$floater->set_name("Floater $i");
|
$frameno++;
|
||||||
$framelay->set_name("Framelay $i");
|
$framelay->set_name("Spin Layer $frameno (50ms)");
|
||||||
$img->merge_visible_layers(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +125,8 @@ register "seth_spin",
|
|||||||
"Take one image. Spin it about the horizontal axis, and end up with another image. I made it for easy web buttons.",
|
"Take one image. Spin it about the horizontal axis, and end up with another image. I made it for easy web buttons.",
|
||||||
"Seth Burgess",
|
"Seth Burgess",
|
||||||
"Seth Burgess <sjburges\@gimp.org>",
|
"Seth Burgess <sjburges\@gimp.org>",
|
||||||
"1.5",
|
"1.6",
|
||||||
N_"<Toolbox>/Xtns/Animation/Seth Spin...",
|
N_"<Toolbox>/Xtns/Animation/Seth Spin",
|
||||||
"*",
|
"*",
|
||||||
[
|
[
|
||||||
[PF_DRAWABLE, "source", "What drawable to spin from?"],
|
[PF_DRAWABLE, "source", "What drawable to spin from?"],
|
||||||
@ -133,7 +147,7 @@ register "seth_spin",
|
|||||||
|
|
||||||
$perspective = $perspective/255.0; # PF_SLIDER doesn't work right for < 1
|
$perspective = $perspective/255.0; # PF_SLIDER doesn't work right for < 1
|
||||||
|
|
||||||
Gimp->progress_init("Seth Spin...",-1);
|
Gimp->progress_init(__"Seth Spin...",-1);
|
||||||
|
|
||||||
# Copy souce and destination to new image
|
# Copy souce and destination to new image
|
||||||
|
|
||||||
@ -161,7 +175,7 @@ register "seth_spin",
|
|||||||
# need an even number of frames for spinback
|
# need an even number of frames for spinback
|
||||||
if ($frames%2 && $spinback) {
|
if ($frames%2 && $spinback) {
|
||||||
$frames++;
|
$frames++;
|
||||||
gimp_message("An even number of frames is needed for spin back.\nAdjusted frames up to $frames");
|
Gimp->message(__"An even number of frames is needed for spin back.\nAdjusted frames up to $frames");
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_layer($img, $spinlayer, $destlayer, $spinback ? $frames/2 : $frames, $perspective);
|
spin_layer($img, $spinlayer, $destlayer, $spinback ? $frames/2 : $frames, $perspective);
|
||||||
@ -180,16 +194,10 @@ register "seth_spin",
|
|||||||
@all_layers = $img->get_layers;
|
@all_layers = $img->get_layers;
|
||||||
$img->set_visible(@all_layers);
|
$img->set_visible(@all_layers);
|
||||||
|
|
||||||
for ($i=1; $i<=$frames ; $i++) {
|
|
||||||
$all_layers[$i-1]->set_name("Spin Layer $i (50ms)");
|
|
||||||
}
|
|
||||||
$all_layers[$frames-1]->set_name("Spin Layer SRC (250ms)");
|
|
||||||
|
|
||||||
if ($spinback) {
|
if ($spinback) {
|
||||||
$all_layers[$frames/2-1]->set_name("Spin Layer DEST (250ms)");
|
$all_layers[$frames/2-1]->set_name(__"Spin Layer DEST (250ms)");
|
||||||
}
|
}
|
||||||
else { $all_layers[0]->set_name("Spin Layer DEST (250ms)")}
|
$all_layers[$frames-1]->set_name(__"Spin Layer SRC (250ms)");
|
||||||
|
|
||||||
|
|
||||||
# indexed conversion wants a display for some reason
|
# indexed conversion wants a display for some reason
|
||||||
if ($indexed) {
|
if ($indexed) {
|
||||||
@ -201,3 +209,4 @@ register "seth_spin",
|
|||||||
};
|
};
|
||||||
|
|
||||||
exit main;
|
exit main;
|
||||||
|
|
||||||
|
91
plug-ins/perl/examples/translogo
Executable file
91
plug-ins/perl/examples/translogo
Executable file
@ -0,0 +1,91 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use Gimp qw(:auto __ N_);
|
||||||
|
use Gimp::Fu;
|
||||||
|
use Gimp::Util;
|
||||||
|
#Gimp::set_trace(TRACE_CALL);
|
||||||
|
|
||||||
|
sub my_code {
|
||||||
|
my ($image, $drawable, $rad_tog, $pattern, $txt_col) = @_;
|
||||||
|
$drawable->has_alpha or die __"You can't run this script without an ALPHA CHANNEL!!";
|
||||||
|
my $test = 0;
|
||||||
|
$test = $drawable->type_with_alpha;
|
||||||
|
if ($test == 5) {
|
||||||
|
die __"You can't run this script with an INDEXED image!!";
|
||||||
|
} elsif ($test == 3) {
|
||||||
|
gimp_convert_rgb ($image);
|
||||||
|
}
|
||||||
|
my $img = gimp_image_new (100, 100, RGB_IMAGE);
|
||||||
|
$drawable->image->selection_all;
|
||||||
|
$drawable->edit_copy;
|
||||||
|
gimp_selection_none ($image);
|
||||||
|
my $layer;
|
||||||
|
$layer=$img->layer_new($drawable->width,$drawable->height,$image->layertype(1), __"Text", 100, NORMAL_MODE);
|
||||||
|
$layer->drawable_fill(TRANS_IMAGE_FILL);
|
||||||
|
$img->add_layer($layer,0);
|
||||||
|
$layer->edit_paste(0)->floating_sel_anchor;
|
||||||
|
$img->resize($drawable->width,$drawable->height, 0, 0);
|
||||||
|
gimp_selection_layer_alpha ($layer);
|
||||||
|
gimp_selection_invert ($img);
|
||||||
|
gimp_palette_set_background ([255, 255, 255]);
|
||||||
|
gimp_edit_fill ($layer);
|
||||||
|
gimp_selection_none ($img);
|
||||||
|
gimp_invert ($layer);
|
||||||
|
plug_in_gauss_rle ($layer, 2.0, 1, 1);
|
||||||
|
my $bump_lay;
|
||||||
|
$bump_lay = $img->layer_new($img->width,$img->height, RGBA_IMAGE, __"Bumpmap", 100, NORMAL_MODE);
|
||||||
|
$bump_lay->drawable_fill(BG_IMAGE_FILL);
|
||||||
|
$img->add_layer($bump_lay,0);
|
||||||
|
if ($rad_tog == 1) {
|
||||||
|
gimp_patterns_set_pattern ($pattern);
|
||||||
|
gimp_bucket_fill ($bump_lay, PATTERN_BUCKET_FILL, NORMAL_MODE, 100, 0, 0, 0, 0);
|
||||||
|
} else {
|
||||||
|
gimp_palette_set_background ($txt_col);
|
||||||
|
gimp_edit_fill ($bump_lay);
|
||||||
|
}
|
||||||
|
plug_in_bump_map ($img, $bump_lay, $layer, 110.0, 45.0, 4, 0, 0, 0, 0, 1, 0, 0);
|
||||||
|
$pattern_mask = gimp_layer_create_mask ($bump_lay, ALPHA_MASK);
|
||||||
|
$img->add_layer_mask($bump_lay,$pattern_mask);
|
||||||
|
gimp_selection_all ($img);
|
||||||
|
gimp_edit_copy ($layer);
|
||||||
|
$float = gimp_edit_paste ($pattern_mask, 0);
|
||||||
|
gimp_floating_sel_anchor ($float);
|
||||||
|
gimp_levels ($pattern_mask, 0, 0, 77, 0.91, 0, 255);
|
||||||
|
gimp_image_remove_layer_mask ($img, $bump_lay, APPLY);
|
||||||
|
gimp_invert ($layer);
|
||||||
|
gimp_image_flatten ($img);
|
||||||
|
gimp_convert_indexed ($img, 0, MAKE_PALETTE, 256, 0, 0, "");
|
||||||
|
my $new = gimp_image_active_drawable ($img);
|
||||||
|
gimp_layer_add_alpha ($new);
|
||||||
|
gimp_by_color_select ($new, [255, 255, 255], 55, ADD, 0, 0, 0.0, 0);
|
||||||
|
gimp_edit_clear ($new);
|
||||||
|
gimp_selection_none ($img);
|
||||||
|
return ($img);
|
||||||
|
}
|
||||||
|
$help=<<EOF.$help;
|
||||||
|
This script aims to produce a transparent logo in an indexed image
|
||||||
|
which is ready to be saved in .gif format. The quality of the
|
||||||
|
logo is equal to that of flattened .jpg images. If you need a transparent
|
||||||
|
image containing a logo for your web page, just apply this script over
|
||||||
|
a drawable with an alpha channel in RGB or GRAY mode. You'll get a transparent
|
||||||
|
image in indexed mode. You can choose between colour and pattern fill
|
||||||
|
of your text. Enjoy it!
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
register "make_trans_logos",
|
||||||
|
"A script to get transparent beveled logos",
|
||||||
|
"$help",
|
||||||
|
"Michele Gherlone <mikem\@enet.it>",
|
||||||
|
"(c) 2000 M. Gherlone",
|
||||||
|
"20000123",
|
||||||
|
N_"<Image>/Filters/Logulator/Transparent Logo",
|
||||||
|
"*",
|
||||||
|
[
|
||||||
|
[PF_RADIO , 'use_a_colour_or_a_pattern_for_text', "The user's choice", 0, [Colour => 0, Pattern => 1]],
|
||||||
|
[PF_PATTERN , 'choose_a_pattern', "Choose the text Pattern", "Wood #1"],
|
||||||
|
[PF_COLOUR , 'choose_a_colour', "Choose the text Color", [69, 88, 211]],
|
||||||
|
],
|
||||||
|
\&my_code;
|
||||||
|
exit main;
|
||||||
|
|
327
plug-ins/perl/examples/visual
Executable file
327
plug-ins/perl/examples/visual
Executable file
@ -0,0 +1,327 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# this is just a very basic hack...
|
||||||
|
|
||||||
|
use Gimp::Feature qw(perl-5.005 gtk-1.2);
|
||||||
|
use Gimp (':consts','__','N_');
|
||||||
|
use Gimp::Fu;
|
||||||
|
use Gnome;
|
||||||
|
#use Gtk 0.61231;
|
||||||
|
use Gtk;
|
||||||
|
use Gtk::Gdk;
|
||||||
|
use Gimp::UI (); # for the logo
|
||||||
|
|
||||||
|
$VERSION = 0.0;
|
||||||
|
|
||||||
|
$tabw = 30;
|
||||||
|
$tabh = 12;
|
||||||
|
|
||||||
|
#Gimp::set_trace(TRACE_ALL);
|
||||||
|
|
||||||
|
@stringtargets = (
|
||||||
|
{ target => "STRING", flags => 0, info => TARGET_STRING },
|
||||||
|
{ target => "text/plain", flags => 0, info => TARGET_STRING },
|
||||||
|
);
|
||||||
|
|
||||||
|
@funcframetarget = (
|
||||||
|
{ target => "application/funcframe", flags => 0, info => TARGET_STRING },
|
||||||
|
);
|
||||||
|
|
||||||
|
%typetargets = (
|
||||||
|
&PF_IMAGE => [{ target => "application/image-link", flags => 0, info => 0 }],
|
||||||
|
&PF_INT32 => [{ target => "application/value-link", flags => 0, info => 0 }],
|
||||||
|
&PF_STRING => [{ target => "application/value-link", flags => 0, info => 0 }],
|
||||||
|
);
|
||||||
|
|
||||||
|
my $ex; # average font width for default font
|
||||||
|
my $ey; # average font height for default font
|
||||||
|
|
||||||
|
my $window; # the main window
|
||||||
|
my $canvas; # the gtklayout widget
|
||||||
|
my $funclist;
|
||||||
|
|
||||||
|
my %type2str = (
|
||||||
|
&PARAM_BOUNDARY => 'BOUNDARY',
|
||||||
|
&PARAM_CHANNEL => 'CHANNEL',
|
||||||
|
&PARAM_COLOR => 'COLOR',
|
||||||
|
&PARAM_DISPLAY => 'DISPLAY',
|
||||||
|
&PARAM_DRAWABLE => 'DRAWABLE',
|
||||||
|
&PARAM_FLOAT => 'FLOAT',
|
||||||
|
&PARAM_IMAGE => 'IMAGE',
|
||||||
|
&PARAM_INT32 => 'INT32',
|
||||||
|
&PARAM_FLOATARRAY => 'FLOATARRAY',
|
||||||
|
&PARAM_INT16 => 'INT16',
|
||||||
|
&PARAM_PARASITE => 'PARASITE',
|
||||||
|
&PARAM_STRING => 'STRING',
|
||||||
|
&PARAM_PATH => 'PATH',
|
||||||
|
&PARAM_INT16ARRAY => 'INT16ARRAY',
|
||||||
|
&PARAM_INT8 => 'INT8',
|
||||||
|
&PARAM_INT8ARRAY => 'INT8ARRAY',
|
||||||
|
&PARAM_LAYER => 'LAYER',
|
||||||
|
&PARAM_REGION => 'REGION',
|
||||||
|
&PARAM_STRINGARRAY => 'STRINGARRAY',
|
||||||
|
&PARAM_SELECTION => 'SELECTION',
|
||||||
|
&PARAM_STATUS => 'STATUS',
|
||||||
|
&PARAM_INT32ARRAY => 'INT32ARRAY',
|
||||||
|
);
|
||||||
|
|
||||||
|
sub add_func($$;) {
|
||||||
|
my($group,$func)=@_;
|
||||||
|
$funclist->append($func);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub create_main {
|
||||||
|
my $t = new Gtk::Tooltips;
|
||||||
|
my $w = new Gtk::Window;
|
||||||
|
|
||||||
|
my $v = new Gtk::VBox 0,5;
|
||||||
|
my $h = new Gtk::HBox 0,5;
|
||||||
|
|
||||||
|
$canvas = new ProgShell;
|
||||||
|
|
||||||
|
$funclist = new Gtk::CList 1;
|
||||||
|
$funclist->set_usize(200,0);
|
||||||
|
$funclist->drag_source_set ([-button1_mask, -button3_mask], [-copy, -move], @::stringtargets);
|
||||||
|
|
||||||
|
$funclist->signal_connect ("drag_data_get", sub {
|
||||||
|
my ($widget, $context, $data, $info, $time) = @_;
|
||||||
|
$data->set ($data->target, 8, $widget->get_text($widget->selection,0));
|
||||||
|
});
|
||||||
|
|
||||||
|
$funclist->set_selection_mode(-extended);
|
||||||
|
|
||||||
|
$w->add ($h);
|
||||||
|
$h->add ($v);
|
||||||
|
|
||||||
|
my $sc = new Gtk::ScrolledWindow;
|
||||||
|
$sc->add ($funclist);
|
||||||
|
$v->add ($sc);
|
||||||
|
$h->add ($canvas);
|
||||||
|
|
||||||
|
for (sort Gimp->procedural_db_query("","","","","","","")) {
|
||||||
|
$group = "gimp";
|
||||||
|
$group = "image" if /^gimp_image_/;
|
||||||
|
$group = "layer" if /^gimp_layer_/;
|
||||||
|
$group = "channel" if /^gimp_channel_/;
|
||||||
|
$group = "drawable" if /^gimp_drawable_/;
|
||||||
|
add_func $group, $_;
|
||||||
|
$gimpfunc{$_} = 1;
|
||||||
|
}
|
||||||
|
$window = $w;
|
||||||
|
$w->realize;
|
||||||
|
$ex = $w->style->font->string_width ('Mn')*0.5;
|
||||||
|
$ey = $w->style->font->string_width ('My');
|
||||||
|
|
||||||
|
$w->set_title(__"Visual Scriptor");
|
||||||
|
$w->signal_connect("destroy",sub {main_quit Gtk});
|
||||||
|
|
||||||
|
show_all $w;
|
||||||
|
}
|
||||||
|
|
||||||
|
register "extension_visual_scriptor",
|
||||||
|
"Visual Gimp Scripting Environment",
|
||||||
|
"=pod(DESCRIPTION)",
|
||||||
|
"Marc Lehmann",
|
||||||
|
"Marc Lehmann",
|
||||||
|
$VERSION,
|
||||||
|
N_"<Toolbox>/Xtns/Visual Scriptor",
|
||||||
|
"",
|
||||||
|
[],
|
||||||
|
sub {
|
||||||
|
|
||||||
|
Gimp::gtk_init;
|
||||||
|
|
||||||
|
create_main;
|
||||||
|
main Gtk;
|
||||||
|
|
||||||
|
();
|
||||||
|
};
|
||||||
|
|
||||||
|
# the basic function/node-type
|
||||||
|
package Func;
|
||||||
|
|
||||||
|
use Gimp;
|
||||||
|
|
||||||
|
sub new_from_gimp_func {
|
||||||
|
my $name = shift;
|
||||||
|
my $self = {};
|
||||||
|
my ($narg, $nval);
|
||||||
|
(
|
||||||
|
$self->{blurb},
|
||||||
|
$self->{help},
|
||||||
|
$self->{author},
|
||||||
|
$self->{copyright},
|
||||||
|
$self->{date},
|
||||||
|
$self->{proc_type},
|
||||||
|
$narg,
|
||||||
|
$nval,
|
||||||
|
) = Gimp->procedural_db_proc_info($name);
|
||||||
|
$self->{in } = [map Gimp->procedural_db_proc_arg($name,$_), 0..$narg-1];
|
||||||
|
$self->{out} = [map Gimp->procedural_db_proc_val($name,$_), 0..$nval-1];
|
||||||
|
$self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new_from_name {
|
||||||
|
my $class = shift;
|
||||||
|
my $name = shift;
|
||||||
|
$new{$name} = new_from_gimp_func($name) if !$new{$name} && $::gimpfunc{$name};
|
||||||
|
$new{$name} ?
|
||||||
|
bless {
|
||||||
|
name => $name,
|
||||||
|
%{$new{$name}},
|
||||||
|
}, $class
|
||||||
|
:
|
||||||
|
();
|
||||||
|
}
|
||||||
|
|
||||||
|
# a connection tab
|
||||||
|
package Tab;
|
||||||
|
|
||||||
|
use Gimp::basewidget Gtk::Button;
|
||||||
|
|
||||||
|
sub OPEN (){1}
|
||||||
|
sub CONN (){2}
|
||||||
|
sub BOUND(){3}
|
||||||
|
|
||||||
|
sub GTK_CLASS_INIT {
|
||||||
|
my $class = shift;
|
||||||
|
add_arg_type $class "state", "gint", 3, 1;
|
||||||
|
add_arg_type $class "type" , "gint", 3, 2;
|
||||||
|
add_arg_type $class "dir" , "gint", 3, 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub GTK_OBJECT_SET_ARG {
|
||||||
|
my($self,$arg,$id,$value) = @_;
|
||||||
|
print "SA $self,$arg,$id,$value\n";
|
||||||
|
if ($id == 1) {
|
||||||
|
$self->{state} = $value;
|
||||||
|
} elsif ($id == 2) {
|
||||||
|
$self->{type} = $value;
|
||||||
|
$self->drag_dest_set('all', ['copy'], $::typetargets{$value});
|
||||||
|
$self->drag_source_set ([-button1_mask], [-copy], $::typetargets{$value});
|
||||||
|
} elsif ($id == 3) {
|
||||||
|
$self->{dir} = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub GTK_OBJECT_GET_ARG {
|
||||||
|
my($self,$arg,$id) = @_;
|
||||||
|
if ($id == 1) {
|
||||||
|
$self->{state};
|
||||||
|
} elsif ($id == 2) {
|
||||||
|
$self->{type};
|
||||||
|
} elsif ($id == 3) {
|
||||||
|
$self->{dir};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub GTK_OBJECT_INIT {
|
||||||
|
shift unless ref $self; # care for "old" Gtk modules
|
||||||
|
$self->set_usize($::tabw, $::tabh);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my $class = shift;
|
||||||
|
$class->SUPER::new(@_);
|
||||||
|
#$class->SUPER::new(shadow => out, @_);
|
||||||
|
}
|
||||||
|
|
||||||
|
# a single function or "block", can only exist
|
||||||
|
# within a progshell
|
||||||
|
package FuncFrame;
|
||||||
|
|
||||||
|
use Gimp::basewidget Gtk::VBox;
|
||||||
|
|
||||||
|
sub GTK_OBJECT_INIT {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
signal_connect $self draw => sub {
|
||||||
|
print "re-drawing @_\n\n";
|
||||||
|
};
|
||||||
|
signal_connect $self realize => sub {
|
||||||
|
print "realize @_\n\n";
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->add ($self->{inbox } = new Gtk::HBox 1, $::tabw*0.6);
|
||||||
|
$self->add ($self->{button} = new Gtk::Button);
|
||||||
|
$self->add ($self->{outbox} = new Gtk::HBox 1, $::tabw*0.6);
|
||||||
|
|
||||||
|
$self->{button}->add(
|
||||||
|
$self->{label} = new Gtk::Label
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_func {
|
||||||
|
my($self,$func)=@_;
|
||||||
|
$self->{func} = $func;
|
||||||
|
$self->{inbox }->remove($_) for $self->{inbox }->children;
|
||||||
|
$self->{outbox}->remove($_) for $self->{outbox}->children;
|
||||||
|
my $w = 1;
|
||||||
|
my $in = $self->{func}->{in };
|
||||||
|
my $out = $self->{func}->{out};
|
||||||
|
for (@$in) {
|
||||||
|
$self->{inbox }->add (new Tab type => $_->[0], dir => 0);
|
||||||
|
}
|
||||||
|
for (@$out) {
|
||||||
|
$self->{outbox}->add (new Tab type => $_->[0], dir => 1);
|
||||||
|
}
|
||||||
|
$self->{label}->set($func->{name});
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new_from_name {
|
||||||
|
my $class = shift;
|
||||||
|
my $func = Func->new_from_name (shift);
|
||||||
|
if ($func) {
|
||||||
|
my $self = $class->new(@_);
|
||||||
|
$self->set_func($func);
|
||||||
|
$self;
|
||||||
|
} else {
|
||||||
|
();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# the shell canvas
|
||||||
|
package ProgShell;
|
||||||
|
|
||||||
|
use Gimp::basewidget Gtk::Layout;
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
print "new for progshell ",ProgShell->_object_type,"\n";
|
||||||
|
Gtk::Object::new("ProgShell");
|
||||||
|
}
|
||||||
|
|
||||||
|
sub GTK_CLASS_INIT { }
|
||||||
|
sub GTK_OBJECT_INIT {
|
||||||
|
my $canvas = shift;
|
||||||
|
print "X @_\n";
|
||||||
|
|
||||||
|
$canvas->set_usize (600, 800);
|
||||||
|
$canvas->set_hadjustment(0);
|
||||||
|
$canvas->set_vadjustment(0);
|
||||||
|
$canvas->set_app_paintable(1);
|
||||||
|
|
||||||
|
$canvas->signal_connect (draw => sub {
|
||||||
|
print "DRAW @_ : ",@{$_[1]},"\n";
|
||||||
|
});
|
||||||
|
|
||||||
|
$canvas->signal_connect (drag_data_received => sub {
|
||||||
|
my ($widget, $context, $x, $y, $data, $info, $time) = @_;
|
||||||
|
my $type = Gtk::Gdk::Atom->name($data->type);
|
||||||
|
if (($type eq "STRING" || $type eq "text/plain") && $data->format == 8) {
|
||||||
|
my $widget = FuncFrame->new_from_name($data->data);
|
||||||
|
$widget->show_all;
|
||||||
|
$canvas ->put($widget,$x,$y);
|
||||||
|
#printf ("Received \"%s\" in trashcan at $x, $y\n", $data->data);
|
||||||
|
} else {
|
||||||
|
$context->finish (0, 0, $time);
|
||||||
|
}
|
||||||
|
$context->finish (1, 0, $time);
|
||||||
|
});
|
||||||
|
|
||||||
|
$canvas->drag_dest_set('all', ['copy'], @::stringtargets);
|
||||||
|
}
|
||||||
|
|
||||||
|
package main;
|
||||||
|
|
||||||
|
exit main;
|
||||||
|
|
Reference in New Issue
Block a user