Hi!
I'm learning to write Gimp-perl scripts. Just now, I
tried to draw a line with a width of one pixel. From within
gimp this can be done by selecting the 'Circle (01)' brush.
However, when I do this in a script, the line width drawn gets
to be two pixels wide. I can't figure out how to change this
behaviour.
Second, In my script, I generate a custom gradient: I just
put some numers in a text file. Now, I'd like to use this gradient
from that point on, but as it turns out, I can't use it, until
I pressed 'refresh' from the gradients editor. Is there any
way of 'refreshing' the gradients from a perls script, without
user interaction?
I included the test script I used, below; maybe some of you
have a good tip for me
regards,
Jos van Riswick
[EMAIL PROTECTED]
#!/usr/bin/perl
use Gimp qw( :auto );
Gimp::init;
$NX=400; $NY=30;
$image = new Image ($NX,$NY,RGB);
$layer0 = $image->layer_new ($NX,$NY,0,"x",100,0);
$layer0->edit_clear;
$layer0->add_layer(0);
# Generate a custom gradient
MyGradient(0.5, 1,1,0, 0,0,0 );
gimp_gradients_set_active("MyGradient");
gimp_blend($layer0,CUSTOM,0,0,100,0,0,1,3,2,0,40,100,60);
# Draw a line
gimp_brushes_set_opacity (100);
gimp_brushes_set_paint_mode (0);
gimp_brushes_set_spacing (1);
gimp_brushes_set_brush("Circle (01)");
gimp_palette_set_foreground ("orange");
gimp_paintbrush ($layer0,0,1,[3,3,$NX-3,3],0,0);
# gimp_paintbrush_default ($layer0,1,[3,3,$NX-3,3]);
# $layer0->set_pixel(3,3,24,[0,0,0]);
$layer0->file_xpm_save(("/root/pl/test.xpm")x2);
# $c=ConvertColor("blue");
# $c=ConvertColor([245,0,34]);
# print @$c; print $$c[1];
sub ConvertColor {
my ($retval,$oldcol);
print "$color\n";
$oldcol=gimp_palette_get_background();
gimp_palette_set_background($_[0]);
$retval=gimp_palette_get_background();
gimp_palette_set_background($oldcol);
return $retval;
}
sub MyGradient {
my ($center,$r1,$g1,$b1,$r2,$g2,$b2)=@_;
open(OUT,'>/root/.gimp-1.1/gradients/MyGradient');
print OUT "GIMP Gradient\n";
print OUT "1\n";
print OUT "0 $center 1 $r1 $g1 $b1 1 $r2 $g2 $b2 1 0 0\n";
close(OUT);
}