Adding back the polypoints.

This commit is contained in:
visionmercer 2026-05-04 12:14:29 +02:00
commit 1a473a6972

View file

@ -36,10 +36,10 @@ temp&=_resize
redim shared pal(0) as _unsigned long redim shared pal(0) as _unsigned long
dim as integer ch1,ch2,ch3,bt dim as integer ch1,ch2,ch3,bt
loadpalette "slso8",pal() loadpalette "slso8",pal()
layers(0).ihandle=_newimage(640,350,32) layers(0).ihandle=_newimage(320,320,32)
layers(1).ihandle=_newimage(640,350,32) layers(1).ihandle=_newimage(320,320,32)
layers(2).ihandle=_newimage(640,350,32) layers(2).ihandle=_newimage(320,320,32)
layers(3).ihandle=_newimage(640, 350, 32) layers(3).ihandle=_newimage(320,320,32)
_dest layers(0).ihandle _dest layers(0).ihandle
line (0,0)-(_width-1,_height-1),_rgb32(255),bf line (0,0)-(_width-1,_height-1),_rgb32(255),bf
@ -91,16 +91,26 @@ do
' Zooming ' Zooming
if mw <> 0 then if mw <> 0 then
' 1. Capture the current world position under the mouse ' 1. Capture current world position
dim mouseWorldX as single: mouseWorldX = (_mousex - state.offsetX) / state.zoom dim mouseWorldX as single: mouseWorldX = (_mousex - state.offsetX) / state.zoom
dim mouseWorldY as single: mouseWorldY = (_mousey - state.offsetY) / state.zoom dim mouseWorldY as single: mouseWorldY = (_mousey - state.offsetY) / state.zoom
' 2. Calculate the new zoom level
state.zoom = state.zoom + (mw * 0.1 * state.zoom) ' Multiplier makes it feel smoother ' 2. Calculate the new zoom level (Snap to whole numbers)
if state.zoom < 0.05 then state.zoom = 0.05 if mw > 0 then
state.zoom = state.zoom + 1
else
state.zoom = state.zoom - 1
end if
' 3. Constrain zoom (Min 1, Max 20)
if state.zoom < 1 then state.zoom = 1
if state.zoom > 20 then state.zoom = 20 if state.zoom > 20 then state.zoom = 20
' 3. Adjust offsets so the world position stays under the mouse
' 4. Adjust offsets and LOCK them to integers
' This prevents the canvas from sitting "between" screen pixels
state.offsetX = _mousex - (mouseWorldX * state.zoom) state.offsetX = _mousex - (mouseWorldX * state.zoom)
state.offsetY = _mousey - (mouseWorldY * state.zoom) state.offsetY = _mousey - (mouseWorldY * state.zoom)
mw = 0 mw = 0
end if end if
@ -230,7 +240,11 @@ sub canvas
' 3. Calculate Canvas Coordinates ' 3. Calculate Canvas Coordinates
dim canX as integer: canX = int((_mousex - state.offsetX) / state.zoom) dim canX as integer: canX = int((_mousex - state.offsetX) / state.zoom)
dim canY as integer: canY = int((_mousey - state.offsetY) / state.zoom) dim canY as integer: canY = int((_mousey - state.offsetY) / state.zoom)
static polypoints(200) as single
static pointCount as integer
static drawCol static drawCol
if _mousebutton(1) then drawCol = state.fcolor if _mousebutton(1) then drawCol = state.fcolor
if _mousebutton(2) then drawCol = state.bcolor if _mousebutton(2) then drawCol = state.bcolor