Beispiel #1
0
 def test_imageFallbackBackgroundColor(self):
     self.makeTestDrawing()
     with TempFile(suffix=".jpg") as tmp:
         drawBot.saveImage(tmp.path, imageJPEGCompressionFactor=1.0)
         self.assertEqual(drawBot.imagePixelColor(tmp.path, (5, 5)), (1.0, 1.0, 1.0, 1.0))
     with TempFile(suffix=".jpg") as tmp:
         drawBot.saveImage(tmp.path, imageJPEGCompressionFactor=1.0, imageFallbackBackgroundColor=(0, 1, 0))
         r, g, b, a = drawBot.imagePixelColor(tmp.path, (5, 5))
         self.assertEqual((round(r, 2), round(g, 2), round(b, 2)), (0, 1.0, 0))
     with TempFile(suffix=".jpg") as tmp:
         drawBot.saveImage(tmp.path, imageJPEGCompressionFactor=1.0, imageFallbackBackgroundColor=AppKit.NSColor.redColor())
         r, g, b, a = drawBot.imagePixelColor(tmp.path, (5, 5))
         self.assertEqual((round(r, 2), round(g, 2), round(b, 2)), (1, 0.0, 0))
Beispiel #2
0
 def getPixelColor(self, p, scaled=True):
     u"""Answer the color in either the scaled point (x, y) or original image size point."""
     assert self.path is not None
     x, y = point2D(p)
     if scaled:
         x = self.w / self.iw
         y = self.h / self.ih
     return imagePixelColor(self.path, (x, y))
Beispiel #3
0
def mockImagePixelColor(path, xy):
    return drawBot.imagePixelColor(mockedImagePath, xy)
Beispiel #4
0
def mockImagePixelColor(path, xy):
    return drawBot.imagePixelColor(mockedImagePath, xy)