no-wrap option; pivoted exponential zoom

This commit is contained in:
Ilia Denisov
2026-03-07 11:35:18 +02:00
committed by GitHub
parent 1de621c743
commit 477e656008
22 changed files with 605 additions and 81 deletions
+17 -10
View File
@@ -2,15 +2,17 @@ package world
// renderLinesStageB performs a full expanded-canvas redraw but renders ONLY Line primitives.
// It uses the Stage A render plan: tiles + per-tile clip + per-tile candidates.
func (w *World) renderLinesStageB(drawer PrimitiveDrawer, params RenderParams) error {
plan, err := w.buildRenderPlanStageA(params)
if err != nil {
return err
}
// func (w *World) renderLinesStageB(drawer PrimitiveDrawer, params RenderParams) error {
// plan, err := w.buildRenderPlanStageA(params)
// if err != nil {
// return err
// }
drawLinesFromPlan(drawer, plan, w.W, w.H)
return nil
}
// allowWrap := params.Options == nil || !params.Options.DisableWrapScroll
// drawLinesFromPlan(drawer, plan, w.W, w.H, allowWrap)
// return nil
// }
// lineSeg is one canonical segment (endpoints in [0..W) x [0..H)) to be drawn.
// It represents part of the torus-shortest polyline for a Line primitive after wrap splitting.
@@ -20,7 +22,7 @@ type lineSeg struct {
}
// drawLinesFromPlan executes a lines-only draw from an already built render plan.
func drawLinesFromPlan(drawer PrimitiveDrawer, plan RenderPlan, worldW, worldH int) {
func drawLinesFromPlan(drawer PrimitiveDrawer, plan RenderPlan, worldW, worldH int, allowWrap bool) {
for _, td := range plan.Tiles {
if td.ClipW <= 0 || td.ClipH <= 0 {
continue
@@ -42,7 +44,12 @@ func drawLinesFromPlan(drawer PrimitiveDrawer, plan RenderPlan, worldW, worldH i
// Collect segments that actually intersect this tile's canonical rect.
segsToDraw := make([]lineSeg, 0, len(lines))
for _, l := range lines {
segs := torusShortestLineSegments(l, worldW, worldH)
var segs []lineSeg
if allowWrap {
segs = torusShortestLineSegments(l, worldW, worldH)
} else {
segs = []lineSeg{{x1: l.X1, y1: l.Y1, x2: l.X2, y2: l.Y2}}
}
for _, s := range segs {
if segmentIntersectsRect(s, td.Tile.Rect) {
segsToDraw = append(segsToDraw, s)