<s> from __future__ import absolute_import , division , print_function , unicode_literals <EOL> """<STR_LIT>""" <EOL> import math , random , time , glob , threading <EOL> from subprocess import Popen , PIPE , STDOUT <EOL> import demo <EOL> import pi3d <EOL> def _tex_load ( tex_list , slot , fName ) : <EOL> tex_list [ slot ] = pi3d . Texture ( fName ) <EOL> DISPLAY = pi3d . Display . create ( x = <NUM_LIT:50> , y = <NUM_LIT:50> , frames_per_second = <NUM_LIT> ) <EOL> DISPLAY . set_background ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1.0> ) <EOL> pi3d . Light ( ( <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:0> ) ) <EOL> shader = pi3d . Shader ( "<STR_LIT>" ) <EOL> flatsh = pi3d . Shader ( "<STR_LIT>" ) <EOL> post = pi3d . PostProcess ( "<STR_LIT>" ) <EOL> tFiles = glob . glob ( "<STR_LIT>" ) <EOL> nTex = len ( tFiles ) <EOL> slot = <NUM_LIT:0> <EOL> tex_list = [ pi3d . Texture ( tFiles [ slot ] ) , None ] <EOL> slot = <NUM_LIT:1> <EOL> t = threading . Thread ( target = _tex_load , args = ( tex_list , slot % <NUM_LIT:2> , tFiles [ slot % nTex ] ) ) <EOL> t . daemon = True <EOL> t . start ( ) <EOL> myshape = pi3d . MergeShape ( ) <EOL> asphere = pi3d . Sphere ( sides = <NUM_LIT:32> , slices = <NUM_LIT:32> ) <EOL> myshape . radialCopy ( asphere , step = <NUM_LIT> ) <EOL> myshape . position ( <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> myshape . set_draw_details ( shader , [ tex_list [ <NUM_LIT:0> ] ] , <NUM_LIT> , <NUM_LIT:0.1> ) <EOL> mysprite = pi3d . Sprite ( w = <NUM_LIT> , h = <NUM_LIT> ) <EOL> mysprite . position ( <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> mysprite . set_draw_details ( flatsh , [ tex_list [ <NUM_LIT:0> ] ] ) <EOL> mykeys = pi3d . Keyboard ( ) <EOL> pic_next = <NUM_LIT> <EOL> pic_dt = <NUM_LIT> <EOL> tm = <NUM_LIT:0.0> <EOL> dt = <NUM_LIT> <EOL> sc = <NUM_LIT:0.0> <EOL> ds = <NUM_LIT> <EOL> x = <NUM_LIT:0.0> <EOL> dx = <NUM_LIT> <EOL> mFiles = glob . glob ( "<STR_LIT>" ) <EOL> random . shuffle ( mFiles ) <EOL> nMusic = len ( mFiles ) <EOL> iMusic = <NUM_LIT:0> <EOL> p = Popen ( [ b"<STR_LIT>" , b"<STR_LIT>" , b"<STR_LIT>" , b"<STR_LIT>" ] , stdout = PIPE , stdin = PIPE ) <EOL> p . stdin . write ( bytearray ( "<STR_LIT>" . format ( mFiles [ iMusic ] ) , "<STR_LIT:ascii>" ) ) <EOL> p . stdin . flush ( ) <EOL> rval , gval , bval = <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> <EOL> mx , my = <NUM_LIT:1.0> , <NUM_LIT:1.0> <EOL> dx , dy = <NUM_LIT:1.0> , <NUM_LIT:1.0> <EOL> while DISPLAY . loop_running ( ) : <EOL> tm = tm + dt <EOL> sc = ( sc + ds ) % <NUM_LIT> <EOL> myshape . set_custom_data ( <NUM_LIT> , [ tm , sc , - <NUM_LIT:0.5> * sc ] ) <EOL> post . start_capture ( ) <EOL> mysprite . draw ( ) <EOL> myshape . draw ( ) <EOL> post . end_capture ( ) <EOL> flg = True <EOL> while flg : <EOL> st_read = time . time ( ) <EOL> l = p . stdout . readline ( ) <EOL> if ( time . time ( ) - st_read ) > <NUM_LIT> : <EOL> flg = False <EOL> if b'<STR_LIT>' in l : <EOL> iMusic = ( iMusic + <NUM_LIT:1> ) % nMusic <EOL> p . stdin . write ( bytearray ( "<STR_LIT>" . format ( mFiles [ iMusic ] ) , "<STR_LIT:ascii>" ) ) <EOL> p . stdin . flush ( ) <EOL> if b'<STR_LIT>' in l : <EOL> val_str = l . split ( ) <EOL> rval = float ( val_str [ <NUM_LIT:2> ] ) / <NUM_LIT> <EOL> gval = float ( val_str [ <NUM_LIT:6> ] ) / <NUM_LIT> <EOL> bval = float ( val_str [ <NUM_LIT:10> ] ) / <NUM_LIT> <EOL> post . draw ( { <NUM_LIT> : rval , <NUM_LIT> : gval , <NUM_LIT:50> : bval } ) <EOL> if mx > <NUM_LIT> : <EOL> dx = - <NUM_LIT:1.0> <EOL> elif mx < <NUM_LIT:0.0> : <EOL> dx = <NUM_LIT:1.0> <EOL> if my > <NUM_LIT> : <EOL> dy = - <NUM_LIT:1.0> <EOL> elif my < <NUM_LIT:0.0> : <EOL> dy = <NUM_LIT:1.0> <EOL> mx += dx * gval / <NUM_LIT> <EOL> my += dy * bval / <NUM_LIT> <EOL> myshape . scale ( mx , my , mx ) <EOL> myshape . rotateIncY ( <NUM_LIT> + rval ) <EOL> myshape . rotateIncX ( <NUM_LIT> - bval ) <EOL> mysprite . rotateIncZ ( <NUM_LIT:0.5> ) <EOL> if tm > pic_next : <EOL> """<STR_LIT>""" <EOL> pic_next += pic_dt <EOL> myshape . set_draw_details ( shader , [ tex_list [ slot % <NUM_LIT:2> ] ] ) <EOL> mysprite . set_draw_details ( flatsh , [ tex_list [ slot % <NUM_LIT:2> ] ] ) <EOL> slot += <NUM_LIT:1> <EOL> t = threading . Thread ( target = _tex_load , args = ( tex_list , slot % <NUM_LIT:2> , tFiles [ slot % nTex ] ) ) <EOL> t . daemon = True <EOL> t . start ( ) <EOL> k = mykeys . read ( ) <EOL> if k == <NUM_LIT> : <EOL> pi3d . screenshot ( "<STR_LIT>" ) <EOL> elif k == <NUM_LIT> : <EOL> mykeys . close ( ) <EOL> DISPLAY . destroy ( ) <EOL> break <EOL> p . stdin . write ( b'<STR_LIT>' ) </s>
