<s> '''<STR_LIT>''' <EOL> from kivy . clock import Clock <EOL> from kivy . app import App <EOL> from kivy . uix . floatlayout import FloatLayout <EOL> from kivy . core . window import Window <EOL> from kivy . graphics import RenderContext <EOL> from kivy . properties import StringProperty <EOL> header = '''<STR_LIT>''' <EOL> plasma_shader = header + '''<STR_LIT>''' <EOL> class ShaderWidget ( FloatLayout ) : <EOL> fs = StringProperty ( None ) <EOL> def __init__ ( self , ** kwargs ) : <EOL> self . canvas = RenderContext ( ) <EOL> super ( ShaderWidget , self ) . __init__ ( ** kwargs ) <EOL> Clock . schedule_interval ( self . update_glsl , <NUM_LIT:1> / <NUM_LIT> ) <EOL> def on_fs ( self , instance , value ) : <EOL> shader = self . canvas . shader <EOL> old_value = shader . fs <EOL> shader . fs = value <EOL> if not shader . success : <EOL> shader . fs = old_value <EOL> raise Exception ( '<STR_LIT>' ) <EOL> def update_glsl ( self , * largs ) : <EOL> self . canvas [ '<STR_LIT:time>' ] = Clock . get_boottime ( ) <EOL> self . canvas [ '<STR_LIT>' ] = list ( map ( float , self . size ) ) <EOL> self . canvas [ '<STR_LIT>' ] = Window . render_context [ '<STR_LIT>' ] <EOL> class PlasmaApp ( App ) : <EOL> def build ( self ) : <EOL> return ShaderWidget ( fs = plasma_shader ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> PlasmaApp ( ) . run ( ) </s>
