Example #1
0
	def clear_hex(self, colour):
		"""
		Clear the surface to a single colour
		"""
		# Make sure we never send a 1 by mistake and screw up the frames
		(r,g,b) = [ v if not v == 1 else 0 for v in ColourUtils.hexToTuple(colour) ]
		for x in range(0,self.total_pixels):
			self.pixels[x*3:(x+1)*3] = [r,g,b]
Example #2
0
	def draw_hex_pixel(self, x, y, colour):
		"""
		Set the value of the pixel at (x,y) to colour(#RRGGBB")
		"""
		# Make sure we never send a 1 by mistake and screw up the frames
		(r,g,b) = [ v if not v == 1 else 0 for v in ColourUtils.hexToTuple(colour) ]
		pos = self.layout.get_position(x,y)
		if pos is not None:
			mapped_pixel = 3 * pos
			self.pixels[mapped_pixel:mapped_pixel+3] = [r,g,b]
Example #3
0
def hexToFloatTuple(hexString):
    (r, g, b) = ColourUtils.hexToTuple(hexString)
    rf = r / float(255)
    gf = g / float(255)
    bf = b / float(255)
    return (rf, gf, bf)