Created
July 11, 2014 00:05
-
-
Save inclement/448b033e96080fefd24d to your computer and use it in GitHub Desktop.
kivy infinite scrolling image example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from kivy.uix.widget import Widget | |
| from kivy.lang import Builder | |
| from kivy.clock import Clock | |
| from kivy.base import runTouchApp | |
| class Scrolling(Widget): | |
| def __init__(self, **kwargs): | |
| super(Scrolling, self).__init__(**kwargs) | |
| self.canvas.children[-1].texture.wrap = 'repeat' | |
| def update(self, dt): | |
| tcs = self.tex_coords | |
| for i in range(0, 8, 2): | |
| self.tex_coords[i] += dt/3. | |
| root = Builder.load_string(''' | |
| Scrolling: | |
| <Scrolling>: | |
| tex_coords: [0, 0, 0, 1, 1, 1, 1, 0] | |
| canvas: | |
| Rectangle: | |
| pos: self.pos | |
| size: self.size | |
| source: 'colours.png' | |
| tex_coords: root.tex_coords | |
| ''') | |
| Clock.schedule_interval(root.update, 1./60) | |
| runTouchApp(root) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this example, I was struggling on how to create a texture scroll. However I had to make some slight edit to make your example work.