def getColorAt(self, point): """ Return the color of the specified point. Returns None if the specified point is outside the triangle boundries. """ alpha, beta, gamma = self.calcBarycentricCoordinates(point) # Point it outside the triangle; However, because if we assume we are already # are using triangle.iterPoints to iterate through all the points in the # triangle, we can safely set the negative values to 0, which has the side # effect of removing the clipping. if (alpha < 0): alpha = 0.0 if (beta < 0): beta = 0.0 if (gamma < 0): gamma = 0.0 if (alpha > 1): alpha = 1.0 if (beta > 1): beta = 1.0 if (gamma > 1): gamma = 1.0 #if (alpha < 0) or (beta < 0) or (gamma < 0): # return None # Calculate the new blended color p1cBlend = color.darken(self.p1c, alpha) p2cBlend = color.darken(self.p2c, beta) p3cBlend = color.darken(self.p3c, gamma) return color.blend(color.blend(p1cBlend, p2cBlend), p3cBlend)
def __call__(self, time, delta): frame = self.source(time, delta) period = color.get(self.period, time, delta) velocity = delta / period self.position += velocity #**** INCOMPLETE. NEEDS TO ADDRESS LEAVES AND FISSURES **** #cubes cubes=frame[0] resolution = len(cubes) c=[] for i in range(len(cubes)): c.append([]) for j in range(len(cubes[i])): if j<constants.HEIGHT_INNER: fpart, pos = math.modf(self.position) fpart = abs(fpart) if(self.position < 0): fpart = 1.0 - fpart cur = int(pos + i) % resolution next = int(cur + 1) % resolution else: #The topmost cubes on the outer shell need special handling fpart, pos = math.modf(self.position) fpart = abs(fpart) if(self.position < 0): fpart = 1.0 - fpart cur = int(pos + i) % resolution next = int(int((int(cur + 1) % resolution)/2)*2) cur=int(int(cur/2)*2) c[i].append([]) for k in range(len(cubes[i][j])): c[i][j].append([]) color1=cubes[cur][j][k] color2=cubes[next][j][k] c[i][j][k]=color.blend(color1, color2, abs(fpart)) #leaves #fissures return [c,frame[1],frame[2]]
def run(self, screen): screen.fill(self.backcolor) # The selected thing is at the center # text is centered i = 0 for entry in self.options: slot = i - self.selected tone = color.blend(self.textcolor, self.backcolor, self.fade * abs(slot)) if (slot == 0): font = self.selected_font else: font = self.unselected_font label = font.render(entry["name"], True, tone) (x, y) = self.centering(label, screen) lineheight = font.get_height() + 4 screen.blit(label, (4, y + lineheight * slot)) i += 1 return not self.stop
def __call__(self, time, delta): period = color.get(self.period, time, delta) period = period/self.numBeads velocity = delta / period #velocity = period / self.numBeads self.position += velocity fpart, pos = math.modf(self.position) #fpart = abs(fpart) #if(self.position < 0): # fpart = 1.0 - fpart iBead=int(pos)%self.numBeads r=[] for z in range(constants.CUBE_DEPTH): bead1=self.beads[iBead%self.numBeads] bead2=self.beads[(iBead+1)%self.numBeads] r.append(color.blend(bead1,bead2,fpart)) #r.append(self.beads[iBead%self.numBeads]) iBead+=1 return r
def get(self): progress = min((self.timer() - self.start) / self.t, 1) if (progress < 1): return color.blend(self.a, self.b, progress) else: return self.b