def __call__(self, x,y): z = (x * 0.0, y * 0.0) c = (x, y) if not InBulb(x,y): for i in xrange(self.its): z = cpl.c_add(cpl.c_mult(z,z), c) if abs(z[0]) >= 2.0 or abs(z[1]) >= 2.0: return [ 0,0 , int (255 * (float(i) / self.its))] return [0,0,0]
def populate(self): t0 = time.time() i = 0 while True: i = i + 1 if i % 1000 == 0: if time.time() - t0 > self.secs: return boxes = [] c = self.rect.rand() if InBulb(*c): continue z = (c[0] * 0.0, c[1] * 0.0) for i in xrange(self.its[-1]): z = cpl.c_add(cpl.c_mult(z,z), c) if abs(z[0]) >= 2.0 or abs(z[1]) >= 2.0: for px,py in boxes: for j in xrange(len(self.its)): if i < self.its[j]: self.data[px,py,j] += 1 break else: boxes.append(self.rect.real2pix(z[0], z[1], self.width, self.height))