예제 #1
0
def mix(color, color1, weight=Pr(50)):
    """Mixes two colors together"""

    p = weight.value / 100.0
    w = p * 2 - 1
    a = color.a - color1.a

    w1 = ((w if w * a == -1 else (w + a) / (1 + w * a)) + 1) / 2.0
    w2 = 1 - w1

    r = color.r * w1 + color1.r * w2
    g = color.g * w1 + color1.g * w2
    b = color.b * w1 + color1.b * w2

    a = color.a * p + color1.a * (1 - p)

    return Color(r, g, b, a)
예제 #2
0
def grayscale(color):
    """Converts a color to grayscale."""
    color = Color(color)
    color.s = 1
    return color
예제 #3
0
def spinin(color, value=Pr(10)):
    """Changes the hue of a color."""
    color = Color(color)
    color.h += value
    return color
예제 #4
0
def hsla(h, s, l, a):
    """Converts an Hsla(h, s, l) quadruplet into a color."""
    return Color.from_hsl(h, s, l, a)
예제 #5
0
def hsl(h, s, l):
    """Converts an Hsl(h, s, l) triplet into a color."""
    return Color.from_hsl(h, s, l)
예제 #6
0
def rgba(r, g, b, a):
    """Converts an Rgba(r, g, b, a) quadruplet into a color."""
    return Color(r, g, b, a)
예제 #7
0
def complement(color):
    """Returns the complement of a color."""
    color = Color(color)
    return color
예제 #8
0
def darken(color, value=Pr(10)):
    """Makes a color darker."""
    color = Color(color)
    color.l -= value
    return color
예제 #9
0
def fadeout(color, value=Pr(10)):
    """Add or change an alpha layer for any color value."""
    color = Color(color)
    color.a -= value
    return color
예제 #10
0
def grayscale(color):
    """Converts a color to grayscale."""
    color = Color(color)
    color.s = 1
    return color
예제 #11
0
def desaturate(color, value=Pr(10)):
    """Makes a color less saturated."""
    color = Color(color)
    color.s -= value
    return color
예제 #12
0
def rgb(r, g, b):
    """Converts an Rgb(r, g, b) triplet into a color."""
    return Color(r, g, b)
예제 #13
0
def saturate(color, value=Pr(10)):
    """Makes a color more saturated."""
    color = Color(color)
    color.s += value
    return color
예제 #14
0
def hsl(h, s, l):
    """Converts an Hsl(h, s, l) triplet into a color."""
    return Color.from_hsl(h, s, l)
예제 #15
0
def invert(color):
    """Returns the inverse of a color."""
    color = Color(color)
    return color
예제 #16
0
def hsla(h, s, l, a):
    """Converts an Hsla(h, s, l) quadruplet into a color."""
    return Color.from_hsl(h, s, l, a)
예제 #17
0
def lighten(color, value=Pr(10)):
    """Makes a color lighten."""
    color = Color(color)
    color.l += value
    return color