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

Skip to content

Commit b301de1

Browse files
committed
Inline convert_face type converter
1 parent c002273 commit b301de1

File tree

3 files changed

+12
-27
lines changed

3 files changed

+12
-27
lines changed

src/_backend_agg_wrapper.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ PyRendererAgg_draw_path(RendererAgg *self,
4545
GCAgg &gc,
4646
mpl::PathIterator path,
4747
agg::trans_affine trans,
48-
py::object face_obj)
48+
py::object rgbFace)
4949
{
50-
agg::rgba face;
51-
52-
if (!convert_face(face_obj.ptr(), gc, &face)) {
53-
throw py::error_already_set();
50+
agg::rgba face = rgbFace.cast<agg::rgba>();
51+
if (!rgbFace.is_none()) {
52+
if (gc.forced_alpha || rgbFace.cast<py::sequence>().size() == 3) {
53+
face.a = gc.alpha;
54+
}
5455
}
5556

5657
self->draw_path(gc, path, trans, face);
@@ -80,12 +81,13 @@ PyRendererAgg_draw_markers(RendererAgg *self,
8081
agg::trans_affine marker_path_trans,
8182
mpl::PathIterator path,
8283
agg::trans_affine trans,
83-
py::object face_obj)
84+
py::object rgbFace)
8485
{
85-
agg::rgba face;
86-
87-
if (!convert_face(face_obj.ptr(), gc, &face)) {
88-
throw py::error_already_set();
86+
agg::rgba face = rgbFace.cast<agg::rgba>();
87+
if (!rgbFace.is_none()) {
88+
if (gc.forced_alpha || rgbFace.cast<py::sequence>().size() == 3) {
89+
face.a = gc.alpha;
90+
}
8991
}
9092

9193
self->draw_markers(gc, marker_path, marker_path_trans, path, trans, face);

src/py_converters.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -489,21 +489,6 @@ int convert_gcagg(PyObject *pygc, void *gcp)
489489
return 1;
490490
}
491491

492-
int convert_face(PyObject *color, GCAgg &gc, agg::rgba *rgba)
493-
{
494-
if (!convert_rgba(color, rgba)) {
495-
return 0;
496-
}
497-
498-
if (color != NULL && color != Py_None) {
499-
if (gc.forced_alpha || PySequence_Size(color) == 3) {
500-
rgba->a = gc.alpha;
501-
}
502-
}
503-
504-
return 1;
505-
}
506-
507492
int convert_points(PyObject *obj, void *pointsp)
508493
{
509494
numpy::array_view<double, 2> *points = (numpy::array_view<double, 2> *)pointsp;

src/py_converters.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ int convert_points(PyObject *pygc, void *pointsp);
4141
int convert_transforms(PyObject *pygc, void *transp);
4242
int convert_bboxes(PyObject *pygc, void *bboxp);
4343
int convert_colors(PyObject *pygc, void *colorsp);
44-
45-
int convert_face(PyObject *color, GCAgg &gc, agg::rgba *rgba);
4644
}
4745

4846
#endif

0 commit comments

Comments
 (0)