refactoring progress
This commit is contained in:
@@ -8,13 +8,13 @@ type SierpinskiArrow struct {
|
||||
dirty bool
|
||||
}
|
||||
|
||||
func (s *SierpinskiArrow) Draw(ctx *RenderCtx) {
|
||||
rl.Translatef(float32(ctx.SourceWidth)/2.0, float32(ctx.SourceHeight)/2.0, 0)
|
||||
func (s *SierpinskiArrow) Draw(env *Env) {
|
||||
rl.Translatef(float32(env.GetGraphicsWidth())/2.0, float32(env.GetGraphicsHeight())/2.0, 0)
|
||||
rl.ClearBackground(rl.NewColor(0, 0, 0, 0))
|
||||
sierpinskiArrow(ctx, int(ctx.Ports["sierpinskiArrowDepth"]), ctx.Ports["sierpinskiArrowLength"])
|
||||
sierpinskiArrow(env, int(env.Ports["sierpinskiArrowDepth"]), env.Ports["sierpinskiArrowLength"])
|
||||
}
|
||||
|
||||
func (s *SierpinskiArrow) Update(ctx *RenderCtx) {
|
||||
func (s *SierpinskiArrow) Update(_ *Env) {
|
||||
s.dirty = true
|
||||
}
|
||||
|
||||
@@ -22,26 +22,26 @@ func (s *SierpinskiArrow) IsDirty() bool {
|
||||
return s.dirty
|
||||
}
|
||||
|
||||
func sierpinskiArrow(ctx *RenderCtx, order int, length float64) {
|
||||
func sierpinskiArrow(env *Env, order int, length float64) {
|
||||
if order == 0 {
|
||||
curve(ctx, order, length, ctx.Ports["sierpinskiArrowAngle"])
|
||||
curve(env, order, length, env.Ports["sierpinskiArrowAngle"])
|
||||
} else {
|
||||
rl.Rotatef(float32(ctx.Ports["sierpinskiArrowAngle"]), 0, 0, 1)
|
||||
curve(ctx, order, length, -ctx.Ports["sierpinskiArrowAngle"])
|
||||
rl.Rotatef(float32(env.Ports["sierpinskiArrowAngle"]), 0, 0, 1)
|
||||
curve(env, order, length, -env.Ports["sierpinskiArrowAngle"])
|
||||
}
|
||||
}
|
||||
|
||||
func curve(ctx *RenderCtx, order int, length float64, angle float64) {
|
||||
func curve(env *Env, order int, length float64, angle float64) {
|
||||
if order == 0 {
|
||||
len := int32(length)
|
||||
rl.SetLineWidth(4)
|
||||
rl.DrawLine(0, 0, len, 0, rl.RayWhite)
|
||||
rl.Translatef(float32(length), 0, 0)
|
||||
} else {
|
||||
curve(ctx, order-1, length/2, -angle)
|
||||
curve(env, order-1, length/2, -angle)
|
||||
rl.Rotatef(float32(angle), 0, 0, 1)
|
||||
curve(ctx, order-1, length/2, angle)
|
||||
curve(env, order-1, length/2, angle)
|
||||
rl.Rotatef(float32(angle), 0, 0, 1)
|
||||
curve(ctx, order-1, length/2, -angle)
|
||||
curve(env, order-1, length/2, -angle)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user