Looking for example 3d circle

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
mc_hendriks
Posts: 14
Joined: 2014-02-28T00:30:49-07:00
Authentication code: 6789

Looking for example 3d circle

Post by mc_hendriks »

I'm looking for a perl example to create a 3-D looking circle (or ball).
Any help would be appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Looking for example 3d circle

Post by fmw42 »

Sorry, I cannot give you that in Perl(Magick), but I do have a bash shell script, spherize a the link below. You probably can convert my command lines to Perlmagick.

Or you likely can make a call from Perl to run my shell script.
mc_hendriks
Posts: 14
Joined: 2014-02-28T00:30:49-07:00
Authentication code: 6789

Re: Looking for example 3d circle

Post by mc_hendriks »

I have made the following "working" example:
Still have a few questions at the bottom left.
...
####################
# part of example script
####################
print "Create 3D ball ...\n";
$img=Image::Magick->new;
$img->Set(size=>'500x500');
$x=$img->ReadImage('xc:white');
warn "$x" if "$x";
my ($center_x,$center_y,$radius)=(200,200,200);
$img->Draw(fill => 'red', points => "$center_x,$center_y @{[$center_x + $radius]},$center_y", primitive => 'circle' );

#
# create a radial white spot
#
$example=Image::Magick->new;
$example->Set(size=>'150x150');
$x=$example->ReadImage('radial-gradient:white-red');
warn "$x" if "$x";

# put it together in one image
$img->Composite(image=>$example,compose=>'over',geometry=>'+45+75');

# write it to a file:
$img->Write('perlmagickdemo.jpg');

http://digirent.nl/images/perlmagickdemo.jpg

# Questions left on the samen example:
###################
# is it possible to use Composite and only use a cirkel of the $example ? Now it copies the complete square
# is it possible to get a more 3d looking effect on the border of the red cirkel and how to realize that?
####################
Post Reply