This all began as a way to draw diagrams for American football (I have a blog mixing football, curve fits using
PDL, stats using
PDL::Stats, graphs using
Chart::Clicker, and other bits of Perl, called "Code and Football"), and originally I was mostly using Windows batch and command line Image Magick.
A bash equivalent might be something like this..
#! /bin/bash
convert -size 100x100 -stroke SeaGreen -fill palegreen -strokewidth 2
+\
xc:white -draw 'translate 50,50 circle 0,0,25,0' /share/circle_script.
+jpg
After a while I got interested in doing the same things in Perl, because typing
'convert blah blah' all the time was getting old, and code reuse was becoming more and more a factor.
I started rewriting things into PerlMagick and lo and behold, things started breaking, such as this simple way to draw a circle using translate. The code below demonstrates my issue (i.e. translate fails).
#! /usr/bin/perl
use warnings;
use strict;
use Image::Magick;
my $p = Image::Magick->new;
$p->Set( size => '100x100');
$p->Read("xc:white");
$p->Draw( primitive => 'circle' ,translate => "50,50",
stroke => 'SeaGreen', strokewidth => 2, fill => 'palegreen',
points => '0,0,25,0' );
$p->Write("/share/circle_perl.jpg");
I have this problem with the default IM packages in both Ubuntu 10.04 and Ubuntu 11.04. But if I switch to Graphics::Magick, it
just works.
Thing is, I don't see Graphics::Magick in CPAN and after having authored one whole CPAN module, I'm growing a little fond of that way of "publishing" code. But some questions, I think, are worth asking at this point, before pushing too far up the possible CPAN path.
- Can CPAN code be based on Graphics::Magick?
- Should such code look for either module, and switch?
- How do you test a proposed graphics module, whose output is visual, with something like Test::More?
Any comments, hints, ideas appreciated.
David.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.