3d-buttons with Perl , Dst_In and Fx confusion.
Posted: 2008-09-28T07:31:08-07:00
Hi, I was tring to convert the 3d button tutorial at http://www.imagemagick.org/Usage/advanced/#3d-logos-2 to Perl. The commandline code looks like
here is my start at a Perl version
Does anyone know how to finish this 3d thing off?
Code: Select all
#Lets start by again showing the start logo we will be giving a
#3D look. This is exactly as above, to produce the sample logo.
convert -size 170x100 xc:black \
-fill white -draw 'circle 50,50 13,50' \
-draw 'circle 120,50 157,50' \
-draw 'rectangle 50,13 120,87' \
-fill black -draw 'circle 50,50 25,50' \
-draw 'circle 120,50 145,50' \
-draw 'rectangle 50,25 120,75' \
-fill white -draw 'circle 60,50 40,50' \
-draw 'circle 110,50 130,50' \
-draw 'rectangle 60,30 110,70' \
-gaussian 1x1 +matte ant_mask.png
convert ant_mask.png -fill red -draw 'color 0,0 reset' \
ant_mask.png +matte -compose CopyOpacity -composite \
-font Generic.ttf -pointsize 36 -fill white -stroke black \
-gravity Center -annotate -0 "Ant" \
ant.png
#I still use a mask for generating the logo, as this is a good way of erasing the area between the central oval and the outer ring of the logo.
#Now lets give it a 3D-look, by using Overlay Highlighting techniques.
##################################
###################################
# my difficulty is here with -fx A and what Dst_in is
convert ant.png -fx A +matte -blur 0x6 -shade 110x30 -normalize \
ant.png -compose Overlay -composite \
ant.png -matte -compose Dst_In -composite \
ant_3D.png
###################################
##################################
#Adding shadows is also easier thanks to the new Shadow Generation operator
#provided by IM.
convert ant_3D.png \( +clone -background navy -shadow 80x4+6+6 \) +swap \
-background none -layers merge +repage ant_3D_shadowed.png
Code: Select all
#!/usr/bin/perl -w
use strict;
use Image::Magick;
my $image = Image::Magick->new;
$image->Set(size=>'170x100');
my $rc = $image->Read("xc:black");
$image->Draw(primitive=> 'circle',fill=>'red', points=>'50,50 13,50');
$image->Draw(primitive=> 'circle',fill=>'red', points=>'120,50 157,50');
$image->Draw(primitive=> 'rectangle',fill=>'red', points=>'50,13 120,87');
$image->Draw(primitive=> 'circle',fill=>'black', points=>'50,50 25,50');
$image->Draw(primitive=> 'circle',fill=>'black', points=>'120,50 145,50');
$image->Draw(primitive=> 'rectangle',fill=>'black', points=>'50,25 120,75');
$image->Draw(primitive=> 'circle',fill=>'red', points=>'60,50 40,50');
$image->Draw(primitive=> 'circle',fill=>'red', points=>'110,50 130,50');
$image->Draw(primitive=> 'rectangle',fill=>'red', points=>'60,30 110,70');
$image->Set(matte=>1);
$image->Set(gaussian=>'1x1');
$image->Annotate(
pointsize=>40,
text=>'Ant',
stroke => 'black',
fill => 'white',
gravity => 'center',
x=> 0, # offsets
y=> 0, # offsets
);
#I still use a mask for generating the logo, as this is a good way of erasing the area between the central oval and the outer ring of the logo.
#Now lets give it a 3D-look, by using Overlay Highlighting techniques.
################################################
#I'm stuck here with -fx A and Dst_In, I can't figure out the Perl translation
###############################################
# convert ant.png -fx A +matte -blur 0x6 -shade 110x30 -normalize ant.png
#convert -compose Overlay -composite ant.png -matte -compose Dst_In -composite #ant_3D.png
$image->Write("ant.png");
__END__
Does anyone know how to finish this 3d thing off?