<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> import vispy . app <EOL> from vispy import gloo <EOL> from vispy import visuals <EOL> from vispy . visuals . transforms import STTransform <EOL> class Canvas ( vispy . app . Canvas ) : <EOL> def __init__ ( self ) : <EOL> vispy . app . Canvas . __init__ ( self , keys = '<STR_LIT>' , size = ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . image = visuals . ImageVisual ( get_image ( ) , method = '<STR_LIT>' ) <EOL> s = <NUM_LIT> / max ( self . image . size ) <EOL> t = <NUM_LIT:0.5> * ( <NUM_LIT> - ( self . image . size [ <NUM_LIT:0> ] * s ) ) + <NUM_LIT:50> <EOL> self . image . transform = STTransform ( scale = ( s , s ) , translate = ( t , <NUM_LIT:50> ) ) <EOL> self . show ( ) <EOL> def on_draw ( self , ev ) : <EOL> gloo . clear ( color = '<STR_LIT>' , depth = True ) <EOL> self . image . draw ( ) <EOL> def on_resize ( self , event ) : <EOL> vp = ( <NUM_LIT:0> , <NUM_LIT:0> , self . physical_size [ <NUM_LIT:0> ] , self . physical_size [ <NUM_LIT:1> ] ) <EOL> self . context . set_viewport ( * vp ) <EOL> self . image . transforms . configure ( canvas = self , viewport = vp ) <EOL> def get_image ( ) : <EOL> """<STR_LIT>""" <EOL> from vispy . io import load_data_file , read_png <EOL> try : <EOL> return read_png ( load_data_file ( '<STR_LIT>' ) ) <EOL> except Exception as exc : <EOL> print ( "<STR_LIT>" % exc ) <EOL> image = np . random . normal ( size = ( <NUM_LIT:100> , <NUM_LIT:100> , <NUM_LIT:3> ) ) <EOL> image [ <NUM_LIT:20> : <NUM_LIT> , <NUM_LIT:20> : <NUM_LIT> ] += <NUM_LIT> <EOL> image [ <NUM_LIT:50> ] += <NUM_LIT> <EOL> image [ : , <NUM_LIT:50> ] += <NUM_LIT> <EOL> image = ( ( image - image . min ( ) ) * <EOL> ( <NUM_LIT> / ( image . max ( ) - image . min ( ) ) ) ) . astype ( np . ubyte ) <EOL> return image <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> win = Canvas ( ) <EOL> import sys <EOL> if sys . flags . interactive != <NUM_LIT:1> : <EOL> vispy . app . run ( ) </s>
