def OnUpdateColorBlue(self, delta): r, g, b = utils.ColorToRGB( channels.getChannelColor(channels.selectedChannel())) b = self.clip(0, 255, b + delta) channels.setChannelColor(channels.selectedChannel(), utils.RGBToColor(r, g, b)) self._controller.encoders().Refresh()
def getClosestColor(color): # TODO Create and send custom color palette to Push to match the colors in the FL project (https://github.com/Ableton/push-interface/issues/2) # http://www.shodor.org/stella2java/rgbint.html # def Int2RGBA(Int): # blue = Int & 255 # green = (Int >> 8) & 255 # red = (Int >> 16) & 255 # alpha = (Int >> 24) & 255 # return red, green, blue, alpha # # def RGBA2Int(RGBA): # red = RGBA[0] # green = RGBA[1] # blue = RGBA[2] # alpha = RGBA[3] # Int = (alpha<<24) + (red<<16) + (green<<8) + blue # return Int RGB = utils.ColorToRGB(color) R1 = RGB[0] G1 = RGB[1] B1 = RGB[2] d = {} # https://stackoverflow.com/questions/1847092/given-an-rgb-value-what-would-be-the-best-way-to-find-the-closest-match-in-the-d # https://matplotlib.org/api/colors_api.html for color, RGB in COLORS.RGB_MAP.items(): R2 = RGB[0] G2 = RGB[1] B2 = RGB[2] d[color] = (R2 - R1)**2 + (G2 - G1)**2 + (B2 - B1)**2 return min(d, key=d.get)
def get_color_red_line(): r, g, b = utils.ColorToRGB(channels.getChannelColor(channels.selectedChannel())) return '[%3d] %3d %3d ' % (r, g, b)
def get_color_blue_line(): r, g, b = utils.ColorToRGB(channels.getChannelColor(channels.selectedChannel())) return ' %3d %3d [%3d]' % (r, g, b)
def OnUpdateColorBlue(self, delta): r, g, b = utils.ColorToRGB(channels.getChannelColor(channels.selectedChannel())) b = self.clip(0, 255, b + delta) channels.setChannelColor(channels.selectedChannel(), utils.RGBToColor(r, g, b))