package shape

import (
	

	
	
	
)

type shapeCylinder struct {
	*baseShape
}

const (
	defaultArcDepth = 24.
)

func ( *geo.Box) Shape {
	 := shapeCylinder{
		baseShape: &baseShape{
			Type: CYLINDER_TYPE,
			Box:  ,
		},
	}
	.FullShape = go2.Pointer(Shape())
	return 
}

func getArcHeight( *geo.Box) float64 {
	 := defaultArcDepth
	// Note: box height should always be larger than 3*default
	// this just handles after collapsing into an oval
	if .Height < *2 {
		 = .Height / 2.0
	}
	return 
}

func ( shapeCylinder) () *geo.Box {
	 := .Box.Height
	 := .Box.TopLeft.Copy()
	 := getArcHeight(.Box)
	 -= 3 * 
	.Y += 2 * 
	return geo.NewBox(, .Box.Width, )
}

func cylinderOuterPath( *geo.Box) *svg.SvgPathContext {
	 := getArcHeight()
	 := 0.45
	 := svg.NewSVGPathContext(.TopLeft, 1, 1)
	.StartAt(.Absolute(0, ))
	.C(false, 0, 0, .Width*, 0, .Width/2, 0)
	.C(false, .Width-.Width*, 0, .Width, 0, .Width, )
	.V(true, .Height-*2)
	.C(false, .Width, .Height, .Width-.Width*, .Height, .Width/2, .Height)
	.C(false, .Width*, .Height, 0, .Height, 0, .Height-)
	.V(true, -(.Height - *2))
	.Z()
	return 
}

func cylinderInnerPath( *geo.Box) *svg.SvgPathContext {
	 := getArcHeight()
	 := 0.45
	 := svg.NewSVGPathContext(.TopLeft, 1, 1)
	.StartAt(.Absolute(0, ))
	.C(false, 0, *2, .Width*, *2, .Width/2, *2)
	.C(false, .Width-.Width*, *2, .Width, *2, .Width, )
	return 
}

func ( shapeCylinder) () []geo.Intersectable {
	return cylinderOuterPath(.Box).Path
}

func ( shapeCylinder) () []string {
	return []string{
		cylinderOuterPath(.Box).PathData(),
		cylinderInnerPath(.Box).PathData(),
	}
}

func ( shapeCylinder) (, , ,  float64) (float64, float64) {
	// 2 arcs top, height + padding, 1 arc bottom
	 :=  +  + 3*defaultArcDepth
	return math.Ceil( + ), math.Ceil()
}

func ( shapeCylinder) () (,  float64) {
	return defaultPadding, defaultPadding / 2
}