Exemplo n.º 1
0
    def test_create_green_gradient_image_frame_message(self):
        size = (10, 2)
        color = (0, 255, 0)
        image = ImageFactory.generate_gradient_image(size, color)

        message = MessageFactory.create_display_frame_message(image)

        self.assertEqual(message, '{"command": {"display_frame": {"mode": "RGB", "pixels": "AAAAABkAADMAAEwAAGYAAH8AAJkAALIAAMwAAOUAAAAAABkAADMAAEwAAGYAAH8AAJkAALIAAMwA\\nAOUA\\n", "size": [10, 2]}}}')
Exemplo n.º 2
0
    def test_create_red_image_frame_message(self):
        size = (8, 8)
        color = (255, 0, 0)
        image = ImageFactory.generate_gradient_image(size, color)

        message = MessageFactory.create_display_frame_message(image)

        self.assertEqual(message, '{"command": {"display_frame": {"mode": "RGB", "pixels": "AAAAHwAAPwAAXwAAfwAAnwAAvwAA3wAAAAAAHwAAPwAAXwAAfwAAnwAAvwAA3wAAAAAAHwAAPwAA\\nXwAAfwAAnwAAvwAA3wAAAAAAHwAAPwAAXwAAfwAAnwAAvwAA3wAAAAAAHwAAPwAAXwAAfwAAnwAA\\nvwAA3wAAAAAAHwAAPwAAXwAAfwAAnwAAvwAA3wAAAAAAHwAAPwAAXwAAfwAAnwAAvwAA3wAAAAAA\\nHwAAPwAAXwAAfwAAnwAAvwAA3wAA\\n", "size": [8, 8]}}}')
    def test_create_green_image_from_string(self):
        image = ImageFactory.generate_gradient_image((8, 8), (0, 255, 0))
        (data, size, mode) = TestImageFactory.get_image_data(image)

        image_from_string = ImageFactory.create_image_from_string(
            mode, size, data)

        self.assertEqual(image, image_from_string)
Exemplo n.º 4
0
    def test_send_image_frame_from_client_to_server(self):
        size = (6, 9)
        color = (0, 255, 0)
        image = ImageFactory.generate_gradient_image(size, color)

        reactor.callLater(1, self.client.send_image_frame, image)
        reactor.run()

        self.assertEqual(self.device.image, image)
def test_random_images():
    display_size = (8, 8)
    max_luminance = 10
    device = Ws281xDevice(display_size, max_luminance)
    green = (0, 255, 0)
    image = ImageFactory.generate_gradient_image(display_size, green)

    while True:
        #fill_image_uniformly(image)
        #fill_image_randomly(image)
        #fill_image_increasingly(image)
        device.display_frame(image)
        time.sleep(1/30.)