<s> import sys <EOL> from glob import glob <EOL> from os . path import join , dirname <EOL> from kivy . uix . scatter import Scatter <EOL> from kivy . uix . widget import Widget <EOL> from kivy . uix . label import Label <EOL> from kivy . app import App <EOL> from kivy . graphics . svg import Svg <EOL> from kivy . core . window import Window <EOL> from kivy . uix . floatlayout import FloatLayout <EOL> from kivy . lang import Builder <EOL> smaa_ui = '''<STR_LIT>''' <EOL> class SvgWidget ( Scatter ) : <EOL> def __init__ ( self , filename ) : <EOL> super ( SvgWidget , self ) . __init__ ( ) <EOL> with self . canvas : <EOL> svg = Svg ( filename ) <EOL> self . size = svg . width , svg . height <EOL> class SvgApp ( App ) : <EOL> def build ( self ) : <EOL> from kivy . garden . smaa import SMAA <EOL> Window . bind ( on_keyboard = self . _on_keyboard_handler ) <EOL> self . smaa = SMAA ( ) <EOL> self . effects = [ self . smaa , Widget ( ) ] <EOL> self . effect_index = <NUM_LIT:0> <EOL> self . label = Label ( text = '<STR_LIT>' , top = Window . height ) <EOL> self . effect = effect = self . effects [ <NUM_LIT:0> ] <EOL> self . root = FloatLayout ( ) <EOL> self . root . add_widget ( effect ) <EOL> if <NUM_LIT:0> : <EOL> from kivy . graphics import Color , Rectangle <EOL> wid = Widget ( size = Window . size ) <EOL> with wid . canvas : <EOL> Color ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> Rectangle ( size = Window . size ) <EOL> effect . add_widget ( wid ) <EOL> if <NUM_LIT:1> : <EOL> filenames = sys . argv [ <NUM_LIT:1> : ] <EOL> if not filenames : <EOL> filenames = glob ( join ( dirname ( __file__ ) , '<STR_LIT>' ) ) <EOL> for filename in filenames : <EOL> svg = SvgWidget ( filename ) <EOL> effect . add_widget ( svg ) <EOL> effect . add_widget ( self . label ) <EOL> svg . scale = <NUM_LIT> <EOL> svg . center = Window . center <EOL> if <NUM_LIT:0> : <EOL> wid = Scatter ( size = Window . size ) <EOL> from kivy . graphics import Color , Triangle , Rectangle <EOL> with wid . canvas : <EOL> Color ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> Rectangle ( size = Window . size ) <EOL> Color ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> w , h = Window . size <EOL> cx , cy = w / <NUM_LIT> , h / <NUM_LIT> <EOL> Triangle ( points = [ cx - w * <NUM_LIT> , cy - h * <NUM_LIT> , <EOL> cx , cy + h * <NUM_LIT> , <EOL> cx + w * <NUM_LIT> , cy - h * <NUM_LIT> ] ) <EOL> effect . add_widget ( wid ) <EOL> if <NUM_LIT:0> : <EOL> from kivy . uix . button import Button <EOL> from kivy . uix . slider import Slider <EOL> effect . add_widget ( Button ( text = '<STR_LIT>' ) ) <EOL> effect . add_widget ( Slider ( pos = ( <NUM_LIT:200> , <NUM_LIT:200> ) ) ) <EOL> control_ui = Builder . load_string ( smaa_ui ) <EOL> self . root . add_widget ( control_ui ) <EOL> def _on_keyboard_handler ( self , instance , key , * args ) : <EOL> if key == <NUM_LIT:32> : <EOL> self . effect_index = ( self . effect_index + <NUM_LIT:1> ) % <NUM_LIT:2> <EOL> childrens = self . effect . children [ : ] <EOL> self . effect . clear_widgets ( ) <EOL> self . root . remove_widget ( self . effect ) <EOL> self . effect = self . effects [ self . effect_index ] <EOL> self . root . add_widget ( self . effect ) <EOL> for child in reversed ( childrens ) : <EOL> self . effect . add_widget ( child ) <EOL> self . label . text = self . effect . __class__ . __name__ <EOL> Window . title = self . label . text <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> SvgApp ( ) . run ( ) </s>
