anti-aliased 2D vector graphics

A

Andy C

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
 
A

Andy C

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
 
C

Christos TZOTZIOY Georgiou

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.
 
R

Robin Becker

Andy C said:
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.
 
E

Erik Max Francis

Andy said:
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.
 
T

Terry Hancock

<posted & mailed>

Andy said:
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
 
D

Dave Brown

: 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
 
C

Christos TZOTZIOY Georgiou

[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)
 
C

Christos TZOTZIOY Georgiou

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).
 
B

Borcis

Dave said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top