Классный зум

This commit is contained in:
2026-02-26 19:06:36 +03:00
parent a1f31d76c7
commit 9e2bb23c8a
2 changed files with 7 additions and 1 deletions

View File

@@ -99,6 +99,11 @@ pub fn addZoom(self: *Canvas, value: f32) void {
self._zoom = @max(self._zoom, 0.01); self._zoom = @max(self._zoom, 0.01);
} }
pub fn multZoom(self: *Canvas, value: f32) void {
self._zoom *= value;
self._zoom = @max(self._zoom, 0.01);
}
pub fn getZoom(self: Canvas) f32 { pub fn getZoom(self: Canvas) f32 {
return self._zoom; return self._zoom;
} }

View File

@@ -135,7 +135,8 @@ fn handleCanvasZoom(canvas: *Canvas, scroll: anytype) void {
}; };
const doc_pt = canvas.contentPointToDocument(content_pt, natural_scale); const doc_pt = canvas.contentPointToDocument(content_pt, natural_scale);
canvas.addZoom(y / 1000); // canvas.addZoom(y / 1000);
canvas.multZoom(1 + y / 3000);
canvas.requestRedraw(); canvas.requestRedraw();
// Сдвигаем viewport так, чтобы точка под курсором (даже вне холста) не уезжала // Сдвигаем viewport так, чтобы точка под курсором (даже вне холста) не уезжала