aboutsummaryrefslogtreecommitdiff
path: root/util/ColorOps.py
blob: 88a58a7d7740f99bcf17cd1ed251c4fb63e9dd9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import random
def randomColor():
    return [random.randint(0,255) for i in range(3)]
def chooseRandomColor(colorList):
    return random.choice(colorList)
def safeColor(c):
    return [min(channel,255) for channel in c]
def combineColors(c1,c2):
    return safeColor([c1[i]+c2[i] for i in range(min(len(c1),len(c2)))])
def fastMultiply(color, percent, acc=100):
    percent = int(percent*acc)
    color = colorToInt(color)
    color = [channel*percent for channel in color]

def colorToInt(color):
    return [int(channel) for channel in color]
def multiplyColor(color, percent):
    
    return safeColor([channel*(percent) for channel in color])