<s> from svgwrite import Drawing <EOL> from depixel . io_data import PixelDataWriter <EOL> def rgb ( rgb ) : <EOL> return "<STR_LIT>" % rgb <EOL> class PixelDataSvgWriter ( PixelDataWriter ) : <EOL> FILE_EXT = '<STR_LIT>' <EOL> PIXEL_BORDER = None <EOL> def make_drawing ( self , _drawing_type , filename ) : <EOL> return Drawing ( filename ) <EOL> def save_drawing ( self , drawing , _drawing_type ) : <EOL> drawing . save ( ) <EOL> def draw_pixel ( self , drawing , pt , colour ) : <EOL> pixel_border = self . PIXEL_BORDER <EOL> if pixel_border is None : <EOL> pixel_border = colour <EOL> drawing . add ( drawing . rect ( self . scale_pt ( pt ) , self . scale_pt ( ( <NUM_LIT:1> , <NUM_LIT:1> ) ) , <EOL> stroke = rgb ( pixel_border ) , fill = rgb ( colour ) ) ) <EOL> def draw_line ( self , drawing , pt0 , pt1 , colour ) : <EOL> drawing . add ( drawing . line ( pt0 , pt1 , stroke = rgb ( colour ) ) ) <EOL> def draw_polygon ( self , drawing , path , colour , fill ) : <EOL> drawing . add ( drawing . polygon ( path , stroke = rgb ( colour ) , fill = rgb ( fill ) ) ) <EOL> def draw_path_shape ( self , drawing , paths , colour , fill ) : <EOL> dpath = [ ] <EOL> for path in paths : <EOL> dpath . append ( '<STR_LIT:M>' ) <EOL> dpath . extend ( path ) <EOL> dpath . append ( '<STR_LIT>' ) <EOL> drawing . add ( drawing . path ( dpath , stroke = rgb ( colour ) , fill = rgb ( fill ) ) ) <EOL> def draw_spline_shape ( self , drawing , splines , colour , fill ) : <EOL> if fill == ( <NUM_LIT:255> , <NUM_LIT:255> , <NUM_LIT:255> ) : <EOL> return <EOL> dpath = [ ] <EOL> for spline in splines : <EOL> bcurves = list ( spline . quadratic_bezier_segments ( ) ) <EOL> dpath . append ( '<STR_LIT:M>' ) <EOL> dpath . append ( self . scale_pt ( bcurves [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) ) <EOL> for bcurve in bcurves : <EOL> dpath . append ( '<STR_LIT>' ) <EOL> dpath . append ( self . scale_pt ( bcurve [ <NUM_LIT:1> ] ) ) <EOL> dpath . append ( self . scale_pt ( bcurve [ <NUM_LIT:2> ] ) ) <EOL> dpath . append ( '<STR_LIT>' ) <EOL> drawing . add ( drawing . path ( dpath , stroke = rgb ( colour ) , fill = rgb ( fill ) ) ) <EOL> def draw_shape ( self , drawing , shape ) : <EOL> self . draw_curve_shape ( drawing , shape [ '<STR_LIT>' ] , <EOL> self . GRID_COLOUR , shape [ '<STR_LIT:value>' ] ) </s>
