From: Bill Bumgarner <bbum@co...> - 2003-01-11 16:44:12
I added bridge code for NSRectFillList() in _AppKit.m. For
def drawRect_(self, aRect):
for pointArray, rectCount, color in self.pointsCountsAndColors:
self.pointsCountsAndColors = 
... where pointArray was created as ....
pointsArray = array.array('f', [0.0,0.0,1.0,1.0] * len(points))
rectCount = 0
for p in points:
x = int(round(p))
y = int(round(p))
if (x >= 0) and (x < pixelsWide) and (y >= 0) and (y <
pointsArray[ (rectCount * 4) ] = x
pointsArray[ (rectCount * 4) + 1 ] = y
rectCount += 1
... the rectCount argument is optional. In this case, I preallocate
the array to the maximum number of points and then count only the
points that fall within the bounds of the view.
In any case, this pattern of bridging is very, very fast and the
addition to _AppKit.m is quite straightforward.