Beispiel #1
0
func NewStickShape(height float32, width float32, step float32) (shape *StickShap, err error) {
	convex, err := sf.NewConvexShape()
	shape = &StickShap{ConvexShape: *convex, height: height, width: width, step: step, ctrlPoint: make([]sf.Vector2f, 12), radiusTop: 0, radiusBottom: 0}
	shape.SetPointCount(uint(4*step + 4))
	shape.updateShape()
	return
}
Beispiel #2
0
func NewCurveCicleShape(step int, radius float32, num uint) (cShape *CurveConvexShape, err error) {
	shape, err := sf.NewConvexShape()
	cShape = &CurveConvexShape{ConvexShape: *shape, step: step, ctrlPoints: make([]sf.Vector2f, 0), curves: 3}
	cShape.SetPointCount(num)
	var i uint
	for i = 0; i < num; i++ {
		cShape.SetPoint(i, sf.Vector2f{radius * float32(math.Cos(float64(i)*math.Pi*2/float64(num))), radius * float32(math.Sin(float64(i)*math.Pi*2/float64(num)))})
	}
	cShape.AllToCurve()
	return
}
Beispiel #3
0
func NewCurveConvexShape(step int) (cShape *CurveConvexShape, err error) {
	shape, err := sf.NewConvexShape()
	cShape = &CurveConvexShape{ConvexShape: *shape, step: step, ctrlPoints: make([]sf.Vector2f, 0), curves: 3}
	return
}