FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fixed exception when drawing colored edges on OSX · matplotlib/matplotlib@02f8a65 · GitHub

Repository navigation

Commit 02f8a65

Browse files
committed
Fixed exception when drawing colored edges on OSX
1 parent 4db17d1 commit 02f8a65

2 files changed

Lines changed: 31 additions & 13 deletions

File tree

‎lib/matplotlib/backends/backend_macosx.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
8484

8585
def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
8686
coordinates, offsets, offsetTrans, facecolors,
87-
antialiased, showedges):
87+
antialiased, edgecolors):
8888
cliprect = gc.get_clip_rectangle()
8989
clippath, clippath_transform = gc.get_clip_path()
9090
gc.draw_quad_mesh(master_transform,
@@ -98,7 +98,7 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
9898
offsetTrans,
9999
facecolors,
100100
antialiased,
101-
showedges)
101+
edgecolors)
102102

103103
def new_gc(self):
104104
self.gc.save()

‎src/_macosx.m‎

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
16521652
PyObject* offset_transform;
16531653
PyObject* facecolors;
16541654
int antialiased;
1655-
int showedges;
1655+
PyObject* edgecolors;
16561656

16571657
CGContextRef cr = self->cr;
16581658

@@ -1662,7 +1662,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
16621662
return NULL;
16631663
}
16641664

1665-
if(!PyArg_ParseTuple(args, "OOOOiiOOOOii",
1665+
if(!PyArg_ParseTuple(args, "OOOOiiOOOOiO",
16661666
&master_transform,
16671667
&cliprect,
16681668
&clippath,
@@ -1674,7 +1674,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
16741674
&offset_transform,
16751675
&facecolors,
16761676
&antialiased,
1677-
&showedges)) return NULL;
1677+
&edgecolors)) return NULL;
16781678

16791679
int ok = 1;
16801680
CGContextSaveGState(cr);
@@ -1777,7 +1777,9 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
17771777

17781778
size_t Npaths = meshWidth * meshHeight;
17791779
size_t Nfacecolors = (size_t) PyArray_DIM(facecolors, 0);
1780-
if ((Nfacecolors == 0 && !showedges) || Npaths == 0)
1780+
size_t Nedgecolors = (size_t) PyArray_DIM(edgecolors, 0);
1781+
1782+
if ((Nfacecolors == 0 && Nedgecolors == 0) || Npaths == 0)
17811783
{
17821784
/* Nothing to do here */
17831785
goto exit;
@@ -1797,17 +1799,18 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
17971799
const double b = *(double*)PyArray_GETPTR2(facecolors, 0, 2);
17981800
const double a = *(double*)PyArray_GETPTR2(facecolors, 0, 3);
17991801
CGContextSetRGBFillColor(cr, r, g, b, a);
1800-
if (antialiased && !showedges)
1802+
if (antialiased && Nedgecolors == 0)
18011803
{
18021804
CGContextSetRGBStrokeColor(cr, r, g, b, a);
18031805
}
18041806
}
18051807

1806-
if (showedges)
1808+
if (Nedgecolors == 0)
18071809
{
1808-
CGContextSetRGBStrokeColor(cr, 0, 0, 0, 1);
1810+
edgecolors = facecolors;
18091811
}
18101812

1813+
18111814
double x, y;
18121815
for (ih = 0; ih < meshHeight; ih++)
18131816
{
@@ -1854,15 +1857,30 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
18541857
CGContextAddLines(cr, points, 4);
18551858
CGContextClosePath(cr);
18561859

1860+
if (Nedgecolors > 0)
1861+
{
1862+
npy_intp ei = i % Nedgecolors;
1863+
const double e_r = *(double*)PyArray_GETPTR2(edgecolors, ei, 0);
1864+
const double e_g = *(double*)PyArray_GETPTR2(edgecolors, ei, 1);
1865+
const double e_b = *(double*)PyArray_GETPTR2(edgecolors, ei, 2);
1866+
const double e_a = *(double*)PyArray_GETPTR2(edgecolors, ei, 3);
1867+
1868+
CGContextSetRGBStrokeColor(cr, e_r, e_g, e_b, e_a);
1869+
}
1870+
else
1871+
{
1872+
CGContextSetRGBStrokeColor(cr, 0, 0, 0, 1);
1873+
}
1874+
18571875
if (Nfacecolors > 1)
18581876
{
18591877
npy_intp fi = i % Nfacecolors;
18601878
const double r = *(double*)PyArray_GETPTR2(facecolors, fi, 0);
18611879
const double g = *(double*)PyArray_GETPTR2(facecolors, fi, 1);
18621880
const double b = *(double*)PyArray_GETPTR2(facecolors, fi, 2);
18631881
const double a = *(double*)PyArray_GETPTR2(facecolors, fi, 3);
1864-
CGContextSetRGBFillColor(cr, r, g, b, a);
1865-
if (showedges)
1882+
1883+
if (Nedgecolors > 0)
18661884
{
18671885
CGContextDrawPath(cr, kCGPathFillStroke);
18681886
}
@@ -1878,7 +1896,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
18781896
}
18791897
else if (Nfacecolors==1)
18801898
{
1881-
if (showedges || antialiased)
1899+
if (Nedgecolors > 0 || antialiased)
18821900
{
18831901
CGContextDrawPath(cr, kCGPathFillStroke);
18841902
}
@@ -1887,7 +1905,7 @@ static BOOL _clip(CGContextRef cr, PyObject* object)
18871905
CGContextFillPath(cr);
18881906
}
18891907
}
1890-
else if (showedges)
1908+
else if (Nedgecolors > 0)
18911909
{
18921910
CGContextStrokePath(cr);
18931911
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL