本文整理汇总了Python中kivy.graphics.Fbo.ask_update方法的典型用法代码示例。如果您正苦于以下问题:Python Fbo.ask_update方法的具体用法?Python Fbo.ask_update怎么用?Python Fbo.ask_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.graphics.Fbo
的用法示例。
在下文中一共展示了Fbo.ask_update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Slide
# 需要导入模块: from kivy.graphics import Fbo [as 别名]
# 或者: from kivy.graphics.Fbo import ask_update [as 别名]
class Slide(Factory.ButtonBehavior, Factory.Image):
ctrl = ObjectProperty(None)
slide_rotation = NumericProperty(0)
slide_scale = NumericProperty(1.)
slide_pos = ListProperty([0,0])
selected = BooleanProperty(False)
index = NumericProperty(0)
def __init__(self, **kwargs):
# get raw rgb thumb is available
self.thumb = kwargs.get('thumb', None)
del kwargs['thumb']
# extract controler now, we need it.
self.ctrl = kwargs.get('ctrl')
# create fbo for tiny texture
self.fbo = Fbo(size=(160, 120))
with self.fbo:
Color(1, 1, 1)
Rectangle(size=self.fbo.size)
self.fborect = Rectangle(size=self.fbo.size)
if self.thumb:
self.upload_thumb()
else:
self.update_capture()
super(Slide, self).__init__(**kwargs)
def on_press(self, touch):
if touch.is_double_tap:
self.ctrl.remove_slide(self)
else:
self.ctrl.select_slide(self)
def update_capture(self, *largs):
edit_mode = self.ctrl.is_edit
self.ctrl.is_edit = False
# update main fbo
fbo = self.ctrl.capture.fbo
fbo.ask_update()
fbo.draw()
# update our tiny fbo
self.fborect.texture = fbo.texture
self.fbo.ask_update()
self.fbo.draw()
# then bind the texture to our texture image
self.texture = self.fbo.texture
self.texture_size = self.texture.size
self.ctrl.is_edit = edit_mode
self.ctrl.set_dirty()
self.thumb = None
def download_thumb(self):
if self.thumb is None:
fbo = self.fbo
fbo.draw()
fbo.bind()
tmp = glReadPixels(0, 0, fbo.size[0], fbo.size[1], GL_RGBA, GL_UNSIGNED_BYTE)
fbo.release()
# remove alpha
tmp = list(tmp)
del tmp[3::4]
tmp = ''.join(tmp)
self.thumb = (fbo.size[0], fbo.size[1], tmp)
def upload_thumb(self):
from kivy.graphics.texture import Texture
w, h, pixels = self.thumb
texture = Texture.create((w, h), 'rgb', 'ubyte')
texture.blit_buffer(pixels, colorfmt='rgb')
self.texture = texture
self.texture_size = texture.size