From 6e0a1d9df17e661da2038781d75633440b2b6341 Mon Sep 17 00:00:00 2001 From: Charles Merriam Date: Sun, 1 Feb 2015 00:10:39 -0800 Subject: [PATCH 1/6] Add examples/canvas/clearbuffers.py docstring --- examples/canvas/clearbuffers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/canvas/clearbuffers.py b/examples/canvas/clearbuffers.py index d22f6c0cb..690b77188 100644 --- a/examples/canvas/clearbuffers.py +++ b/examples/canvas/clearbuffers.py @@ -1,5 +1,14 @@ -__all__ = ('FboFloatLayout', ) +''' +FBO Canvas +========== +This demonstrates a layout using an FBO (Frame Buffer Off-screen) +instead of a plain canvas. You should see a black canvas with a +button labelled 'FBO' in the bottom left corner. Clicking it +animates the button moving right to left. +''' + +__all__ = ('FboFloatLayout', ) from kivy.graphics import Color, Rectangle, Canvas, ClearBuffers, ClearColor from kivy.graphics.fbo import Fbo From 79a0f65c8bfca3cc36b53fa3d8919d8d1d4292e8 Mon Sep 17 00:00:00 2001 From: Charles Merriam Date: Sun, 1 Feb 2015 00:13:07 -0800 Subject: [PATCH 2/6] Minor examples/canvas/clearbuffers.py code readability --- examples/canvas/clearbuffers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/canvas/clearbuffers.py b/examples/canvas/clearbuffers.py index 690b77188..d7215980c 100644 --- a/examples/canvas/clearbuffers.py +++ b/examples/canvas/clearbuffers.py @@ -14,6 +14,7 @@ from kivy.graphics import Color, Rectangle, Canvas, ClearBuffers, ClearColor from kivy.graphics.fbo import Fbo from kivy.uix.floatlayout import FloatLayout from kivy.properties import ObjectProperty, NumericProperty +from kivy.factory import Factory class FboFloatLayout(FloatLayout): @@ -37,7 +38,7 @@ class FboFloatLayout(FloatLayout): super(FboFloatLayout, self).__init__(**kwargs) def add_widget(self, *largs): - # trick to attach graphics instructino to fbo instead of canvas + # trick to attach graphics instruction to fbo instead of canvas canvas = self.canvas self.canvas = self.fbo ret = super(FboFloatLayout, self).add_widget(*largs) @@ -69,13 +70,12 @@ class FboFloatLayout(FloatLayout): from kivy.app import App from kivy.core.window import Window from kivy.animation import Animation -from kivy.factory import Factory as F class ScreenLayerApp(App): def build(self): f = FboFloatLayout() - b = F.Button(text="FBO", size_hint=(None, None)) + b = Factory.Button(text="FBO", size_hint=(None, None)) f.add_widget(b) def anim_btn(*args): From 44c80a10f91b06c563c79b30e926296475bf9e73 Mon Sep 17 00:00:00 2001 From: Charles Merriam Date: Sun, 1 Feb 2015 00:13:40 -0800 Subject: [PATCH 3/6] examples/canvas/clearbuffers.py move imports to top --- examples/canvas/clearbuffers.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/canvas/clearbuffers.py b/examples/canvas/clearbuffers.py index d7215980c..84d69389f 100644 --- a/examples/canvas/clearbuffers.py +++ b/examples/canvas/clearbuffers.py @@ -14,8 +14,12 @@ from kivy.graphics import Color, Rectangle, Canvas, ClearBuffers, ClearColor from kivy.graphics.fbo import Fbo from kivy.uix.floatlayout import FloatLayout from kivy.properties import ObjectProperty, NumericProperty +from kivy.app import App +from kivy.core.window import Window +from kivy.animation import Animation from kivy.factory import Factory + class FboFloatLayout(FloatLayout): texture = ObjectProperty(None, allownone=True) @@ -66,11 +70,6 @@ class FboFloatLayout(FloatLayout): self.fbo_color.rgba = (1, 1, 1, value) - -from kivy.app import App -from kivy.core.window import Window -from kivy.animation import Animation - class ScreenLayerApp(App): def build(self): From 2732194e01100474a23e8cd343e40c4d4d47f95c Mon Sep 17 00:00:00 2001 From: Charles Merriam Date: Sun, 1 Feb 2015 00:14:05 -0800 Subject: [PATCH 4/6] examples/canvas/clearbuffers.py remove dead code --- examples/canvas/clearbuffers.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/examples/canvas/clearbuffers.py b/examples/canvas/clearbuffers.py index 84d69389f..bfd8fbb47 100644 --- a/examples/canvas/clearbuffers.py +++ b/examples/canvas/clearbuffers.py @@ -81,14 +81,6 @@ class ScreenLayerApp(App): Animation(x=f.width-b.width).start(b) b.bind(on_press=anim_btn) - #before this or calback instruction was only way... - #so no way to avoid going into python instead of stayingin c - #def clear_fb(*args): - # f.fbo.bind() - # f.fbo.clear_buffer() - # f.fbo.release() - #Window.bind(on_draw=clear_fb) - return f From d0f979c49d6422e09297eb175d046d0a5a6435ae Mon Sep 17 00:00:00 2001 From: Charles Merriam Date: Sun, 1 Feb 2015 00:14:45 -0800 Subject: [PATCH 5/6] examples/canvas/clearbuffers.py button slides both ways --- examples/canvas/clearbuffers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/canvas/clearbuffers.py b/examples/canvas/clearbuffers.py index bfd8fbb47..bd7680fdf 100644 --- a/examples/canvas/clearbuffers.py +++ b/examples/canvas/clearbuffers.py @@ -78,7 +78,10 @@ class ScreenLayerApp(App): f.add_widget(b) def anim_btn(*args): - Animation(x=f.width-b.width).start(b) + if b.pos[0] == 0: + Animation(x=f.width-b.width).start(b) + else: + Animation(x=0).start(b) b.bind(on_press=anim_btn) return f From d6a9dc7f9c642723d6f53aaac69c35c46fb3b434 Mon Sep 17 00:00:00 2001 From: Charles Merriam Date: Sun, 1 Feb 2015 00:16:11 -0800 Subject: [PATCH 6/6] Rename examples/canvas/clearbuffers.py to fbo_canvas.py Old name was misleading and squished two words together. Code never even called fbo.clearbuffers(). --- examples/canvas/{clearbuffers.py => fbo_canvas.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/canvas/{clearbuffers.py => fbo_canvas.py} (100%) diff --git a/examples/canvas/clearbuffers.py b/examples/canvas/fbo_canvas.py similarity index 100% rename from examples/canvas/clearbuffers.py rename to examples/canvas/fbo_canvas.py