refactoring progress

This commit is contained in:
2026-01-08 11:54:35 -06:00
parent bbad63c60a
commit b3d9d0340a
7 changed files with 312 additions and 155 deletions

View File

@@ -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)
}
}