本文整理汇总了Python中kivy.graphics.Mesh方法的典型用法代码示例。如果您正苦于以下问题:Python graphics.Mesh方法的具体用法?Python graphics.Mesh怎么用?Python graphics.Mesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.graphics
的用法示例。
在下文中一共展示了graphics.Mesh方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_path
# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Mesh [as 别名]
def draw_path(self, gc, path, transform, rgbFace=None):
'''Produce the rendering of the graphics elements using
:class:`kivy.graphics.Line` and :class:`kivy.graphics.Mesh` kivy
graphics instructions. The paths are converted into polygons and
assigned either to a clip rectangle or to the same canvas for
rendering. Paths are received in matplotlib coordinates. The
aesthetics is defined by the `GraphicsContextKivy` gc.
'''
if _mpl_ge_2_0:
polygons = path.to_polygons(transform, self.widget.width,
self.widget.height, closed_only=False)
else:
polygons = path.to_polygons(transform, self.widget.width,
self.widget.height)
list_canvas_instruction = self.get_path_instructions(gc, polygons,
closed=True, rgbFace=rgbFace)
for widget, instructions in list_canvas_instruction:
widget.canvas.add(instructions)
示例2: __init__
# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Mesh [as 别名]
def __init__(self, **kwargs):
super(Graph, self).__init__(**kwargs)
with self.canvas:
self._fbo = Fbo(size=self.size, with_stencilbuffer=self._with_stencilbuffer)
with self._fbo:
self._background_color = Color(*self.background_color)
self._background_rect = Rectangle(size=self.size)
self._mesh_ticks_color = Color(*self.tick_color)
self._mesh_ticks = Mesh(mode='lines')
self._mesh_rect_color = Color(*self.border_color)
self._mesh_rect = Mesh(mode='line_strip')
with self.canvas:
Color(1, 1, 1)
self._fbo_rect = Rectangle(size=self.size, texture=self._fbo.texture)
mesh = self._mesh_rect
mesh.vertices = [0] * (5 * 4)
mesh.indices = range(5)
self._plot_area = StencilView()
self.add_widget(self._plot_area)
t = self._trigger = Clock.create_trigger(self._redraw_all)
ts = self._trigger_size = Clock.create_trigger(self._redraw_size)
tc = self._trigger_color = Clock.create_trigger(self._update_colors)
self.bind(center=ts, padding=ts, precision=ts, plots=ts, x_grid=ts,
y_grid=ts, draw_border=ts)
self.bind(xmin=t, xmax=t, xlog=t, x_ticks_major=t, x_ticks_minor=t,
xlabel=t, x_grid_label=t, ymin=t, ymax=t, ylog=t,
y_ticks_major=t, y_ticks_minor=t, ylabel=t, y_grid_label=t,
font_size=t, label_options=t, x_ticks_angle=t)
self.bind(tick_color=tc, background_color=tc, border_color=tc)
self._trigger()
示例3: create_drawings
# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Mesh [as 别名]
def create_drawings(self):
self._color = Color(*self.color)
self._mesh = Mesh(mode='line_strip')
self.bind(color=lambda instr, value: setattr(self._color, "rgba", value))
return [self._color, self._mesh]
示例4: get_graphics
# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Mesh [as 别名]
def get_graphics(self, gc, polygons, points_line, rgbFace, closed=False):
'''Return an instruction group which contains the necessary graphics
instructions to draw the respective graphics.
'''
instruction_group = InstructionGroup()
if isinstance(gc.line['dash_list'], tuple):
gc.line['dash_list'] = list(gc.line['dash_list'])
if rgbFace is not None:
if len(polygons.meshes) != 0:
instruction_group.add(Color(*rgbFace))
for vertices, indices in polygons.meshes:
instruction_group.add(Mesh(
vertices=vertices,
indices=indices,
mode=str("triangle_fan")
))
instruction_group.add(Color(*gc.get_rgb()))
if _mpl_ge_1_5 and (not _mpl_ge_2_0) and closed:
points_poly_line = points_line[:-2]
else:
points_poly_line = points_line
if gc.line['width'] > 0:
instruction_group.add(Line(points=points_poly_line,
width=int(gc.line['width'] / 2),
dash_length=gc.line['dash_length'],
dash_offset=gc.line['dash_offset'],
dash_joint=gc.line['join_style'],
dash_list=gc.line['dash_list']))
return instruction_group
示例5: get_mesh
# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Mesh [as 别名]
def get_mesh(self):
v = []
# first calculate the distance between endpoints of the inner
# arc, so we know how many steps to use when calculating
# vertices
end_point_inner = polar_to_rect(
self.origin, self.r_min, self.theta_max)
d_inner = d_outer = 3.
theta_step_inner = (self.theta_max - self.theta_min) / d_inner
end_point_outer = polar_to_rect(
self.origin, self.r_max, self.theta_max)
if self.r_min == 0:
theta_step_outer = (self.theta_max - self.theta_min) / d_outer
for x in range(int(d_outer)):
v += (polar_to_rect(self.origin, 0, 0) * 2)
v += (polar_to_rect(
self.origin, self.r_max,
self.theta_min + x * theta_step_outer) * 2)
else:
for x in range(int(d_inner + 2)):
v += (polar_to_rect(
self.origin, self.r_min - 1,
self.theta_min + x * theta_step_inner) * 2)
v += (polar_to_rect(
self.origin, self.r_max + 1,
self.theta_min + x * theta_step_inner) * 2)
v += (end_point_inner * 2)
v += (end_point_outer * 2)
return Mesh(vertices=v, indices=range(int(len(v) / 4)),
mode='triangle_strip')
示例6: __init__
# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Mesh [as 别名]
def __init__(self, **kwargs):
super(Graph, self).__init__(**kwargs)
with self.canvas:
self._fbo = Fbo(size=self.size)
self._marker_color = Color(self.marker_color)
self._marker = Line()
with self._fbo:
self._background_color = Color(*self.background_color)
self._background_rect = Rectangle(size=self.size)
self._mesh_ticks_color = Color(*self.tick_color)
self._mesh_ticks = Mesh(mode='lines')
self._mesh_rect_color = Color(*self.border_color)
self._mesh_rect = Mesh(mode='line_strip')
with self.canvas:
Color(1, 1, 1)
self._fbo_rect = Rectangle(size=self.size)
mesh = self._mesh_rect
mesh.vertices = [0] * (5 * 4)
mesh.indices = range(5)
self._plot_area = StencilView()
self.add_widget(self._plot_area)
t = self._trigger = Clock.create_trigger(self._redraw_all)
ts = self._trigger_size = Clock.create_trigger(self._redraw_size)
tc = self._trigger_color = Clock.create_trigger(self._update_colors)
self.bind(center=ts, padding=ts, precision=ts, plots=ts, x_grid=ts,
y_grid=ts, draw_border=ts)
self.bind(xmin=t, xmax=t, xlog=t, x_ticks_major=t, x_ticks_minor=t,
xlabel=t, x_grid_label=t, ymin=t, ymax=t, ylog=t,
y_ticks_major=t, y_ticks_minor=t, ylabel=t, y_grid_label=t,
font_size=t, label_options=t)
self.bind(tick_color=tc, background_color=tc, border_color=tc)
self._trigger()
示例7: create_drawings
# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Mesh [as 别名]
def create_drawings(self):
self._color = Color(*self.color)
self._mesh = Mesh(mode='line_strip')
self.bind(color=lambda instr, value: setattr(self._color.rgba, value))
return [self._color, self._mesh]
示例8: update_glsl
# 需要导入模块: from kivy import graphics [as 别名]
# 或者: from kivy.graphics import Mesh [as 别名]
def update_glsl(self, nap):
'''
https://github.com/kivy/kivy/issues/2178
if Game.REPLACE_CURSOR:
cur_x, cur_y = g_window.mouse_pos
cur_x += CURSOR_OFFSET_X
cur_y += CURSOR_OFFSET_Y
for c in (self.begin_cursor,
self.begin_cursor + VERTEX_SIZE,
self.begin_cursor + VERTEX_SIZE * 2,
self.begin_cursor + VERTEX_SIZE * 3):
self.vertices[c] = cur_x
self.vertices[c + 1] = cur_y
'''
if self.animate:
for i in self.animate.copy():
idx = i * VERTEX_SIZE * 4 + 2
val = self.vertices[idx] * (nap * 25 + 1)
if val >= 1:
val = 1
self.animate.remove(i)
for c in (idx,
idx + VERTEX_SIZE,
idx + VERTEX_SIZE * 2,
idx + VERTEX_SIZE * 3):
self.vertices[c] = val
if not self.animate and not Game.REPLACE_CURSOR:
Clock.unschedule(self.update_glsl)
self.canvas.clear()
if self.blending_is_broken:
self.canvas.before.add(select_blend_func)
self.canvas.after.add(reset_blend_func)
self.canvas.add(Mesh(indices=self.indices, vertices=self.vertices,
fmt=VERTEX_FORMAT, mode='triangles',
texture=self.tex))