Exemplo n.º 1
0
    def test_init_color(self):
        """
        Test of giving random content to the color instance.
        """

        random.seed()
        for _ in xrange(20):
            L = random.randint(0, 100)
            a = random.randint(-255, 255)
            b = random.randint(-255, 255)
            col = Color(L, a, b)
            self.assertEqual(col.get_values(), [L, a, b])
Exemplo n.º 2
0
    def test_init_color(self):
        """
        Test of giving random content to the color instance.
        """

        random.seed()
        for _ in xrange(20):
            L = random.randint(0, 100)
            a = random.randint(-255, 255)
            b = random.randint(-255, 255)
            col = Color(L, a, b)
            self.assertEqual(col.get_values(), [L, a, b])
Exemplo n.º 3
0
    def test_distance(self):
        """
        similar color
        """
        for _ in xrange(20):
            L = random.randint(0, 100)
            a = random.randint(-255, 255)
            b = random.randint(-255, 255)
            col = Color(L, a, b)
            self.assertTrue(col.distance(col) == 0.)

        a = Color(5, 3, 3)
        b = Color(6, 1, -1)
        self.assertTrue(math.fabs(a.distance(b) - 4.58257) < 0.00001)
Exemplo n.º 4
0
    def test_distance(self):
        """
        similar color
        """
        for _ in xrange(20):
            L = random.randint(0, 100)
            a = random.randint(-255, 255)
            b = random.randint(-255, 255)
            col = Color(L, a, b)
            self.assertTrue(col.distance(col) == 0.)

        a = Color(5, 3, 3)
        b = Color(6, 1, -1)
        self.assertTrue(math.fabs(a.distance(b) - 4.58257) < 0.00001)
Exemplo n.º 5
0
 def parse_munsell_chip(self, chip):
     L = float(chip.getElementsByTagName("L")[0].firstChild.data)
     a = float(chip.getElementsByTagName("a")[0].firstChild.data)
     b = float(chip.getElementsByTagName("b")[0].firstChild.data)
     return Color(L, a, b)