Using the Agg renderer by itself

Hi Folks,

I've got some drawing to do (for a web app). I don't need all the MPL machinery, but I do need a high quality, fast, renderer.

Other options:

  - The python bindings to GD seem to not really being maintained

  - PyCairo is a pain to install, and not fast for Python (doesn't know about numpy arrays of points, for instance)

  - Kiva appears to be quite enmeshed with ETS, and thus a bit of trick to install (at least without EPD or PythonXY or something)

So I thought I'd give MPL's AGG wrappers a try. I've managed to get things working, but I do have a couple questions:

1) are there docs somewhere? What I've found is very sparse, and doc strings are minimal -- though I've got the source, so only so much or a complaint.

2) It looks like the AGG renderers take floats for almost everything -- makes sense, with anti-aliasing and sub-pixel rendering. But is it float32 or float64 internally? It seems either will work, but I'm going for maximum performance, so I'd like to use the native format.

Testing drawing a polygon, I'm a bit confused about GraphicsContext vs the renderer. If I do:

gc = GraphicsContextBase()
transform = Affine2D() # default unit transform

## draw the polygon:
## create a path for a polygon:
points = np.array(((10,10),(10,190),(150,100),(290,10),(10,10)),np.float64)

p = Path(points)

gc.set_linewidth(4)
gc.set_alpha(0.75)

fill_color = (0.0, 1.0, 0.0)
line_color = (1.0, 0.0, 0.0)

#gc._rgb = line_color
gc.set_foreground(line_color)

Canvas.draw_path(gc, p, transform, fill_color)

I get a green polygon with a red border, like I'd expect. However:

Why is the outline color set in the GraphicsContext, but the fill color passed in to the draw_path call? Or am I doing that wrong?

Thanks for input,

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...236...

I've got some drawing to do (for a web app). I don't need all the MPL
machinery, but I do need a high quality, fast, renderer.

One more question. I see:

     def draw_markers(self, *kl, **kw):
         # for filtering to work with rastrization, methods needs to be wrapped.
         # maybe there is better way to do it.
         return self._renderer.draw_markers(*kl, **kw)

What do I pass in to this function?

Thanks,
   -Chris

···

On 11/23/11 9:52 AM, Chris.Barker wrote:

Other options:

   - The python bindings to GD seem to not really being maintained

   - PyCairo is a pain to install, and not fast for Python (doesn't know
about numpy arrays of points, for instance)

   - Kiva appears to be quite enmeshed with ETS, and thus a bit of trick
to install (at least without EPD or PythonXY or something)

So I thought I'd give MPL's AGG wrappers a try. I've managed to get
things working, but I do have a couple questions:

1) are there docs somewhere? What I've found is very sparse, and doc
strings are minimal -- though I've got the source, so only so much or a
complaint.

2) It looks like the AGG renderers take floats for almost everything --
makes sense, with anti-aliasing and sub-pixel rendering. But is it
float32 or float64 internally? It seems either will work, but I'm going
for maximum performance, so I'd like to use the native format.

Testing drawing a polygon, I'm a bit confused about GraphicsContext vs
the renderer. If I do:

gc = GraphicsContextBase()
transform = Affine2D() # default unit transform

## draw the polygon:
## create a path for a polygon:
points = np.array(((10,10),(10,190),(150,100),(290,10),(10,10)),np.float64)

p = Path(points)

gc.set_linewidth(4)
gc.set_alpha(0.75)

fill_color = (0.0, 1.0, 0.0)
line_color = (1.0, 0.0, 0.0)

#gc._rgb = line_color
gc.set_foreground(line_color)

Canvas.draw_path(gc, p, transform, fill_color)

I get a green polygon with a red border, like I'd expect. However:

Why is the outline color set in the GraphicsContext, but the fill color
passed in to the draw_path call? Or am I doing that wrong?

Thanks for input,

-Chris

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...236...

2011/11/23 Chris.Barker <Chris.Barker@...236...>:

I've got some drawing to do (for a web app). I don't need all the MPL
machinery, but I do need a high quality, fast, renderer.

http://www.effbot.org/zone/aggdraw-index.htm

http://www.effbot.org/imagingbook/imagedraw.htm

Don't know if this suffices your needs.

Friedrich

There is an HTML5 backend, supposedly. Don’t know how well documented it is, though.

Ben Root

···

On Wednesday, November 23, 2011, Chris.Barker <Chris.Barker@…236…> wrote:

Hi Folks,

I’ve got some drawing to do (for a web app). I don’t need all the MPL

machinery, but I do need a high quality, fast, renderer.

Other options:

  • The python bindings to GD seem to not really being maintained

  • PyCairo is a pain to install, and not fast for Python (doesn’t know

about numpy arrays of points, for instance)

  • Kiva appears to be quite enmeshed with ETS, and thus a bit of trick
    to install (at least without EPD or PythonXY or something)

So I thought I’d give MPL’s AGG wrappers a try. I’ve managed to get
things working, but I do have a couple questions:

  1. are there docs somewhere? What I’ve found is very sparse, and doc

strings are minimal – though I’ve got the source, so only so much or a
complaint.

  1. It looks like the AGG renderers take floats for almost everything –
    makes sense, with anti-aliasing and sub-pixel rendering. But is it

float32 or float64 internally? It seems either will work, but I’m going
for maximum performance, so I’d like to use the native format.

Testing drawing a polygon, I’m a bit confused about GraphicsContext vs

the renderer. If I do:

gc = GraphicsContextBase()
transform = Affine2D() # default unit transform

draw the polygon:

create a path for a polygon:

points = np.array(((10,10),(10,190),(150,100),(290,10),(10,10)),np.float64)

p = Path(points)

gc.set_linewidth(4)
gc.set_alpha(0.75)

fill_color = (0.0, 1.0, 0.0)
line_color = (1.0, 0.0, 0.0)

#gc._rgb = line_color
gc.set_foreground(line_color)

Canvas.draw_path(gc, p, transform, fill_color)

I get a green polygon with a red border, like I’d expect. However:

Why is the outline color set in the GraphicsContext, but the fill color

passed in to the draw_path call? Or am I doing that wrong?

Thanks for input,

-Chris

Hmm -- coll idea -- I'll look into that at some point. However, as I don't need the MPL machinerey, but just the renderer, I'm not sure it would buy me much.

And I'm not sure I can:

a) count on html 5 on all browsers we need to support

or

b) get the drawing performance I want if I have to push all the data to the client to draw.

But something to keep an eye on, thanks.

-Chris

···

On 11/23/11 10:38 AM, Benjamin Root wrote:

On Wednesday, November 23, 2011, Chris.Barker <Chris.Barker@...236... > <mailto:Chris.Barker@…236…>> wrote:
> Hi Folks,
>
> I've got some drawing to do (for a web app). I don't need all the MPL
> machinery, but I do need a high quality, fast, renderer.

There is an HTML5 backend, supposedly. Don't know how well documented
it is, though.

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...236...

2011/11/23 Chris.Barker<Chris.Barker@...236...>:

I've got some drawing to do (for a web app). I don't need all the MPL
machinery, but I do need a high quality, fast, renderer.

http://www.effbot.org/zone/aggdraw-index.htm

I've been wondering about that -- it doesn't look terribly maintained -- no updates for a long time, and I'm concerned about performance 99 if you are drawing something simple, but with lot's of points, all that conversion from numpy types to python type to C types is going to be an issue.

http://www.effbot.org/imagingbook/imagedraw.htm

this is definitely slow for what I'm doing.

Thanks,
   -Chris

···

On 11/23/11 10:13 AM, Friedrich Romstedt wrote:

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...236...