diff --git a/plug-ins/perl/Changes b/plug-ins/perl/Changes index 2231445c7c..83bd858e5c 100644 --- a/plug-ins/perl/Changes +++ b/plug-ins/perl/Changes @@ -5,6 +5,10 @@ Revision history for Gimp-Perl extension. - updated perlotine. - fixed logulator (bugs are actually in the script-fu parts). - moved gimp_drawable_bounds from Gimp::Util to Gimp. + - applied patch to logulator by . + - added examples/giflogo. + - do not install examples/gap-vcr. + - added new sethspin, with slight changes. 1.19 Thu Jan 6 00:21:58 CET 2000 - used N_ to mark all the menu paths, since gimp now tries to diff --git a/plug-ins/perl/MANIFEST b/plug-ins/perl/MANIFEST index cf42673d22..45fa85e0a9 100644 --- a/plug-ins/perl/MANIFEST +++ b/plug-ins/perl/MANIFEST @@ -122,6 +122,8 @@ examples/bricks examples/dataurl examples/colorhtml examples/gap-vcr +examples/giflogo +examples/sethspin pxgettext po/ChangeLog po/gimp-perl.pot diff --git a/plug-ins/perl/Makefile.PL b/plug-ins/perl/Makefile.PL index 253897c4a0..c4d230bacc 100644 --- a/plug-ins/perl/Makefile.PL +++ b/plug-ins/perl/Makefile.PL @@ -29,13 +29,13 @@ if ($ARGV[0] ne "--writemakefile") { @pins = qw(windify prep4gif webify PDB tex-to-float ditherize feedback xachlego xachshadow parasite-editor roundsel - scratches blowinout terral_text xachvision perlcc - animate_cells image_tile yinyang stamps font_table + scratches blowinout terral_text xachvision perlcc giflogo + animate_cells image_tile yinyang stamps font_table sethspin perlotine randomblends innerbevel fit-text guidegrid roundrectsel repdup centerguide stampify goldenmean triangle mirrorsplit layerfuncs randomart1 glowing_steel frame_reshuffle frame_filter logulator miff gimpmagick guide_remove guides_to_selection burst - fire povray avi layerfuncs bricks dataurl colorhtml gap-vcr + fire povray avi layerfuncs bricks dataurl colorhtml ); @pdl_pins = qw( diff --git a/plug-ins/perl/UI/UI.pm b/plug-ins/perl/UI/UI.pm index e7b913eb2b..5c2f2ec43e 100644 --- a/plug-ins/perl/UI/UI.pm +++ b/plug-ins/perl/UI/UI.pm @@ -600,7 +600,9 @@ sub interact($$$$@) { } $value=$default unless defined $value; + # massage label text a small bit (works only for english) $label="$name: "; + $label =~ y/_/ /; $label =~ s/^(\w)/\U$1/g; if($type == PF_INT8 # perl just maps || $type == PF_INT16 # all this crap diff --git a/plug-ins/perl/examples/giflogo b/plug-ins/perl/examples/giflogo new file mode 100755 index 0000000000..fa2fa44302 --- /dev/null +++ b/plug-ins/perl/examples/giflogo @@ -0,0 +1,79 @@ +#!/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 "Must have alpha"; + 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); +} + +register "make_trans_logos", + "A script to get .GIF beveled logos", + "Very handy to get perfectly looking ". + "transparent logos for web purposes ". + "You must use an initial drawable ". + "with an alpha channel, or the script will stop ". + "Try it out!!", + "Michele Gherlone ", + "(c) 2000 M. Gherlone", + "20000123", + N_"/Filters/Render/GIFLogo", + "*", + [ + [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; + diff --git a/plug-ins/perl/examples/logulator b/plug-ins/perl/examples/logulator index e53f5a6b27..9e521b5236 100755 --- a/plug-ins/perl/examples/logulator +++ b/plug-ins/perl/examples/logulator @@ -103,7 +103,7 @@ sub gimp_text_fontname { $newlay; } -# script-fu convinience fucntions +# script-fu convenience functions sub cdr { my(@x)=@{$_[0]}; @@ -1503,16 +1503,21 @@ sub script_fu_glossy_logo { gimp_selection_none ($img); }; } - if ($shadow_toggle) { - do { - gimp_selection_layer_alpha ($text_layer); - $dont_drop_me = script_fu_drop_shadow(RUN_NONINTERACTIVE, $img, $text_layer, $s_offset_x, $s_offset_y, 15, [0, 0, 0], 80, 1); - $width = gimp_image_width ($img); - $height = gimp_image_height ($img); - gimp_selection_none ($img); - }; + if ($shadow_toggle == 1) { + do { + $drop_sh_layer = gimp_layer_copy ($text_layer, 1); + gimp_layer_set_mode ($drop_sh_layer, NORMAL_MODE); + gimp_image_add_layer ($img, $drop_sh_layer, 2); + gimp_selection_layer_alpha ($drop_sh_layer); + gimp_palette_set_background ([0, 0, 0]); + gimp_edit_fill ($drop_sh_layer); + gimp_selection_none ($img); + plug_in_gauss_rle ($drop_sh_layer, 15, 1, 1); + gimp_layer_set_offsets ($drop_sh_layer, $s_offset_x, $s_offset_y); + gimp_layer_set_opacity ($drop_sh_layer, 80); + }; } - if ($flatten_toggle) { + if ($flatten_toggle == 1) { do { $final = gimp_image_flatten ($img); }; @@ -1547,11 +1552,10 @@ register "perl_fu_glossy_logo", [PF_PATTERN, 'pattern_outline', "Pattern (outline)", "Electric Blue"], [PF_TOGGLE, 'use_pattern_overlay',"Use pattern overlay", 0], [PF_PATTERN, 'pattern_overlay', "Pattern (overlay)", "Parque #1"], - [PF_TOGGLE, 'default_bumpmap_settings',"Default bump-map settings", 1], - [PF_TOGGLE, 'shadow', "Shadow?", 1], - [PF_VALUE, 'shadow_x_offset', "Shadow X offset", "8"], - [PF_VALUE, 'shadow_y_offset', "Shadow Y offset", "8"], - [PF_TOGGLE, 'flatten_image', "Flatten image?", 0], + [PF_TOGGLE, 'shadow_toggle', "Shadow?", 1], + [PF_VALUE, 's_offset_x', "Shadow X offset", "8"], + [PF_VALUE, 's_offset_y', "Shadow Y offset", "8"], + [PF_TOGGLE, 'flatten_toggle', "Flatten image?", 0], ], \&script_fu_glossy_logo; sub script_fu_glowing_logo { @@ -1866,6 +1870,11 @@ sub script_fu_neon_logo { my $shadow_offx = $size / 10; my $shadow_offy = $size / 10; my $tube_layer = gimp_text_fontname ($img, -1, 0, 0, $text, $border, 1, $size, PIXELS, $font); + #get the actual height of the text the user has in the drawable + gimp_selection_layer_alpha ($tube_layer); + $float_layer = gimp_selection_float ($tube_layer, 0, 0); + $float_height = $float_layer->height; + gimp_floating_sel_anchor ($float_layer); my $width = gimp_drawable_width ($tube_layer); my $height = gimp_drawable_height ($tube_layer); my $glow_layer = gimp_layer_new ($img, $width, $height, RGBA_IMAGE, "Neon Glow", 100, NORMAL_MODE); @@ -1899,7 +1908,9 @@ sub script_fu_neon_logo { gimp_selection_shrink ($img, $shrink); gimp_palette_set_background ([0, 0, 0]); gimp_edit_fill ($selection); - gimp_edit_fill ($tube_layer); + if ($float_height >= 100) { + gimp_edit_fill ($tube_layer); #this way the user has to choose a REAL big font + } #in order to get the original effect!! gimp_selection_none ($img); if (not ($feather1 == 0)) { plug_in_gauss_rle ($img, $tube_layer, $feather1, 1, 1); @@ -1913,7 +1924,11 @@ sub script_fu_neon_logo { gimp_hue_saturation ($tube_layer, 0, $tube_hue, -15, 70); gimp_selection_load ($selection); gimp_selection_feather ($img, $inc_shrink); - gimp_selection_shrink ($img, $inc_shrink); + if ($size < 100) { + gimp_selection_shrink ($img, $inc_shrink * 2); #this is to avoid the strange error if + } else { #gimp_selection_shrink is called with 0 + gimp_selection_shrink ($img, $inc_shrink); + } gimp_curves_spline ($tube_layer, 0, 6, neon_spline1 ()); gimp_selection_load ($selection); gimp_selection_feather ($img, $inc_shrink); @@ -2752,7 +2767,7 @@ sub script_fu_title_header { gimp_palette_set_background ([0, 0, 0]); gimp_edit_fill ($bg_layer); gimp_ellipse_select ($img, 0, 0, $text_height, $text_height, REPLACE, 1, 0, 0); - gimp_palette_set_background (gimp_color_picker ($text_layer, $text_layers_offset, 0, 1, 0, 2, 0)); + gimp_palette_set_background (gimp_color_picker ($text_layer, $text_layers_offset, 0, 1, 0, 6, 0)); gimp_edit_fill ($bg_layer); gimp_rect_select ($img, ($img_width - $fade_width), 0, $fade_width, $text_height, REPLACE, 0, 0); gimp_palette_set_foreground (gimp_palette_get_background ()); diff --git a/plug-ins/perl/examples/sethspin b/plug-ins/perl/examples/sethspin new file mode 100755 index 0000000000..9fffd951b6 --- /dev/null +++ b/plug-ins/perl/examples/sethspin @@ -0,0 +1,203 @@ +#!/usr/bin/perl + +# 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 +# 1.0.x had a perspective PDB function anyway + +# Here's the working theory on this: +# There's a function called spinlayer which will spin from a spinlayer to a +# destlayer. It won't touch those 2 layers at all, and will leave its results +# on the top of the layer stack. +# +# If the user wants to spin back, it will take 1/2 the layers otherwise required +# per call to the spin_layer, so that the number of total layers comes out the +# same. +# +# The main function makes a new image, copies the source and destination onto it +# with appropriate offsets, and passes this image with the bottom 2 layers to +# spin_layer. At the end, remove the original 2 layers, since they won't be +# needed, and add in some Layer comments for timing your gif. +# +################################################################################ +# Many thanks to Steinar and Marc, for expressing an intrest in the script that +# kept me going, and to Steinar in particular for helping me track down why the +# script was crashing gimp (hint - don't make layers of height=0, and if you do +# make sure you're logging to console since the Gtk messagebox will never show +# up due to a rapid segfault). +# +# Revision History: +# 1.0 - Initial (too early) release +# 1.1 - Second (still ugly) release: Made the perspective setting actually do +# something +# 1.2 - Used some of the convienence functions, and made things a little eaiser +# from the user's standpoint too. Also moved it from the +# Filters->Animations-> menu to Xtns->Animations. I think its +# 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. +# +# TODO: Clean it up; allow for other effects (skewing, ripples?) while spinning; + +# Seth Burgess +# + +use Gimp; # No qw(:auto) - Trying to use all OO-styling +use Gimp::Fu; +use Gimp::Util; + +# 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) = @_; + + my $floater, # The transformed image + $framelay; # The background color + + # 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); + $floater = $framelay->copy(1); + $img->add_layer($floater, 0); + # spin it a step + $img->selection_all(); + @x = $img->selection_bounds(); + $img->selection_none(); + + # x[1],x[2] x[3],x[2] + # x[1],x[4] x[3],x[4] + my($y1, $y3); + $y1 = int($x[2]+$spin->height *sin($i)/2); + $y3 = int($x[4]-$spin->height *sin($i)/2); + + $y3++ if ($y1 == $y3); + + $floater->set_name("First-floater $i"); + $floater = Gimp->perspective($floater, 1, + $x[1]+saw($i)*$prp*$framelay->width,$y1, + $x[3]-saw($i)*$prp*$framelay->width,$y1, + $x[1]-saw($i)*$prp*$framelay->width,$y3, + $x[3]+saw($i)*$prp*$framelay->width,$y3); + $framelay->fill(1); # BG-IMAGE-FILL + + $img->set_visible($floater, $framelay); + + $floater->set_name("Floater $i"); + $framelay->set_name("Framelay $i"); + $img->merge_visible_layers(0); + } +} + +register "seth_spin", + "Seth Spin", + "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 ", + "1.5", + N_"/Xtns/Animation/Seth Spin...", + "*", + [ + [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?" , 1], + [PF_TOGGLE, "convert_indexed", "Convert to indexed?", 1], + ], + [], + ['gimp-1.1'], + sub { + my($src,$dest,$frames,$color,$perspective,$spinback,$indexed) = @_; + + $oldbackground = Gimp->palette_get_background(); + Gimp->palette_set_background($color); + + $perspective = $perspective/255.0; # PF_SLIDER doesn't work right for < 1 + + Gimp->progress_init("Seth Spin...",-1); + + # Copy souce and destination to new image + + $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); # have to have a layer before displaying + $img->display_new; + + $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; # remove temporary layer. + + # set the layer size to be the full layer for each copied layer + $spinlayer->resize($maxwide, $maxhigh, $spinlayer->offsets); + $destlayer->resize($maxwide, $maxhigh, $destlayer->offsets); + + # 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, $perspective); + + # go back from destination to spinlayer if spinning back + if ($spinback) { + @layerlist = $img->get_layers(); + spin_layer($img, $destlayer, $spinlayer, $frames/2, $perspective); + } + + # remove the original 2 pasted layers + $img->remove_layer($destlayer); + $img->remove_layer($spinlayer); + + # unhide and name layers (Give timings) + @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,MAKE_PALETTE,255,0,1,"buffy" ); + } + + Gimp->palette_set_background($oldbackground); + return(); +}; + +exit main;