Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript js画布渐变缩放?_Javascript_Canvas_Zooming - Fatal编程技术网

Javascript js画布渐变缩放?

Javascript js画布渐变缩放?,javascript,canvas,zooming,Javascript,Canvas,Zooming,我一直在做一个非常巨大的模拟,这意味着需要放大和缩小 我发现了一个很好的工作脚本,但当模拟变得更大时,我发现它有一个问题。。。 放大得越多,步长越小,缩小得越远,步长越大 这是一个问题,因为我需要的步骤是平等的,无论你是什么缩放级别 我现在使用的脚本是: var total = 75, delta = e.detail ? e.detail * -120 : e.wheelDelta; //e is mouse event this.zoomValue += (delta > 0

我一直在做一个非常巨大的模拟,这意味着需要放大和缩小

我发现了一个很好的工作脚本,但当模拟变得更大时,我发现它有一个问题。。。 放大得越多,步长越小,缩小得越远,步长越大

这是一个问题,因为我需要的步骤是平等的,无论你是什么缩放级别

我现在使用的脚本是:

var total = 75,
    delta = e.detail ? e.detail * -120 : e.wheelDelta; //e is mouse event

this.zoomValue += (delta > 0) ? 1 : -1;

this.zoomRatio = 1 + (this.zoomValue / total) * 2;
e.preventDefault();
你可以在这里看到它的作用:(如果它不起作用,我要么摆弄它,要么你在使用Internet Explorer)

我稍后使用zoomRatio来计算各种对象的位置


谁知道放大的更好方法呢?

anwser实际上非常简单。。。然而,在我亲眼看到它之前,我需要有人给我看

解决方案是让它以指数方式缩放,所以

this.zoomRatio = Math.exp(this.zoomValue);
如果你能做到这一点,你可以

this.zoomRatio = Math.exp(this.zoomValue / 10);

要使其以较小的“步数”滚动,anwser实际上非常简单。。。然而,在我亲眼看到它之前,我需要有人给我看

解决方案是让它以指数方式缩放,所以

this.zoomRatio = Math.exp(this.zoomValue);
如果你能做到这一点,你可以

this.zoomRatio = Math.exp(this.zoomValue / 10);
使其以较小的“步数”滚动