本文整理汇总了Python中panda3d.core.CardMaker.show方法的典型用法代码示例。如果您正苦于以下问题:Python CardMaker.show方法的具体用法?Python CardMaker.show怎么用?Python CardMaker.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.CardMaker
的用法示例。
在下文中一共展示了CardMaker.show方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CameraApp
# 需要导入模块: from panda3d.core import CardMaker [as 别名]
# 或者: from panda3d.core.CardMaker import show [as 别名]
#.........这里部分代码省略.........
self.cam_shot = cairo.ImageSurface(cairo.FORMAT_ARGB32,
self.texture.getVideoWidth(),
self.texture.getVideoHeight())
ctx = cairo.Context(self.cam_shot)
ctx.set_source_surface(img, 0 , 0)
ctx.paint()
self.paint_background()
self.cr.set_source_surface(self.draw_viewer(self.cam_shot), 30,
self.top_margin + 5)
self.cr.paint()
self.paint_foreground()
self.surface.write_to_png(self.get_output())
self.parent.repaint()
self.toggle_view(False)
else:
print "Saving..."
pic_path = CameraApp.__ImageDir + "/p" + Util.generate_id() + ".png"
print pic_path
self.cam_shot.write_to_png(pic_path)
self.toggle_view(True)
def paint_scene(self):
drawer_width = self.width - 60
drawer_height = 2 * self.height / 3
surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, self.width, self.height)
context = cairo.Context(surface)
scale_x = float(self.width) / float(self.cam_shot.get_width())
scale_y = float(self.height) / float(self.cam_shot.get_height())
context.scale(scale_x, scale_y)
context.set_source_surface(self.cam_shot, 0, 0)
context.paint()
return surface
def cancel(self):
self.cam_shot = None
self.toggle_view(True)
def draw_viewer(self, image_surface):
drawer_width = self.width - 60
drawer_height = 2 * self.height / 3
surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, drawer_width, drawer_height)
context = cairo.Context(surface)
context.rectangle(0, 0, drawer_width, drawer_height)
context.set_source_rgba(.05, .05, .05, .8)
context.fill()
context.rectangle(1, 1, drawer_width - 2, drawer_height - 2)
context.clip()
context.new_path()
context.transform(get_transformation_matrix(drawer_width, drawer_height, image_surface.get_width(), image_surface.get_height()))
context.set_source_surface(image_surface, 0, 0)
context.paint()
return surface
def paint_background(self):
# Fondo
gradient = cairo.LinearGradient(0, 0, 0, self.height)
gradient.add_color_stop_rgb(0, 0, 0, 0)
gradient.add_color_stop_rgb(1, .4, .4, .4)
self.cr.set_source(gradient)
self.cr.move_to(0, 0)
self.cr.line_to(self.width, 0)
self.cr.line_to(self.width, self.height)
self.cr.line_to(0, self.height)
self.cr.close_path()
self.cr.fill()
def quit(self):
self.toggle_view(False)
self.parent.launch("menu")
def toggle_view(self, video):
self.video_mode = video
if video:
#self.texture.fromCamera()
self.card.setTexture(self.texture)
print (self.texture.getVideoWidth(), self.texture.getVideoHeight())
self.card.show()
self.parent.get_screen().hide()
else:
#self.texture = OpenCVTexture()
self.card.setTexture(self.texture)
self.card.hide()
self.parent.get_screen().show()