Page 1 of 1

Looking for example 3d circle

Posted: 2016-09-10T06:27:08-07:00
by mc_hendriks
I'm looking for a perl example to create a 3-D looking circle (or ball).
Any help would be appreciated.

Re: Looking for example 3d circle

Posted: 2016-09-10T11:22:50-07:00
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.

Re: Looking for example 3d circle

Posted: 2016-09-11T03:44:22-07:00
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?
####################