From 34e395dff9fc426c7ea948df6498be4e4492dae5 Mon Sep 17 00:00:00 2001 From: Marc Lehmann Date: Tue, 31 Jul 2001 23:46:09 +0000 Subject: [PATCH] *** empty log message *** --- plug-ins/perl/Gimp/Fu.pm | 6 +- plug-ins/perl/Gimp/Lib.xs | 2 +- plug-ins/perl/examples/homepage-logo | 223 +++++++++++---------------- plug-ins/perl/examples/innerbevel | 2 - plug-ins/perl/examples/roundrectsel | 5 - plug-ins/perl/examples/scratches | 21 +-- 6 files changed, 105 insertions(+), 154 deletions(-) diff --git a/plug-ins/perl/Gimp/Fu.pm b/plug-ins/perl/Gimp/Fu.pm index 0dd9ddac84..efd330457c 100644 --- a/plug-ins/perl/Gimp/Fu.pm +++ b/plug-ins/perl/Gimp/Fu.pm @@ -803,7 +803,7 @@ IMAGETYPE is one of GIF, JPG, JPEG, PNM or PNG, options include -F do not flatten the image options for GIF and PNG images - +I do save as interlaced (GIF only) + +I do save as interlaced -I do not save as interlaced (default) options for GIF animations (use with -F) @@ -825,10 +825,10 @@ IMAGETYPE is one of GIF, JPG, JPEG, PNM or PNG, options include some examples: test.jpg save the image as a simple jpeg - JPG:test.jpg same + JPG:test.jpg the same JPG-Q70:test.jpg the same but force a quality of 70 GIF-I-F:test.jpg save a gif image(!) named test.jpg - non-inerlaced and without flattening + non-interlaced and without flattening =back diff --git a/plug-ins/perl/Gimp/Lib.xs b/plug-ins/perl/Gimp/Lib.xs index 4971d0e76a..34ba3af5e4 100644 --- a/plug-ins/perl/Gimp/Lib.xs +++ b/plug-ins/perl/Gimp/Lib.xs @@ -424,7 +424,7 @@ perl_paramdef_count (GimpParamDef *arg, int count) if (args[index].data.datatype || !args[index-1].data.d_int32) \ { \ for (j = 0; j < args[index-1].data.d_int32; j++) \ - trace_printf (frmt ## "%s", (ctype) args[index].data.datatype[j], \ + trace_printf (frmt "%s", (ctype) args[index].data.datatype[j], \ j < args[index-1].data.d_int32 - 1 ? ", " : ""); \ } \ else \ diff --git a/plug-ins/perl/examples/homepage-logo b/plug-ins/perl/examples/homepage-logo index 29855030f6..b3d2c6564a 100644 --- a/plug-ins/perl/examples/homepage-logo +++ b/plug-ins/perl/examples/homepage-logo @@ -1,151 +1,106 @@ #!/usr/bin/perl -# THIS IS OUTDATED AND WILL NOT RUN WITH CURRENT GIMP VERSIONS! - -# this test-plugin will create a simple button, and does automatically -# save it as an indexed gif in /tmp/x.gif - -# it works as plug-in as well as standalone! -# this script is old (its the first script ever written for gimp-perl) -# and I had no time to fix it yet. - use Gimp; +use Storable; -$blend1 = [0, 150, 255]; -$blend2 = [0, 255, 208]; -$black = "#000000"; -$font = "Engraver"; +$fg = [140,140,250]; +$fg2 = [250,250, 90,]; +$bg = [ 90, 0, 90]; +$w1 = 0.5; +$blur = 0.4; +$font = "-bitstream-blade runner movie font-demi-i-modern-*-*-*-*-*-p-*-iso8859-1"; + +$BASE = "/root/www/src"; +#$BASE = "/tmp"; # enable example mode... if disabled, it will write out some logos, and not # wont' display anything. -$example = 1; +$example = 0; -# set trace level to watch functions as they are executed -Gimp::set_trace(TRACE_NAME) if $example; +$|=1; -sub set_fg ($) { gimp_palette_set_foreground ($_[0]) }; -sub set_bg ($) { gimp_palette_set_background ($_[0]) }; -sub get_fg ($) { gimp_palette_get_foreground () }; -sub get_bg ($) { gimp_palette_get_background () }; +Gimp::init; -# shorthand function for drawing text -sub text($$$$$) { - my($img,$text,$border,$font,$size)=@_; - my $layer=gimp_text($img,-1,0,0,$text,$border,1,$size,PIXELS,"*",$font,"*","*","*","*"); - if (wantarray()) { - ($layer,gimp_text_get_extents($text,$size,PIXELS,"*",$font,"*","*","*","*")); - } else { - $layer; - } +%info = ( + 'example' => [50, "$BASE/images/menu"], + 'headline' => [20, "$BASE/images/menu"], + 'sub_on' => [12, "$BASE/images/menu"], + 'marc' => [25, "$BASE/marc/images/menu"], + 'marcmain' => [14, "$BASE/marc/images/menu"], + 'marcprojects' => [14, "$BASE/marc/images/menu"], + 'marcbackground' => [14, "$BASE/marc/images/menu"], +); + +if ($example) { + @strings = (['example',"Example"]); +} else { + my %depend = %{ retrieve "/root/www/depend" }; + my %logo; + while(my($k,$v)=each(%depend)) { + $logo{join ",",@$_}=$_ for @{$v->{L}}; + } + @strings = values(%logo); } -# convert image to indexed -# and automatically save it as interlaced gif. -sub index_and_save($$) { - my($img,$path)=@_; - gimp_image_flatten($img); - gimp_convert_indexed_palette($img,1,0,32,""); - file_gif_save(RUN_NONINTERACTIVE,$img,-1,$path,$path,1,0,0,0) unless $example; +for(@strings) { + my($class,$string)=@$_; + my($size,$base)=@{$info{$class}}; + print "($class,$size,$base,$string)\n"; + my($w,$h,$a,$d)=Gimp->text_get_extents_fontname($string,$size,PIXELS,$font); + system("rm -f $base/*.jpg"); + $h+=$d; + $w{$class}=$w if $w{$class}<$w; + $h{$class}=$h if $h{$class}<$h; } -sub write_logo { - my($string,$active,$w,$h,$uc)=@_; - - # create a new image - my $img=gimp_image_new($w,$h,RGB); - - # and a layer for it - my $bg=gimp_layer_new($img,$w,$h,RGB_IMAGE,"Background",100,NORMAL_MODE); - - gimp_image_add_layer($img,$bg,1); - - set_fg($blend1); - set_bg($blend2); - - # blend the background - gimp_blend($bg,FG_BG_HSV,NORMAL_MODE,LINEAR,100,0, - REPEAT_NONE,0,0,0, - 0,0,$w*0.9,$h); - gimp_rect_select ($img,$w*0.92,0,$w,$h,REPLACE, 0, 0); - gimp_blend($bg,FG_BG_HSV,NORMAL_MODE,LINEAR,100,0, - REPEAT_NONE,0,0,0, - $w,0,$w*0.92,0); - gimp_selection_all($img); - - set_fg($black); - - my ($text,$tw,$th,$ta,$td) = text ($img, $string, 1, $font, $active ? $h*0.7 : $h*0.5); - - gimp_layer_translate ($text,($w-$tw)/2,($h-$th+$td)/2); - - my ($shadow) = gimp_layer_copy ($text, 0); - - plug_in_gauss_rle ($text, 1, 1, 1) unless $active; - - gimp_image_add_layer ($img,$shadow,1); - - gimp_shear ($shadow,1,HORIZONTAL,-$th); - gimp_layer_scale ($shadow, $tw, $th*0.3, 1); - gimp_layer_translate ($shadow, $th*0.1, $th*0.3); - plug_in_gauss_rle ($shadow, 1, 1, 1); - - gimp_hue_saturation($bg, ALL_HUES, 0, 0, $active ? 10 : -40); - - plug_in_nova ($bg, $h*0.4, $h*0.5, '#f0a020', 5, 50) if $active; - plug_in_nova ($bg, $w-$h*0.4, $h*0.5, '#f0a020', 5, 50) if $active; - - # add an under construction sign - if ($uc) { - set_fg($active ? "#a00000" : "#000000"); - my ($uc,$tw,$th,$ta,$td) = text ($img, "u/c", 1, $font, $h*0.4); - gimp_rotate ($uc,1,0.2); - gimp_layer_translate ($uc,$w*0.84,($h-$th+$td)/2); - } - - index_and_save ($img, "/root/www/src/marc/images/${string}_".($active ? "on" : "off").".gif"); - - gimp_display_new ($img) if $example; - gimp_image_delete($img) unless $example; +for(@strings) { + my($class,$string)=@$_; + my $fn=$string; + my($size,$base)=@{$info{$class}}; + print "+"; + $fn=~y/-\/?&! A-Z/______a-z/; + my $img=create_logo (0,$w{$class},$h{$class},$size,$string,"$base/${fn}_off.jpg") if $class !~ /_on$/; + my $img=create_logo (1,$w{$class},$h{$class},$size,$string,"$base/${fn}_on.jpg"); } -# the extension that's called. -sub extension_homepage_logo { - # if in example mode just draw one example logo. - if($example) { - push(@logos,[ "-Projects", 0, 480, 60 ]); -# push(@logos,[ "-Projects", 1, 480, 60 ]); - } else { - for $active (0, 1) { - for $string (qw(Projects -Background -Main)) { - push(@logos,[$string,$active,240,30]); - } - } - for $active (0, 1) { - for $string (qw(PGCC Judge -FreeISDN -Gimp -Destripe -Links -EGCS)) { - push(@logos,[$string,$active,240,20]); - } - } - } - gimp_progress_init ("rendering buttons..."); - $numlogos = $#logos+1; - while($#logos>=0) { - gimp_progress_update (1-($#logos+1)/$numlogos); - my($string,$active,$w,$h)=@{pop(@logos)}; - $uc=$string=~s/^-//; - write_logo($string,$active,$w,$h,$uc); - } +print "\n"; + +sub create_logo { + my($on,$w,$h,$p,$t,$fn)=@_; + my $img = new Image($w+$w1*$h,$h,RGB); + my $b = new Layer($img,$w+$w1*$h,$h,RGB_IMAGE,'Background',100,NORMAL_MODE); + Palette->set_background($bg); + Palette->set_foreground($on ? $fg2 : $fg); + $b->fill(BG_IMAGE_FILL); + $b->add_layer(0); + + $img->display_new if $example; + + $t=~y/L/l/;# dumb font bladerunner + + my $t = $img->text_fontname(undef,0,$blur*$h*-.5,$t,$blur*$h,1,$p,PIXELS,$font); + my $s = $t->copy(0); $s->add_layer(0); + my $c = $t->copy(0); $c->add_layer(0); + + $t->mblur(0,$blur*$h,0); + $t->merge_down(EXPAND_AS_NECESSARY); + $s->gauss_rle(4,1,1); + $s->set_mode($on ? SUBTRACT_MODE : SUBTRACT_MODE); + #Gimp::set_trace(TRACE_NAME); + + if ($on) { + $c->brightness_contrast(100,0); + $c->set_mode(ADDITION_MODE); + } else { + $s->brightness_contrast(100,0); + $c->brightness_contrast(-50,0); + $c->set_mode(ADDITION_MODE); + } + + $img->flatten->file_jpeg_save($fn,$fn,0.70,0,1,1,"",0,1,0,0); + Gimp->displays_flush if $example; + + $img->clean_all; + + $img->delete unless $example; } - -sub query { - gimp_install_procedure("extension_homepage_logo", "a test extension in perl", - "try it out", "Marc Lehmann", "Marc Lehmann", "1997-02-06", - N_"/Xtns/Homepage-Logo", undef, EXTENSION, - [[PDB_INT32, "run_mode", "Interactive, [non-interactive]"]], []); -} - -sub net { - extension_homepage_logo; -} - -exit main; - diff --git a/plug-ins/perl/examples/innerbevel b/plug-ins/perl/examples/innerbevel index d93483ad57..effaff65f9 100755 --- a/plug-ins/perl/examples/innerbevel +++ b/plug-ins/perl/examples/innerbevel @@ -1,7 +1,5 @@ #!/usr/app/bin/perl -eval 'exec /usr/app/bin/perl -S $0 ${1+"$@"}' - if 0; # not running under some shell # Effect taken from http://tigert.gimp.org/gimp/tutorials/beveled_text/ # perl-ified by Seth Burgess diff --git a/plug-ins/perl/examples/roundrectsel b/plug-ins/perl/examples/roundrectsel index 0210ca88dc..0c41864963 100755 --- a/plug-ins/perl/examples/roundrectsel +++ b/plug-ins/perl/examples/roundrectsel @@ -1,10 +1,6 @@ #!/usr/app/bin/perl -eval 'exec /usr/app/bin/perl -S $0 ${1+"$@"}' - if 0; # not running under some shell # -# This is adrian's idea - take random blends and difference them. You're -# bound to come up w/ something cool eventually. use Gimp; use Gimp::Fu; @@ -43,7 +39,6 @@ register "round_rect_sel", $img->ellipse_select($bounds[3]-$x_round, $bounds[4]-$y_round, $x_round, $y_round, 0, 1, 0, 0.5); $img->ellipse_select($bounds[1], $bounds[4]-$y_round, $x_round, $y_round, 0, 1, 0, 0.5); - eval { $img->undo_push_group_end }; return(); }; diff --git a/plug-ins/perl/examples/scratches b/plug-ins/perl/examples/scratches index 322850a743..2177e84679 100755 --- a/plug-ins/perl/examples/scratches +++ b/plug-ins/perl/examples/scratches @@ -1,22 +1,22 @@ #!/usr/app/bin/perl -eval 'exec /usr/app/bin/perl -S $0 ${1+"$@"}' - if 0; # not running under some shell - use Gimp; use Gimp::Fu; use Gimp::Util; +# Erzeuge ein neues "scratchlayer", d.h. eine Ebene, die graue +# Streifen einer bestimmten Richtung enthält. Dazu wird ein +# weisses Bild "verrauscht" und mit motion-blur in einem +# bestimmten Winkel weichgezeichnet. sub new_scratchlayer { - my($image,$length,$gamma,$angle)=@_; - my $type=$image->layertype(0); - my($layer)=$image->layer_new ($image->width, $image->height, $image->layertype(0), + my ($image,$length,$gamma,$angle) = @_; + my $type = $image->layertype(0); + my $layer = $image->layer_new ($image->width, $image->height, $image->layertype(0), "displace layer ($angle)", 100, NORMAL_MODE); $layer->add_layer(-1); $layer->fill (WHITE_IMAGE_FILL); $layer->noisify (0, 1, 1, 1, 0); $layer->mblur (0, $length, $angle); - #$layer->levels (VALUE_LUT, 120, 255, $gamma, 0, 255); $layer->levels (VALUE_LUT, 120, 255, 0.3, 0, 255); $layer; @@ -36,20 +36,23 @@ register "scratches", [PF_SLIDER , "gamma" , "Scratch map gamma" , 0.3, [0.1, 10, 0.05]], [PF_SPINNER , "smoothness" , "The scratch smoothness" , 15, [ 0, 400]], [PF_SPINNER , "length" , "The scratch length" , 10, [ 0, 400]], - #[PF_BOOL, , "bump_map" , "Use bump map instead of displace", 0], ], [], ['gimp-1.1'], sub { - my($image,$drawable,$anglex,$angley,$gamma,$length,$width)=@_; + my ($image,$drawable,$anglex,$angley,$gamma,$length,$width) = @_; $image->undo_push_group_start; + # Erzeuge zwei "scratchlayer", die die Verschiebung in X und Y + # angeben. my $layer1 = new_scratchlayer ($image, $length, $gamma, $anglex); my $layer2 = new_scratchlayer ($image, $length, $gamma, $angley); + # Verschmiere das Bild. $drawable->displace ($width, $width, 1, 1, $layer1, $layer2, WRAP); + # die beiden Ebenen werden nicht länger benötigt. $layer1->remove_layer; $layer2->remove_layer;