<s> '''<STR_LIT>''' <EOL> from kivy . app import App <EOL> from kivy . uix . floatlayout import FloatLayout <EOL> from kivy . uix . slider import Slider <EOL> from kivy . graphics import Color , Bezier , Line <EOL> class BezierTest ( FloatLayout ) : <EOL> def __init__ ( self , points = [ ] , loop = False , * args , ** kwargs ) : <EOL> super ( BezierTest , self ) . __init__ ( * args , ** kwargs ) <EOL> self . d = <NUM_LIT:10> <EOL> self . points = points <EOL> self . loop = loop <EOL> self . current_point = None <EOL> with self . canvas : <EOL> Color ( <NUM_LIT:1.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ) <EOL> self . bezier = Bezier ( <EOL> points = self . points , <EOL> segments = <NUM_LIT> , <EOL> loop = self . loop , <EOL> dash_length = <NUM_LIT:100> , <EOL> dash_offset = <NUM_LIT:10> ) <EOL> Color ( <NUM_LIT:1.0> , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> self . line = Line ( <EOL> points = self . points + self . points [ : <NUM_LIT:2> ] , <EOL> dash_offset = <NUM_LIT:10> , <EOL> dash_length = <NUM_LIT:100> ) <EOL> s = Slider ( y = <NUM_LIT:0> , pos_hint = { '<STR_LIT:x>' : <NUM_LIT> } , size_hint = ( <NUM_LIT> , None ) , height = <NUM_LIT:50> ) <EOL> s . bind ( value = self . _set_bezier_dash_offset ) <EOL> self . add_widget ( s ) <EOL> s = Slider ( y = <NUM_LIT:50> , pos_hint = { '<STR_LIT:x>' : <NUM_LIT> } , size_hint = ( <NUM_LIT> , None ) , height = <NUM_LIT:50> ) <EOL> s . bind ( value = self . _set_line_dash_offset ) <EOL> self . add_widget ( s ) <EOL> def _set_bezier_dash_offset ( self , instance , value ) : <EOL> self . bezier . dash_length = <NUM_LIT:100> - value <EOL> self . bezier . dash_offset = value <EOL> def _set_line_dash_offset ( self , instance , value ) : <EOL> self . line . dash_length = <NUM_LIT:100> - value <EOL> self . line . dash_offset = value <EOL> def on_touch_down ( self , touch ) : <EOL> if self . collide_point ( touch . pos [ <NUM_LIT:0> ] , touch . pos [ <NUM_LIT:1> ] ) : <EOL> for i , p in enumerate ( list ( zip ( self . points [ : : <NUM_LIT:2> ] , <EOL> self . points [ <NUM_LIT:1> : : <NUM_LIT:2> ] ) ) ) : <EOL> if ( abs ( touch . pos [ <NUM_LIT:0> ] - self . pos [ <NUM_LIT:0> ] - p [ <NUM_LIT:0> ] ) < self . d and <EOL> abs ( touch . pos [ <NUM_LIT:1> ] - self . pos [ <NUM_LIT:1> ] - p [ <NUM_LIT:1> ] ) < self . d ) : <EOL> self . current_point = i + <NUM_LIT:1> <EOL> return True <EOL> return super ( BezierTest , self ) . on_touch_down ( touch ) <EOL> def on_touch_up ( self , touch ) : <EOL> if self . collide_point ( touch . pos [ <NUM_LIT:0> ] , touch . pos [ <NUM_LIT:1> ] ) : <EOL> if self . current_point : <EOL> self . current_point = None <EOL> return True <EOL> return super ( BezierTest , self ) . on_touch_up ( touch ) <EOL> def on_touch_move ( self , touch ) : <EOL> if self . collide_point ( touch . pos [ <NUM_LIT:0> ] , touch . pos [ <NUM_LIT:1> ] ) : <EOL> c = self . current_point <EOL> if c : <EOL> self . points [ ( c - <NUM_LIT:1> ) * <NUM_LIT:2> ] = touch . pos [ <NUM_LIT:0> ] - self . pos [ <NUM_LIT:0> ] <EOL> self . points [ ( c - <NUM_LIT:1> ) * <NUM_LIT:2> + <NUM_LIT:1> ] = touch . pos [ <NUM_LIT:1> ] - self . pos [ <NUM_LIT:1> ] <EOL> self . bezier . points = self . points <EOL> self . line . points = self . points + self . points [ : <NUM_LIT:2> ] <EOL> return True <EOL> return super ( BezierTest , self ) . on_touch_move ( touch ) <EOL> class Main ( App ) : <EOL> def build ( self ) : <EOL> from math import cos , sin , radians <EOL> x = y = <NUM_LIT> <EOL> l = <NUM_LIT:100> <EOL> points = [ x , y ] <EOL> for i in range ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) : <EOL> i = radians ( i ) <EOL> points . extend ( [ x + cos ( i ) * l , y + sin ( i ) * l ] ) <EOL> return BezierTest ( points = points , loop = True ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> Main ( ) . run ( ) </s>
