text stringlengths 0 828 |
|---|
else: |
return surface |
if 'x_center' not in df_shapes or 'y_center' not in df_shapes: |
# No center points have been computed for shapes. |
return surface |
cairo_context = cairo.Context(surface) |
df_shapes = df_shapes.copy() |
# Scale shapes to leave shape edges uncovered. |
df_shapes[['x', 'y']] = (df_shapes[['x_center', 'y_center']] + |
df_shapes[['x_center_offset', |
'y_center_offset']].values * |
shape_scale) |
for path_id, df_path_i in (df_shapes.groupby(self.canvas |
.shape_i_columns)[['x', |
'y']]): |
# Use attribute lookup for `x` and `y`, since it is considerably |
# faster than `get`-based lookup using columns name strings. |
vertices_x = df_path_i.x.values |
vertices_y = df_path_i.y.values |
cairo_context.move_to(vertices_x[0], vertices_y[0]) |
for x, y in itertools.izip(vertices_x[1:], vertices_y[1:]): |
cairo_context.line_to(x, y) |
cairo_context.close_path() |
# Draw filled shape to indicate actuated electrode state. |
cairo_context.set_source_rgba(*fill) |
cairo_context.fill() |
return surface" |
4314,"def render_shapes(self, df_shapes=None, clip=False): |
''' |
Render static electrode shapes (independent of actuation state). |
If video is enabled, draw white outline for each electrode (no fill). |
If video is disabled, draw white outline for each electrode and fill |
blue. |
See also :meth:`render_electrode_state_shapes()`. |
''' |
surface = self.get_surface() |
if df_shapes is None: |
if hasattr(self.canvas, 'df_canvas_shapes'): |
df_shapes = self.canvas.df_canvas_shapes |
else: |
return surface |
cairo_context = cairo.Context(surface) |
for path_id, df_path_i in (df_shapes |
.groupby(self.canvas |
.shape_i_columns)[['x', 'y']]): |
# Use attribute lookup for `x` and `y`, since it is considerably |
# faster than `get`-based lookup using columns name strings. |
vertices_x = df_path_i.x.values |
vertices_y = df_path_i.y.values |
cairo_context.move_to(vertices_x[0], vertices_y[0]) |
for x, y in itertools.izip(vertices_x[1:], vertices_y[1:]): |
cairo_context.line_to(x, y) |
cairo_context.close_path() |
if self.enabled: |
# Video is enabled. |
# Draw white border around electrode. |
line_width = 1 |
if path_id not in self.electrode_channels.index: |
# on off on off |
dashes = [10, 10] |
color = (1, 0, 1) |
line_width *= 2 |
else: |
dashes = [] |
color = (1, 1, 1) |
cairo_context.set_dash(dashes) |
cairo_context.set_line_width(line_width) |
cairo_context.set_source_rgb(*color) |
cairo_context.stroke() |
else: |
# Video is enabled. Fill electrode blue. |
color = ((0, 0, 1) if path_id in self.electrode_channels.index |
else (1, 0, 1)) |
cairo_context.set_source_rgb(*color) |
cairo_context.fill_preserve() |
# Draw white border around electrode. |
cairo_context.set_line_width(1) |
cairo_context.set_source_rgba(1, 1, 1) |
cairo_context.stroke() |
return surface" |
4315,"def render_registration(self): |
''' |
Render pinned points on video frame as red rectangle. |
''' |
surface = self.get_surface() |
if self.canvas is None or self.df_canvas_corners.shape[0] == 0: |
return surface |
corners = self.df_canvas_corners.copy() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.