Exemple #1
0
def _compute_hsb_h(m1, c, eps, r, g, b):
    if c < eps:
        return 0
    elif m1 == r:
        return mod(((g - b) / c), 6.)
    elif m1 == g:
        return (b - r) / c + 2.
    elif m1 == b:
        return (r - g) / c + 4.
Exemple #2
0
def _compute_hsb_h(m1, c, eps, r, g, b):
    if c < eps:
        return 0
    elif m1 == r:
        return mod(((g - b) / c), 6.)
    elif m1 == g:
        return (b - r) / c + 2.
    elif m1 == b:
        return (r - g) / c + 4.
Exemple #3
0
def hsb_to_rgb(h, s, v, *rest):
    i = floor(6 * h)
    f = 6 * h - i
    i = mod(i, 6)
    p = v * (1 - s)
    q = v * (1 - f * s)
    t = v * (1 - (1 - f) * s)

    r, g, b = choose(i, (v, t, p), (q, v, p), (p, v, t), (p, q, v), (t, p, v),
                     (v, p, q))

    return (r, g, b) + rest
Exemple #4
0
def hsb_to_rgb(h, s, v, *rest):
    i = floor(6 * h)
    f = 6 * h - i
    i = mod(i, 6)
    p = v * (1 - s)
    q = v * (1 - f * s)
    t = v * (1 - (1 - f) * s)

    r, g, b = choose(i,
        (v, t, p),
        (q, v, p),
        (p, v, t),
        (p, q, v),
        (t, p, v),
        (v, p, q))

    return (r, g, b) + rest
Exemple #5
0
 def testMod(self):
     self.assertEqualArrays(
         mod(array([[10, 20], [30, 40]]), [[7, 7], [7, 7]]),
         [[3, 6], [2, 5]])
 def testMod(self):
     self.assertEqualArrays(mod(array([[10, 20], [30, 40]]), [[7, 7], [7, 7]]), [[3, 6], [2, 5]])