Exemple #1
0
 def test_create_from_file(self):
     c = ColorChooser.createFromDefinition("resources/colortest.txt")
     self.assertEqual(len(c._colorList), 3)
     self.assertEqual(c.findColor("First Color"), (255, 0, 0))
     self.assertEqual(c.findColor("Other Color"), (0, 255, 0))
     self.assertEqual(c.findColor("Third Color"), (0, 0, 255))
     self.assertEqual(c.currentColor(), (255, 0, 0))
     self.assertEqual(c.nextColor(), (0, 255, 0))
     self.assertEqual(c.nextColor(), (0, 0, 255))
Exemple #2
0
 def __init__(self, item:Item, location:tuple, width:int, height:int,
              color:tuple, fontName:str, speedInPxPerSec:float):
     GridSprite.__init__(self, item.position,
                         pygame.Rect(location[0], location[1], width, height),
                         speedInPxPerSec)
     self.item = item
     self.backgroundColor = color
     self.fontName = fontName
     self.fontColor = (0, 0, 0)
     if ColorChooser.isDarkColor(self.backgroundColor):
         self.fontColor = (255, 255, 255)
     self.image = self.createBlock(self.rect, color, fontName, item)
Exemple #3
0
 def test_empty_chooser_random_color(self):
     c = ColorChooser()
     self.assertEqual(c.randomColor(), ColorChooser.DEFAULT_COLOR)
Exemple #4
0
 def test_read_hex_colors(self):
     line = "Red: #ff0000"
     result = ColorChooser.colorFromLine(line)
     self.assertNotEqual(result, None)
     self.assertEqual(result[0], "Red")
     self.assertEqual(result[1], (255, 0, 0))
Exemple #5
0
 def test_find_invalid_color(self):
     c = ColorChooser()
     self.assertEqual(c.findColor("invalid"), ColorChooser.DEFAULT_COLOR)
Exemple #6
0
 def test_interval(self):
     c = ColorChooser.createFromDefinition("resources/colortest.txt")
     self.assertEqual(c.currentColor(), (255, 0, 0))
     self.assertEqual(c.nextColor(2), (0, 0, 255))
Exemple #7
0
 def test_empty_chooser_find_color(self):
     c = ColorChooser()
     self.assertEqual(c.findColor("Red"), ColorChooser.DEFAULT_COLOR)
Exemple #8
0
 def test_empty_chooser_next_color(self):
     c = ColorChooser()
     self.assertEqual(c.nextColor(), ColorChooser.DEFAULT_COLOR)
     self.assertEqual(c.nextColor(), ColorChooser.DEFAULT_COLOR)
Exemple #9
0
 def _loadColors(self, skinPath:str, colorFileName:str):
     return ColorChooser.createFromDefinition(os.path.join(skinPath, colorFileName))