pairs: allocate and manipulate dest polygon buffer directly

This commit is contained in:
KIU Shueng Chuan 2021-05-28 13:55:51 +08:00 committed by Ogi Moore
parent 8f4104a9ab
commit cabcf6cd29

View File

@ -1757,10 +1757,10 @@ def arrayToQPath(x, y, connect='all', finiteCheck=True):
if qt6: if qt6:
if n % 2 == 1: if n % 2 == 1:
arr = arr[:-1] arr = arr[:-1]
nans = np.broadcast_to(np.nan, (n // 2, 1)) polygon = create_qpolygonf(n // 2 * 3)
xs = np.column_stack([arr['x'].reshape((-1, 2)), nans]).ravel() dst = ndarray_from_qpolygonf(polygon).reshape((-1, 6)) # x0, y0, x1, y1, nan, nan
ys = np.column_stack([arr['y'].reshape((-1, 2)), nans]).ravel() dst[:, :4] = np.frombuffer(arr, dtype=np.double).reshape((-1, 4)) # x0, y0, x1, y1
polygon = arrayToQPolygonF(xs, ys) dst[:, 4:] = np.nan
path.addPolygon(polygon) path.addPolygon(polygon)
return path return path
else: else: