anti-aliased 2D vector graphics

Discussion in 'Python' started by Andy C, Aug 1, 2003.

  1. Andy C

    Andy C Guest

    Where can I get a python package to draw such figures? I googled and found
    PyX, I guess it outputs PostScript. I guess I can get a PostScript to BMP
    converter or something. Is there any other alternative?

    I have looked at PIL, but it doesn't seem to support drawing anti-aliased
    figures. Thanks for any suggestions.

    Andy
    Andy C, Aug 1, 2003
    #1
    1. Advertising

  2. Andy C

    Andy C Guest

    Note that I'm on Windows... if there is some windows-specific solution, that
    would be fine. I know there is a python win32 interface, and I think GDI
    supports anti-aliased vector graphics, but I'm not sure. And fonts -- I
    need to draw text too. Anyone tried that approach?

    thanks,
    Andy

    "Andy C" <> wrote in message
    news:J3pWa.420$...
    > Where can I get a python package to draw such figures? I googled and

    found
    > PyX, I guess it outputs PostScript. I guess I can get a PostScript to BMP
    > converter or something. Is there any other alternative?
    >
    > I have looked at PIL, but it doesn't seem to support drawing anti-aliased
    > figures. Thanks for any suggestions.
    >
    > Andy
    >
    >
    Andy C, Aug 1, 2003
    #2
    1. Advertising

  3. Andy C

    Udo Gleich Guest

    Hi,

    pygame (www.pygame.org) can at least draw antialiased
    lines. Look for the draw module in the documentation.

    Udo
    Udo Gleich, Aug 1, 2003
    #3
  4. On Fri, 01 Aug 2003 07:57:29 GMT, rumours say that "Andy C"
    <> might have written:

    >Where can I get a python package to draw such figures? I googled and found
    >PyX, I guess it outputs PostScript. I guess I can get a PostScript to BMP
    >converter or something. Is there any other alternative?
    >
    >I have looked at PIL, but it doesn't seem to support drawing anti-aliased
    >figures. Thanks for any suggestions.


    Use PIL, and draw on an image twice the size (2*width, 2*height) as the
    one you want. When you're done, resize the image --BILINEAR works fine
    in this case.

    You will need to draw thicker lines & arcs (I don't remember ATM if you
    can use a <width> parameter with drawing methods)... create a custom
    class to manage drawing double lines and arcs / circles when needed.
    --
    TZOTZIOY, I speak England very best,
    Microsoft Security Alert: the Matrix began as open source.
    Christos TZOTZIOY Georgiou, Aug 1, 2003
    #4
  5. Andy C

    Robin Becker Guest

    In article <PipWa.422$>, Andy C
    <> writes
    >Note that I'm on Windows... if there is some windows-specific solution, that
    >would be fine. I know there is a python win32 interface, and I think GDI
    >supports anti-aliased vector graphics, but I'm not sure. And fonts -- I
    >need to draw text too. Anyone tried that approach?
    >
    >thanks,
    >Andy
    >

    ReportLab graphics does anti aliased bitmap drawing via libart_lgpl, but
    I know it's not easy to get into.
    --
    Robin Becker
    Robin Becker, Aug 1, 2003
    #5
  6. Andy C wrote:

    > Where can I get a python package to draw such figures? I googled and
    > found
    > PyX, I guess it outputs PostScript. I guess I can get a PostScript to
    > BMP
    > converter or something. Is there any other alternative?


    One obvious solution would be to use GhostView to use PostScript to
    generate an image, and then sample it down with a good resampling
    library, like PNM.

    --
    Erik Max Francis && && http://www.alcyone.com/max/
    __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
    / \ As far as I'm concerned, being any gender is a drag.
    \__/ Patti Smith
    Erik Max Francis, Aug 1, 2003
    #6
  7. <posted & mailed>

    Andy C wrote:

    > Where can I get a python package to draw such figures? I googled and
    > found
    > PyX, I guess it outputs PostScript. I guess I can get a PostScript to BMP
    > converter or something. Is there any other alternative?
    >
    > I have looked at PIL, but it doesn't seem to support drawing anti-aliased
    > figures. Thanks for any suggestions.


    In addition to the other suggestions made, you might want to consider
    Sketch. It's normally billed as an application, but it's also a pretty
    powerful drawing library for python. I'm uncertain about installation
    issues, it may be a little harder to build on Windows than on Linux, (but
    I suspect this is less of a problem if you just want to use it as a
    library). But it certainly can do everything that you've mentioned.

    I'm pretty sure that Sketch has anti-aliased rendering, but you should also
    be aware that you can get pretty good results simply by oversampling -- I
    usually draw at 4X the intended scale and then scale down by 1/4 to get the
    final result. This is somewhat coarse, but it works pretty well visually.

    See http://sketch.sourceforge.net/ and links therein.

    Cheers,
    Terry

    --
    Terry Hancock
    Anansi Spaceworks http://www.AnansiSpaceworks.com/
    Terry Hancock, Aug 2, 2003
    #7
  8. Andy C

    Dave Brown Guest

    In article <J3pWa.420$>,
    Andy C <> wrote:
    : Where can I get a python package to draw such figures? I googled and found
    : PyX, I guess it outputs PostScript. I guess I can get a PostScript to BMP
    : converter or something. Is there any other alternative?

    Sounds like a job for...SVG!

    Here, have a look at this: http://www2.sfk.nl/svg

    --Dave
    --
    "I had my first real beer (real meaning not sneaking it, or
    the .5 crap), and amazingly enough, I wasn't immediately
    surrounded by girls in bikinis. Go figure...."
    -- Rob Hoadley
    Dave Brown, Aug 3, 2003
    #8
  9. On Sat, 02 Aug 2003 01:43:50 GMT, rumours say that "Andy C"
    <> might have written:

    [SNIP: My suggesting double size images and then resizing]

    >Thanks for the suggestion, I think this will work fine for what I'm doing.
    >A little off topic, but is this how it is typically done? Is there a
    >special case for lines vs. fonts?


    Font size should be doubled.
    For lines, you *need* from 2 to 3 lines, but that involves some
    math.atan2 style pre-calculations... (you can follow the easy way and
    draw four lines as in the next paragraph.
    For boxes, lines etc you better draw each 4 times
    (x+0, y+0), (x+0, y+1), (x+1, y+0), (x+1, y+1)
    --
    TZOTZIOY, I speak England very best,
    Microsoft Security Alert: the Matrix began as open source.
    Christos TZOTZIOY Georgiou, Aug 4, 2003
    #9
  10. On Sat, 02 Aug 2003 01:43:50 GMT, rumours say that "Andy C"
    <> might have written:

    >A little off topic, but is this how it is typically done? Is there a
    >special case for lines vs. fonts?


    Ah, *that* was your question (I was hasty in answering a few minutes
    earlier).
    I believe that yes, this is what is typically done for line art; but my
    answer is not authoritative.
    For fonts, I do not know for certain, although I know for certain that
    this is what *I* have done in a simple "ClearType"-like-display text
    reader I have written for reading texts in my Win2K notebook (I won't
    bother installing XP *only* for the ClearType capability).
    --
    TZOTZIOY, I speak England very best,
    Microsoft Security Alert: the Matrix began as open source.
    Christos TZOTZIOY Georgiou, Aug 4, 2003
    #10
  11. Andy C

    Borcis Guest

    Dave Brown wrote:
    >
    > Sounds like a job for...SVG!


    I was going to say the same thing.

    >
    > Here, have a look at this: http://www2.sfk.nl/svg


    I'd say before a python wrapper, the first things to
    look for are the open spec/doc at w3c, and a working renderer.
    Given that svg is an xml language, I find a wrapper like
    the one pointed at by your link, a bit paradoxical in the
    sense that it's first selling point appears to be the
    convenience of not seeing the xml representation while its
    intrinsic documentation isn't sufficient for that purpose.
    Borcis, Aug 4, 2003
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. .Net Sports
    Replies:
    1
    Views:
    373
    Verde
    Sep 17, 2005
  2. Mark Rae
    Replies:
    0
    Views:
    615
    Mark Rae
    Mar 7, 2006
  3. Leonard Slatkin
    Replies:
    0
    Views:
    442
    Leonard Slatkin
    Nov 1, 2003
  4. Replies:
    8
    Views:
    1,896
    Csaba
    Feb 18, 2006
  5. Replies:
    3
    Views:
    324
Loading...

Share This Page