Created
May 9, 2018 13:50
-
-
Save pgregory/8c04f9caccadc4c4286f101e0884f229 to your computer and use it in GitHub Desktop.
Glowing line
This file contains 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
import sys | |
from kivy.app import App | |
from kivy.uix.relativelayout import RelativeLayout | |
from kivy.uix.widget import Widget | |
from kivy.uix.effectwidget import EffectWidget, InvertEffect, HorizontalBlurEffect, VerticalBlurEffect | |
from kivy.graphics import Color, Rectangle, Line | |
class Drawer(EffectWidget): | |
def __init__(self, *args, **kwargs): | |
super(Drawer, self).__init__(*args, **kwargs) | |
self.effects = [HorizontalBlurEffect(size=16.0), VerticalBlurEffect(size=16.0)] | |
self.w = Widget(size_hint=(1, 1)) | |
self.add_widget(self.w) | |
self.bind(size=self.draw, pos=self.draw) | |
self.draw() | |
def draw(self, *args): | |
self.w.canvas.clear() | |
with self.w.canvas: | |
Color(0, 0, 0, 1) | |
Rectangle(pos=self.pos, size=self.size) | |
self.effects = [HorizontalBlurEffect(size=16.0), VerticalBlurEffect(size=16.0)] | |
Color(0, .8, 1.0, 1) | |
Line(width=4, points=(0, self.height, self.width, 0)) | |
#self.effects = [HorizontalBlurEffect(size=2.0), VerticalBlurEffect(size=2.0)] | |
#Color(1, 1, 1, 1) | |
#Line(width=1, points=(0, self.height, self.width, 0)) | |
class Drawer2(EffectWidget): | |
def __init__(self, *args, **kwargs): | |
super(Drawer2, self).__init__(*args, **kwargs) | |
self.effects = [HorizontalBlurEffect(size=2.0), VerticalBlurEffect(size=2.0)] | |
self.w = Widget(size_hint=(1, 1)) | |
self.add_widget(self.w) | |
self.bind(size=self.draw, pos=self.draw) | |
self.draw() | |
def draw(self, *args): | |
self.w.canvas.clear() | |
with self.w.canvas: | |
Color(0, 1, 1, 1) | |
Line(width=2, points=(0, self.height, self.width, 0)) | |
class MyApp(App): | |
def build(self, *args, **kwargs): | |
super(MyApp, self).__init__(*args, **kwargs) | |
base = RelativeLayout(size_hint=(1, 1)) | |
base.add_widget(Drawer(size_hint=(1, 1))) | |
base.add_widget(Drawer2(size_hint=(1, 1))) | |
return base | |
def main(args): | |
app = MyApp() | |
app.run() | |
if __name__ == "__main__": | |
main(sys.argv[1:]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment