func Flatten(path *draw2d.Path, flattener Flattener, scale float64) {
	// First Point
	var startX, startY float64 = 0, 0
	// Current Point
	var x, y float64 = 0, 0
	i := 0
	for _, cmp := range path.Components {
		switch cmp {
		case draw2d.MoveToCmp:
			x, y = path.Points[i], path.Points[i+1]
			startX, startY = x, y
			if i != 0 {
				flattener.End()
			}
			flattener.MoveTo(x, y)
			i += 2
		case draw2d.LineToCmp:
			x, y = path.Points[i], path.Points[i+1]
			flattener.LineTo(x, y)
			flattener.LineJoin()
			i += 2
		case draw2d.QuadCurveToCmp:
			TraceQuad(flattener, path.Points[i-2:], 0.5)
			x, y = path.Points[i+2], path.Points[i+3]
			flattener.LineTo(x, y)
			i += 4
		case draw2d.CubicCurveToCmp:
			TraceCubic(flattener, path.Points[i-2:], 0.5)
			x, y = path.Points[i+4], path.Points[i+5]
			flattener.LineTo(x, y)
			i += 6
		case draw2d.ArcToCmp:
			x, y = TraceArc(flattener, path.Points[i], path.Points[i+1], path.Points[i+2], path.Points[i+3], path.Points[i+4], path.Points[i+5], scale)
			flattener.LineTo(x, y)
			i += 6
		case draw2d.CloseCmp:
			flattener.LineTo(startX, startY)
			flattener.Close()
		}
	}
	flattener.End()
}
func Flatten(path *draw2d.Path, flattener Flattener, scale float64) {
	
	var startX, startY float64 = 0, 0
	
	var x, y float64 = 0, 0
	i := 0
	for _, cmp := range path.Components {
		switch cmp {
		case draw2d.MoveToCmp:
			x, y = path.Points[i], path.Points[i+1]
			startX, startY = x, y
			if i != 0 {
				flattener.End()
			}
			flattener.MoveTo(x, y)
			i += 2
		case draw2d.LineToCmp:
			x, y = path.Points[i], path.Points[i+1]
			flattener.LineTo(x, y)
			flattener.LineJoin()
			i += 2
		case draw2d.QuadCurveToCmp:
			TraceQuad(flattener, path.Points[i-2:], 0.5)
			x, y = path.Points[i+2], path.Points[i+3]
			flattener.LineTo(x, y)
			i += 4
		case draw2d.CubicCurveToCmp:
			TraceCubic(flattener, path.Points[i-2:], 0.5)
			x, y = path.Points[i+4], path.Points[i+5]
			flattener.LineTo(x, y)
			i += 6
		case draw2d.ArcToCmp:
			x, y = TraceArc(flattener, path.Points[i], path.Points[i+1], path.Points[i+2], path.Points[i+3], path.Points[i+4], path.Points[i+5], scale)
			flattener.LineTo(x, y)
			i += 6
		case draw2d.CloseCmp:
			flattener.LineTo(startX, startY)
			flattener.Close()
		}
	}
	flattener.End()
}
func Flatten ( path * draw2d . Path , flattener Flattener , scale float64 ) { // First Point var startX , startY float64 = 0 , 0 // Current Point var x , y float64 = 0 , 0 i := 0 for _ , cmp := range path . Components { switch cmp { case draw2d . MoveToCmp : x , y = path . Points [ i ] , path . Points [ i + 1 ] startX , startY = x , y if i != 0 { flattener . End ( ) } flattener . MoveTo ( x , y ) i += 2 case draw2d . LineToCmp : x , y = path . Points [ i ] , path . Points [ i + 1 ] flattener . LineTo ( x , y ) flattener . LineJoin ( ) i += 2 case draw2d . QuadCurveToCmp : TraceQuad ( flattener , path . Points [ i - 2 : ] , 0.5 ) x , y = path . Points [ i + 2 ] , path . Points [ i + 3 ] flattener . LineTo ( x , y ) i += 4 case draw2d . CubicCurveToCmp : TraceCubic ( flattener , path . Points [ i - 2 : ] , 0.5 ) x , y = path . Points [ i + 4 ] , path . Points [ i + 5 ] flattener . LineTo ( x , y ) i += 6 case draw2d . ArcToCmp : x , y = TraceArc ( flattener , path . Points [ i ] , path . Points [ i + 1 ] , path . Points [ i + 2 ] , path . Points [ i + 3 ] , path . Points [ i + 4 ] , path . Points [ i + 5 ] , scale ) flattener . LineTo ( x , y ) i += 6 case draw2d . CloseCmp : flattener . LineTo ( startX , startY ) flattener . Close ( ) } } flattener . End ( ) }
// Flatten convert curves into straight segments keeping join segments info
Flatten convert curves into straight segments keeping join segments info