Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

As LTjake suggests, you might want to create a subclass for each of the imaging libraries you support.

For example, you have a line() method, instead of defining that in Image::Mate with a huge conditional for each implementation, you simply define it in each of the derived classes. Then have Image::Mate::new() return an object of that type.

Imager does something similar for its font support - Imager::Font itself doesn't know how to draw text, it lets Imager::Font::(Truetype|Win32|FreeType2|Type1) specialize _draw() which does all the heavy lifting.

This is pretty basic OO.

Another issue I see is that you appear to load every one of the imaging libraries even though the user would only want to use one of them, and you then call import() in package main for that module.

The use of the c option to new() seems a bit inconsitent too - for GD this is used to decide between a paletted image and a true color image, for Imager it's used to decide between an 8-bits/sample image (24-bit color) and 16-bits/sample (48-bit color), but I suspect this is a case of trying to make sense of the different options the modules support.

In reply to Re: Comments and suggestions on new module by tonyc
in thread Comments and suggestions on new module by cosmicperl

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (4)
    As of 2018-03-18 06:51 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (228 votes). Check out past polls.