本文整理汇总了Python中lib.buffer_utils.BufferUtils.get_buffer_address方法的典型用法代码示例。如果您正苦于以下问题:Python BufferUtils.get_buffer_address方法的具体用法?Python BufferUtils.get_buffer_address怎么用?Python BufferUtils.get_buffer_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.buffer_utils.BufferUtils
的用法示例。
在下文中一共展示了BufferUtils.get_buffer_address方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_command_list
# 需要导入模块: from lib.buffer_utils import BufferUtils [as 别名]
# 或者: from lib.buffer_utils.BufferUtils import get_buffer_address [as 别名]
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: setup
# 需要导入模块: from lib.buffer_utils import BufferUtils [as 别名]
# 或者: from lib.buffer_utils.BufferUtils import get_buffer_address [as 别名]
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: get
# 需要导入模块: from lib.buffer_utils import BufferUtils [as 别名]
# 或者: from lib.buffer_utils.BufferUtils import get_buffer_address [as 别名]
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
示例4: get
# 需要导入模块: from lib.buffer_utils import BufferUtils [as 别名]
# 或者: from lib.buffer_utils.BufferUtils import get_buffer_address [as 别名]
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
示例5: setup
# 需要导入模块: from lib.buffer_utils import BufferUtils [as 别名]
# 或者: from lib.buffer_utils.BufferUtils import get_buffer_address [as 别名]
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
示例6: setPixelHLS
# 需要导入模块: from lib.buffer_utils import BufferUtils [as 别名]
# 或者: from lib.buffer_utils.BufferUtils import get_buffer_address [as 别名]
def setPixelHLS(self, location, color):
x, y = BufferUtils.get_buffer_address(self._mixer._app, location)
self._pixel_buffer[x][y] = color
示例7: setp
# 需要导入模块: from lib.buffer_utils import BufferUtils [as 别名]
# 或者: from lib.buffer_utils.BufferUtils import get_buffer_address [as 别名]
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