示例#1
0
    def render_command_list(self, list, buffer):
        """
        Renders the output of a command list to the output buffer.
        Commands are rendered in FIFO overlap style.  Run the list through
        filter_and_sort_commands() beforehand.
        If the output buffer is not zero (black) at a command's target,
        the output will be additively blended according to the blend_state
        (0.0 = 100% original, 1.0 = 100% new)
        """
        for command in list:
            color = command.get_color()
            if isinstance(command, SetAll):
                buffer[:,:] = color

            elif isinstance(command, SetStrand):
                strand = command.get_strand()
                buffer[strand,:] = color

            elif isinstance(command, SetFixture):
                strand = command.get_strand()
                address = command.get_address()
                _, start = BufferUtils.get_buffer_address(self._app, (strand, address, 0))
                end = start + self._scene.fixture(strand, address).pixels
                buffer[strand,start:end] = color

            elif isinstance(command, SetPixel):
                strand = command.get_strand()
                address = command.get_address()
                pixel = command.get_pixel()
                (strand, pixel_offset) = BufferUtils.get_buffer_address(self._app, (strand, address, pixel))
                buffer[strand][pixel_offset] = color
示例#2
0
    def setup(self):
        self.reset()

        self.pixel_locations = self._app.scene.get_all_pixel_locations()
        self.pixel_addr = {}
        for pixel, _ in self.pixel_locations:
            self.pixel_addr[pixel] = BufferUtils.get_buffer_address(self._app, pixel)
示例#3
0
    def setup(self):
        self.num_strands, self.num_pixels = BufferUtils.get_buffer_size(
            self._app)

        self.scene_bb = self._app.scene.get_fixture_bounding_box()
        self.scene_center = (self.scene_bb[0] +
                             (self.scene_bb[2] - self.scene_bb[0]) / 2,
                             self.scene_bb[1] +
                             (self.scene_bb[3] - self.scene_bb[1]) / 2)
        dx = self.scene_bb[2] - self.scene_center[0]
        dy = self.scene_bb[3] - self.scene_center[1]
        self.scene_radius = sqrt(pow(dx, 2) + pow(dy, 2))

        self.locations = self._app.scene.get_all_pixel_locations()
        self.buffer_addr = {}
        self.angles = {}
        self.radii = {}
        for pixel, location in self.locations:
            self.buffer_addr[pixel] = BufferUtils.get_buffer_address(
                self._app, pixel)
            dy = location[1] - self.scene_center[1]
            dx = location[0] - self.scene_center[0]
            angle = (atan2(dy, dx) + pi) / (2.0 * pi)
            self.radii[pixel] = sqrt(pow(dx, 2) + pow(dy, 2))
            self.angles[pixel] = angle
示例#4
0
    def get(self, start, end, progress):

        for strand, address, pixel, location in self.locations:
            dy = math.fabs(location[1] - self.scene_center[1])
            dx = math.fabs(location[0] - self.scene_center[0])
            if math.sqrt(math.pow(dx,2) + math.pow(dy, 2)) < (self.radius * progress):
                _, pixel = BufferUtils.get_buffer_address(self._app, (strand, address, pixel))
                self.mask[strand][pixel][:] = True

        start[self.mask] = 0.0
        end[np.invert(self.mask)] = 0.0
        return start + end
示例#5
0
    def get(self, start, end, progress):

        for strand, address, pixel, location in self.locations:
            dy = math.fabs(location[1] - self.scene_center[1])
            dx = math.fabs(location[0] - self.scene_center[0])
            if math.sqrt(math.pow(dx, 2) + math.pow(dy, 2)) < (self.radius *
                                                               progress):
                _, pixel = BufferUtils.get_buffer_address(
                    self._app, (strand, address, pixel))
                self.mask[strand][pixel][:] = True

        start[self.mask] = 0.0
        end[np.invert(self.mask)] = 0.0
        return start + end
示例#6
0
    def get(self, start, end, progress):
        """
        Simple wipe
        """
        # Move the wipe point along the wipe line
        wipe_point = self.wipe_start + (progress * self.wipe_line_vector)

        # Mask based on the wipe point
        for strand, address, pixel, location in self.locations:
            if np.dot(location - wipe_point, self.wipe_vector) < 0:
                _, pixel = BufferUtils.get_buffer_address(self._app, (strand, address, pixel))
                self.mask[strand][pixel][:] = True

        start[self.mask] = 0.0
        end[np.invert(self.mask)] = 0.0
        return start + end
示例#7
0
文件: spiral.py 项目: bhitov/firemix
    def setup(self):
        self.num_strands, self.num_pixels = BufferUtils.get_buffer_size(self._app)

        self.scene_bb = self._app.scene.get_fixture_bounding_box()
        self.scene_center = (self.scene_bb[0] + (self.scene_bb[2] - self.scene_bb[0]) / 2, self.scene_bb[1] + (self.scene_bb[3] - self.scene_bb[1]) / 2)
        dx = self.scene_bb[2] - self.scene_center[0]
        dy = self.scene_bb[3] - self.scene_center[1]
        self.scene_radius = sqrt(pow(dx,2) + pow(dy, 2))

        self.locations = self._app.scene.get_all_pixel_locations()
        self.buffer_addr = {}
        self.angles = {}
        self.radii = {}
        for pixel, location in self.locations:
            self.buffer_addr[pixel] = BufferUtils.get_buffer_address(self._app, pixel)
            dy = location[1] - self.scene_center[1]
            dx = location[0] - self.scene_center[0]
            angle = (atan2(dy, dx) + pi) / (2.0 * pi)
            self.radii[pixel] = sqrt(pow(dx,2) + pow(dy, 2))
            self.angles[pixel] = angle
示例#8
0
 def setPixelHLS(self, location, color):
     x, y = BufferUtils.get_buffer_address(self._mixer._app, location)
     self._pixel_buffer[x][y] = color
示例#9
0
 def setp(self, location, color):
     """
     Sets a pixel to a color
     """
     x, y = BufferUtils.get_buffer_address(self._mixer._app, location)
     self._pixel_buffer[x][y] = color
示例#10
0
 def setp(self, location, color):
     """
     Sets a pixel to a color
     """
     x, y = BufferUtils.get_buffer_address(self._mixer._app, location)
     self._pixel_buffer[x][y] = color