diff --git a/pixler.bas b/pixler.bas index 87e1e4b..22580d2 100644 --- a/pixler.bas +++ b/pixler.bas @@ -36,10 +36,10 @@ temp&=_resize redim shared pal(0) as _unsigned long dim as integer ch1,ch2,ch3,bt loadpalette "slso8",pal() -layers(0).ihandle=_newimage(640,350,32) -layers(1).ihandle=_newimage(640,350,32) -layers(2).ihandle=_newimage(640,350,32) -layers(3).ihandle=_newimage(640, 350, 32) +layers(0).ihandle=_newimage(320,320,32) +layers(1).ihandle=_newimage(320,320,32) +layers(2).ihandle=_newimage(320,320,32) +layers(3).ihandle=_newimage(320,320,32) _dest layers(0).ihandle line (0,0)-(_width-1,_height-1),_rgb32(255),bf @@ -91,16 +91,26 @@ do ' Zooming 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 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 - if state.zoom < 0.05 then state.zoom = 0.05 + + ' 2. Calculate the new zoom level (Snap to whole numbers) + 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 - ' 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.offsetY = _mousey - (mouseWorldY * state.zoom) + mw = 0 end if @@ -230,7 +240,11 @@ sub canvas ' 3. Calculate Canvas Coordinates dim canX as integer: canX = int((_mousex - state.offsetX) / state.zoom) dim canY as integer: canY = int((_mousey - state.offsetY) / state.zoom) - + + + static polypoints(200) as single + static pointCount as integer + static drawCol if _mousebutton(1) then drawCol = state.fcolor if _mousebutton(2) then drawCol = state.bcolor