// Flatten convert curves into straight segments keeping join segments info
547749
func Flatten(path *Path, flattener Flattener, scale float64) {
	// First Point
	var startX, startY float64
	// Current Point
	var x, y float64
	var i int
	for _, cmp := range path.Components {
		switch cmp {
		case MoveToComponent:
			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 LineToComponent:
			x, y = path.Points[i], path.Points[i+1]
			flattener.LineTo(x, y)
			flattener.LineJoin()
			i += 2
		case QuadCurveToComponent:
			// we include the previous point for the start of the curve
			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 CubicCurveToComponent:
			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 ArcToComponent:
			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 CloseComponent:
			flattener.LineTo(startX, startY)
			flattener.Close()
		}
	}
	flattener.End()
}
1078665
func (g *Graph) simplify() {

	if g == nil {
		return
	}

	for _, node := range g.Out {
		if TypePath == node.ThisString() {
			s := node.GetAt(0).ThisString()

			switch s {
			case "if":
				node.This = TypeIf
				node.DeleteAt(0)
			case "end":
				node.This = TypeEnd
				node.DeleteAt(0)
			case "else":
				node.This = TypeElse
				node.DeleteAt(0)
			case "for":
				node.This = TypeFor
				node.DeleteAt(0)
			case "break":
				node.This = TypeBreak
				node.DeleteAt(0)
			}
		}
	}

}
716926
func (def *Synthdef) flattenInput(params Params, ugen *Ugen, input Input) {
	switch v := input.(type) {
	case *Ugen:
		_, idx, _ := def.addUgen(v)

		// In has different behavior than other ugens when it is multichannel expanded.
		// Each channel of its output gets mapped to a single channel of the expression
		// tree above it. [briansorahan]
		if v.Name == "In" {
			ugen.Inputs = append(ugen.Inputs, UgenInput{
				UgenIndex:   int32(idx),
				OutputIndex: int32(def.inidx),
			})
			def.inidx++
			break
		}
		for outputIndex := range v.Outputs {
			ugen.Inputs = append(ugen.Inputs, UgenInput{
				UgenIndex:   int32(idx),
				OutputIndex: int32(outputIndex),
			})
		}
	case C:
		idx := def.addConstant(v)
		ugen.Inputs = append(ugen.Inputs, UgenInput{
			UgenIndex:   -1,
			OutputIndex: int32(idx),
		})
	case *param:
		idx := v.Index()
		ugen.Inputs = append(ugen.Inputs, UgenInput{
			UgenIndex:   0,
			OutputIndex: idx,
		})
	case MultiInput:
		for _, min := range v.InputArray() {
			switch x := min.(type) {
			case *Ugen:
				_, idx, _ := def.addUgen(x)
				// will we ever need to use a different output index? [bps]
				for outputIndex := range x.Outputs {
					ugen.Inputs = append(ugen.Inputs, UgenInput{
						UgenIndex:   int32(idx),
						OutputIndex: int32(outputIndex),
					})
				}
			case C:
				ugen.Inputs = append(ugen.Inputs, UgenInput{
					UgenIndex:   -1,
					OutputIndex: int32(def.addConstant(x)),
				})
			case *param:
				ugen.Inputs = append(ugen.Inputs, UgenInput{
					UgenIndex:   0,
					OutputIndex: x.Index(),
				})
			}
		}
	}
}
1061704
func flattenDeploymentStyle(style *codedeploy.DeploymentStyle) []map[string]interface{} {
	if style == nil {
		return nil
	}

	item := make(map[string]interface{})
	if style.DeploymentOption != nil {
		item["deployment_option"] = *style.DeploymentOption
	}
	if style.DeploymentType != nil {
		item["deployment_type"] = *style.DeploymentType
	}

	result := make([]map[string]interface{}, 0, 1)
	result = append(result, item)
	return result
}
185174
func (g *Geometry) Interpolate(dist float64) (*Geometry, error) {
	return geomFromC("Interpolate", cGEOSInterpolate(g.g, C.double(dist)))
}
173065
func flattenKVPairs(kvs []*logEntryKV) []interface{} {
	var result []interface{}
	for _, kv := range kvs {
		result = append(result, kv.Key)
		result = append(result, kv.Value)
	}

	return result
}
272070
func (as *accountSet) flatten() []common.Address {
	if as.cache == nil {
		accounts := make([]common.Address, 0, len(as.accounts))
		for account := range as.accounts {
			accounts = append(accounts, account)
		}
		as.cache = &accounts
	}
	return *as.cache
}
829919
func FlattenToWordsFunction(env *Zlisp, name string, args []Sexp) (Sexp, error) {
	if len(args) == 0 {
		return SexpNull, WrongNargs
	}
	stringArgs, err := flattenToWordsHelper(args)
	if err != nil {
		return SexpNull, err
	}

	// Now convert to []Sexp{SexpStr}
	res := make([]Sexp, len(stringArgs))
	for i := range stringArgs {
		res[i] = &SexpStr{S: stringArgs[i]}
	}
	return env.NewSexpArray(res), nil
}
416104
func (s *VisvalingamSimplifier) Simplify(g orb.Geometry) orb.Geometry {
	return simplify(s, g)
}
369932
func flattenEcsLoadBalancers(list []*ecs.LoadBalancer) []map[string]interface{} {
	result := make([]map[string]interface{}, 0, len(list))
	for _, loadBalancer := range list {
		l := map[string]interface{}{
			"container_name": *loadBalancer.ContainerName,
			"container_port": *loadBalancer.ContainerPort,
		}

		if loadBalancer.LoadBalancerName != nil {
			l["elb_name"] = *loadBalancer.LoadBalancerName
		}

		if loadBalancer.TargetGroupArn != nil {
			l["target_group_arn"] = *loadBalancer.TargetGroupArn
		}

		result = append(result, l)
	}
	return result
}
1220267
func flattenStepAdjustments(adjustments []*autoscaling.StepAdjustment) []map[string]interface{} {
	result := make([]map[string]interface{}, 0, len(adjustments))
	for _, raw := range adjustments {
		a := map[string]interface{}{
			"scaling_adjustment": aws.Int64Value(raw.ScalingAdjustment),
		}
		if raw.MetricIntervalUpperBound != nil {
			a["metric_interval_upper_bound"] = fmt.Sprintf("%g", aws.Float64Value(raw.MetricIntervalUpperBound))
		}
		if raw.MetricIntervalLowerBound != nil {
			a["metric_interval_lower_bound"] = fmt.Sprintf("%g", aws.Float64Value(raw.MetricIntervalLowerBound))
		}
		result = append(result, a)
	}
	return result
}
22836
func (pattern *MeshPattern) CurveTo(x1, y1, x2, y2, x3, y3 float64) {
	C.cairo_mesh_pattern_curve_to(pattern.Ptr, C.double(x1), C.double(y1), C.double(x2), C.double(y2), C.double(x3), C.double(y3))
	if err := pattern.status(); err != nil {
		panic(err)
	}
}
290291
func Segment(x []float64, size, noverlap int) [][]float64 {
	stride := size - noverlap
	lx := len(x)

	var segments int
	if lx == size {
		segments = 1
	} else if lx > size {
		segments = (len(x)-size)/stride + 1
	} else {
		segments = 0
	}

	r := make([][]float64, segments)
	for i, offset := 0, 0; i < segments; i++ {
		r[i] = make([]float64, size)

		for j := 0; j < size; j++ {
			r[i][j] = x[offset+j]
		}

		offset += stride
	}

	return r
}
407786
func pathify(parts []string, separator string) string {
	return separator + strings.Join(parts, separator)
}
885385
func (bk *Backend) flatten(bucket []string) string {
	// Convert ["foo", "bar"] to "foo/bar"
	raw := filepath.Join(bucket...)

	// URL encode bucket from "foo/bar" to "foo%2Fbar".
	flat := url.QueryEscape(raw)

	return filepath.Join(bk.rootDir, flat)
}
230363
func (n *Node) Flatten() []*Node {
	nodes := make([]*Node, 0)
	for _, node := range n.Node.Nodes {
		if node.Dir {
			nodes = append(nodes, NewNode(node).Flatten()...)
			continue
		}

		nodes = append(nodes, NewNode(node))
	}

	return nodes
}
609275
func (g *Geometry) Simplify(tolerance float64) (*Geometry, error) {
	return g.simplify("simplify", cGEOSSimplify, tolerance)
}