Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63e443f

Browse files
committed
added scale free ellipse to agg
svn path=/trunk/matplotlib/; revision=2673
1 parent 4ae31dd commit 63e443f

3 files changed

Lines changed: 30 additions & 21 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
2006-08-11 Added scale free Ellipse patch for Agg - CM
2+
13
2006-08-10 Added converters to and from julian dates to matplotlib.dates
24
(num2julian and julian2num) - JDH
35

46
2006-08-08 Fixed widget locking so multiple widgets could share the
57
event handling - JDH
68

7-
2006-08-07 Added scale free Ellipse patch
9+
2006-08-07 Added scale free Ellipse patch to SVG and PS - CM
810

911
2006-08-05 Re-organized imports in numerix for numpy 1.0b2 -- TEO
1012

src/_backend_agg.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ GCAgg::_set_clip_rectangle( const Py::Object& gc) {
188188

189189

190190
Py::Object BufferRegion::to_string(const Py::Tuple &args) {
191-
191+
192192
// owned=true to prevent memory leak
193193
return Py::String(PyString_FromStringAndSize((const char*)aggbuf.data,aggbuf.height*aggbuf.stride), true);
194-
}
195-
194+
}
195+
196196

197197

198198

@@ -385,8 +385,14 @@ RendererAgg::draw_ellipse(const Py::Tuple& args) {
385385

386386
set_clipbox_rasterizer(gc.cliprect);
387387

388-
//last arg is num steps
389-
agg::ellipse path(x, height-y, w, h, 100);
388+
// Approximate the ellipse with 4 bezier paths
389+
agg::path_storage path;
390+
path.move_to(x, height-(y+h));
391+
path.arc_to(w, h, 0.0, false, true, x+w, height-y);
392+
path.arc_to(w, h, 0.0, false, true, x, height-(y-h));
393+
path.arc_to(w, h, 0.0, false, true, x-w, height-y);
394+
path.arc_to(w, h, 0.0, false, true, x, height-(y+h));
395+
path.close_polygon();
390396

391397
_fill_and_stroke(path, gc, face);
392398
return Py::Object();
@@ -640,7 +646,7 @@ RendererAgg::copy_from_bbox(const Py::Tuple& args) {
640646
*/
641647
int boxwidth = r.x2-r.x1;
642648
int boxheight = r.y2-r.y1;
643-
int boxstride = boxwidth*4;
649+
int boxstride = boxwidth*4;
644650
agg::buffer buf(boxwidth, boxheight, boxstride, false);
645651
if (buf.data ==NULL) {
646652
throw Py::MemoryError("RendererAgg::copy_from_bbox could not allocate memory for buffer");
@@ -2186,7 +2192,7 @@ RendererAgg::buffer_rgba(const Py::Tuple& args) {
21862192
int row_len = width*4;
21872193
int start=row_len*starth+startw*4;
21882194
return Py::asObject(PyBuffer_FromMemory( pixBuffer+start, row_len*height-start));
2189-
}
2195+
}
21902196

21912197

21922198

src/_backend_agg.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "agg_arrowhead.h"
1212
#include "agg_basics.h"
13+
#include "agg_bezier_arc.h"
1314
#include "agg_color_rgba.h"
1415
#include "agg_conv_concat.h"
1516
#include "agg_conv_contour.h"
@@ -76,17 +77,17 @@ class GCAgg {
7677
double dpi;
7778
bool snapto;
7879
bool isaa;
79-
80-
agg::line_cap_e cap;
80+
81+
agg::line_cap_e cap;
8182
agg::line_join_e join;
8283

83-
84+
8485
double linewidth;
8586
double alpha;
8687
agg::rgba color;
8788

8889
double *cliprect;
89-
90+
9091
//dashes
9192
size_t Ndash;
9293
double dashOffset;
@@ -138,11 +139,11 @@ class RendererAgg: public Py::PythonExtension<RendererAgg> {
138139
Py::Object copy_from_bbox(const Py::Tuple & args);
139140
Py::Object restore_region(const Py::Tuple & args);
140141

141-
142-
143142

144143

145-
virtual ~RendererAgg();
144+
145+
146+
virtual ~RendererAgg();
146147

147148
static const size_t PIXELS_PER_INCH;
148149
unsigned int width, height;
@@ -177,7 +178,7 @@ class RendererAgg: public Py::PythonExtension<RendererAgg> {
177178
agg::rgba rgb_to_color(const Py::SeqBase<Py::Object>& rgb, double alpha);
178179
facepair_t _get_rgba_face(const Py::Object& rgbFace, double alpha);
179180
void set_clipbox_rasterizer( double *cliprect);
180-
template <class VS> void _fill_and_stroke(VS&, const GCAgg&, const facepair_t&, bool curvy=true);
181+
template <class VS> void _fill_and_stroke(VS&, const GCAgg&, const facepair_t&, bool curvy=true);
181182

182183
template<class PathSource>
183184
void _render_lines_path(PathSource &ps, const GCAgg& gc);
@@ -195,19 +196,19 @@ class _backend_agg_module : public Py::ExtensionModule<_backend_agg_module>
195196
BufferRegion::init_type();
196197
RendererAgg::init_type();
197198

198-
add_keyword_method("RendererAgg", &_backend_agg_module::new_renderer,
199+
add_keyword_method("RendererAgg", &_backend_agg_module::new_renderer,
199200
"RendererAgg(width, height, dpi)");
200201
initialize( "The agg rendering backend" );
201202
}
202-
203+
203204
virtual ~_backend_agg_module() {}
204-
205+
205206
private:
206-
207+
207208
Py::Object new_renderer (const Py::Tuple &args, const Py::Dict &kws);
208209

209210

210-
211+
211212
};
212213

213214

0 commit comments

Comments
 (0)