@@ -24,11 +24,7 @@ export interface RenderOptions {
2424 boundingBox ?: boolean ;
2525}
2626
27- // TODO render path only
28-
29- // Renders a shape made up of the input points to an editable data structure
30- // which can be rendered to svg.
31- export const renderEditable = ( shape : Shape , opt : RenderOptions ) : XmlElement => {
27+ export const renderPath = ( shape : Shape ) : string => {
3228 // Render path data attribute from points and handles.
3329 let path = `M${ shape [ 0 ] . x } ,${ shape [ 0 ] . y } ` ;
3430 forShape ( shape , ( { curr, next : getNext } ) => {
@@ -37,7 +33,12 @@ export const renderEditable = (shape: Shape, opt: RenderOptions): XmlElement =>
3733 const nextControl = expandHandle ( next , next . handleIn ) ;
3834 path += `C${ currControl . x } ,${ currControl . y } ,${ nextControl . x } ,${ nextControl . y } ,${ next . x } ,${ next . y } ` ;
3935 } ) ;
36+ return path ;
37+ } ;
4038
39+ // Renders a shape made up of the input points to an editable data structure
40+ // which can be rendered to svg.
41+ export const renderEditable = ( shape : Shape , opt : RenderOptions ) : XmlElement => {
4142 const stroke = opt . stroke || ( opt . guides ? "black" : "none" ) ;
4243 const strokeWidth = opt . strokeWidth || ( opt . guides ? 1 : 0 ) ;
4344
@@ -54,7 +55,7 @@ export const renderEditable = (shape: Shape, opt: RenderOptions): XmlElement =>
5455 xmlBlobPath . attributes . stroke = stroke ;
5556 xmlBlobPath . attributes [ "stroke-width" ] = strokeWidth ;
5657 xmlBlobPath . attributes . fill = opt . fill || "none" ;
57- xmlBlobPath . attributes . d = path ;
58+ xmlBlobPath . attributes . d = renderPath ( shape ) ;
5859
5960 xmlContentGroup . children . push ( xmlBlobPath ) ;
6061 xmlRoot . children . push ( xmlContentGroup ) ;
0 commit comments