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
+24 -17
View File
@@ -3,33 +3,35 @@ package world
import "math"
// renderPointsStageA performs a full expanded-canvas redraw but renders ONLY Point primitives.
func (w *World) renderPointsStageA(drawer PrimitiveDrawer, params RenderParams) error {
plan, err := w.buildRenderPlanStageA(params)
if err != nil {
return err
}
// func (w *World) renderPointsStageA(drawer PrimitiveDrawer, params RenderParams) error {
// plan, err := w.buildRenderPlanStageA(params)
// if err != nil {
// return err
// }
style := DefaultRenderStyle()
if params.Options != nil && params.Options.Style != nil {
style = *params.Options.Style
}
// style := DefaultRenderStyle()
// if params.Options != nil && params.Options.Style != nil {
// style = *params.Options.Style
// }
applyPointStyle(drawer, style)
drawPointsFromPlanWithRadius(drawer, plan, w.W, w.H, style.PointRadiusPx)
return nil
}
// allowWrap := params.Options == nil || !params.Options.DisableWrapScroll
// applyPointStyle(drawer, style)
// drawPointsFromPlanWithRadius(drawer, plan, w.W, w.H, style.PointRadiusPx, allowWrap)
// return nil
// }
// drawPointsFromPlan keeps backward compatibility for older tests/helpers.
func drawPointsFromPlan(drawer PrimitiveDrawer, plan RenderPlan) {
func drawPointsFromPlan(drawer PrimitiveDrawer, plan RenderPlan, allowWrap bool) {
// Default world sizes are unknown here, so this wrapper is no longer suitable for wrap-aware points.
// Keep it for historical call sites only if they pass through Render().
// Prefer calling drawPointsFromPlanWithRadius with world sizes.
drawPointsFromPlanWithRadius(drawer, plan, 0, 0, DefaultRenderStyle().PointRadiusPx)
drawPointsFromPlanWithRadius(drawer, plan, 0, 0, DefaultRenderStyle().PointRadiusPx, allowWrap)
}
// drawPointsFromPlanWithRadius executes a points-only draw from an already built render plan,
// using the provided screen-space radius. If worldW/worldH are zero, wrap copies are disabled.
func drawPointsFromPlanWithRadius(drawer PrimitiveDrawer, plan RenderPlan, worldW, worldH int, radiusPx float64) {
func drawPointsFromPlanWithRadius(drawer PrimitiveDrawer, plan RenderPlan, worldW, worldH int, radiusPx float64, allowWrap bool) {
// Convert screen radius to world-fixed conservatively (ceil), so wrap copies are not missed.
rPxInt := int(math.Ceil(radiusPx))
if rPxInt < 0 {
@@ -65,7 +67,12 @@ func drawPointsFromPlanWithRadius(drawer PrimitiveDrawer, plan RenderPlan, world
copiesToDraw := make([]pointCopy, 0, len(points))
for _, p := range points {
shifts := pointWrapShifts(p, rWorldFp, worldW, worldH)
var shifts []wrapShift
if allowWrap {
shifts = pointWrapShifts(p, rWorldFp, worldW, worldH)
} else {
shifts = []wrapShift{{dx: 0, dy: 0}}
}
for _, s := range shifts {
if pointCopyIntersectsTile(p, rWorldFp, s.dx, s.dy, td.Tile) {
copiesToDraw = append(copiesToDraw, pointCopy{p: p, dx: s.dx, dy: s.dy})