예제 #1
0
def rgb_to_hsb(r, g, b, *rest):
    # see https://en.wikipedia.org/wiki/HSB_color_space. HSB is also known as HSV.
    r, g, b = _clip1((r, g, b))

    m1 = maximum(r, g, b)
    m0 = minimum(r, g, b)
    c = m1 - m0
    eps = 1e-15

    h = _compute_hsb_h(m1, c, eps, r, g, b)
    h = _wrap_hsb_h(h * (60. / 360.))
    s = _compute_hsb_s(m1, c, eps)

    return (h, s, m1) + rest
예제 #2
0
파일: colors.py 프로젝트: Piruzzolo/Mathics
def rgb_to_hsb(r, g, b, *rest):
    # see https://en.wikipedia.org/wiki/HSB_color_space. HSB is also known as HSV.
    r, g, b = _clip1((r, g, b))

    m1 = maximum(r, g, b)
    m0 = minimum(r, g, b)
    c = m1 - m0
    eps = 1e-15

    h = _compute_hsb_h(m1, c, eps, r, g, b)
    h = _wrap_hsb_h(h * (60. / 360.))
    s = _compute_hsb_s(m1, c, eps)

    return (h, s, m1) + rest
예제 #3
0
 def testMinimum(self):
     self.assertEqualArrays(
         minimum([[1, 2], [3, 4]], [[-1, 4], [-8, 5]], [[8, -4], [1, 10]]),
         [[-1, -4], [-8, 4]])
예제 #4
0
 def testMinimum(self):
     self.assertEqualArrays(minimum(
         [[1, 2], [3, 4]],
         [[-1, 4], [-8, 5]],
         [[8, -4], [1, 10]]), [[-1, -4], [-8, 4]])