<s> """<STR_LIT>""" <EOL> from vispy import gloo <EOL> from vispy import app <EOL> import numpy as np <EOL> import math <EOL> nrows = <NUM_LIT:16> <EOL> ncols = <NUM_LIT:20> <EOL> m = nrows * ncols <EOL> n = <NUM_LIT:1000> <EOL> amplitudes = <NUM_LIT> + <NUM_LIT> * np . random . rand ( m , <NUM_LIT:1> ) . astype ( np . float32 ) <EOL> y = amplitudes * np . random . randn ( m , n ) . astype ( np . float32 ) <EOL> color = np . repeat ( np . random . uniform ( size = ( m , <NUM_LIT:3> ) , low = <NUM_LIT> , high = <NUM_LIT> ) , <EOL> n , axis = <NUM_LIT:0> ) . astype ( np . float32 ) <EOL> index = np . c_ [ np . repeat ( np . repeat ( np . arange ( ncols ) , nrows ) , n ) , <EOL> np . repeat ( np . tile ( np . arange ( nrows ) , ncols ) , n ) , <EOL> np . tile ( np . arange ( n ) , m ) ] . astype ( np . float32 ) <EOL> VERT_SHADER = """<STR_LIT>""" <EOL> FRAG_SHADER = """<STR_LIT>""" <EOL> class Canvas ( app . Canvas ) : <EOL> def __init__ ( self ) : <EOL> app . Canvas . __init__ ( self , title = '<STR_LIT>' , <EOL> keys = '<STR_LIT>' ) <EOL> self . program = gloo . Program ( VERT_SHADER , FRAG_SHADER ) <EOL> self . program [ '<STR_LIT>' ] = y . reshape ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . program [ '<STR_LIT>' ] = color <EOL> self . program [ '<STR_LIT>' ] = index <EOL> self . program [ '<STR_LIT>' ] = ( <NUM_LIT:1.> , <NUM_LIT:1.> ) <EOL> self . program [ '<STR_LIT>' ] = ( nrows , ncols ) <EOL> self . program [ '<STR_LIT>' ] = n <EOL> gloo . set_viewport ( <NUM_LIT:0> , <NUM_LIT:0> , * self . physical_size ) <EOL> self . _timer = app . Timer ( '<STR_LIT>' , connect = self . on_timer , start = True ) <EOL> gloo . set_state ( clear_color = '<STR_LIT>' , blend = True , <EOL> blend_func = ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . show ( ) <EOL> def on_resize ( self , event ) : <EOL> gloo . set_viewport ( <NUM_LIT:0> , <NUM_LIT:0> , * event . physical_size ) <EOL> def on_mouse_wheel ( self , event ) : <EOL> dx = np . sign ( event . delta [ <NUM_LIT:1> ] ) * <NUM_LIT> <EOL> scale_x , scale_y = self . program [ '<STR_LIT>' ] <EOL> scale_x_new , scale_y_new = ( scale_x * math . exp ( <NUM_LIT> * dx ) , <EOL> scale_y * math . exp ( <NUM_LIT:0.0> * dx ) ) <EOL> self . program [ '<STR_LIT>' ] = ( max ( <NUM_LIT:1> , scale_x_new ) , max ( <NUM_LIT:1> , scale_y_new ) ) <EOL> self . update ( ) <EOL> def on_timer ( self , event ) : <EOL> """<STR_LIT>""" <EOL> k = <NUM_LIT:10> <EOL> y [ : , : - k ] = y [ : , k : ] <EOL> y [ : , - k : ] = amplitudes * np . random . randn ( m , k ) <EOL> self . program [ '<STR_LIT>' ] . set_data ( y . ravel ( ) . astype ( np . float32 ) ) <EOL> self . update ( ) <EOL> def on_draw ( self , event ) : <EOL> gloo . clear ( ) <EOL> self . program . draw ( '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> c = Canvas ( ) <EOL> app . run ( ) </s>
