Exemplo n.º 1
0
 def testRegress(self):
     c = Color.fromRgb8(16, 78, 139)
     self.assertEquals(c.getRed8(), 16)
     self.assertEquals(c.getGreen8(), 78)
     self.assertEquals(c.getBlue8(), 139)
     self.assertEquals(c.toRgb8Str(), "16,78,139")
     self.assertEquals(c.toHsvIntStr(), "210,88,55")
     self.assertEquals(c.toHtmlColor(), "#104e8b")
Exemplo n.º 2
0
 def testRealRgb(self):
     c = Color.fromRgb(0.5, 0.3, 0.4)
     self.assertRgb(c, 0.5, 0.3, 0.4)
     self.assertRgb(c.setRed(0), 0.0, 0.3, 0.4)
     self.assertRgb(c.setGreen(1.0), 0.5, 1.0, 0.4)
     self.assertRgb(c.setBlue(0.2), 0.5, 0.3, 0.2)
     rgb = c.getRgb()
     self.assertAlmostEquals(rgb[0], 0.5)
     self.assertAlmostEquals(rgb[1], 0.3)
     self.assertAlmostEquals(rgb[2], 0.4)
     self.assertEquals(c.getRgb8(), (128, 77, 102))
     self.assertHsv(c, 0.9166666666, 0.4, 0.5)
     self.assertHsv(c.setHue(0.2), 0.2, 0.4, 0.5)
     self.assertHsv(c.setSaturation(0.2), 0.9166666666, 0.2, 0.5)
     self.assertHsv(c.setValue(1.0), 0.9166666666, 0.4, 1.0)
     hsv = c.getHsv()
     self.assertAlmostEquals(hsv[0], 0.9166666666)
     self.assertAlmostEquals(hsv[1], 0.4)
     self.assertAlmostEquals(hsv[2], 0.5)
     self.assertEquals(c.getHsvInt(), (330, 40, 50))
     self.assertEquals(c.toHtmlColor(), "#804d66")
Exemplo n.º 3
0
def mkColor(s):
    return Color.fromHtmlColor(s)
Exemplo n.º 4
0
def _mkcolor(rgb8):
    return Color.fromPackRgb8(rgb8)