开发者

convert decimals into negatives?

开发者 https://www.devze.com 2023-02-13 19:14 出处:网络
I\'m scaling an image in css with transforms. The 开发者_Python百科scale goes from 0 to whatever, with 0 through 1 being smaller than the image.

I'm scaling an image in css with transforms.

The 开发者_Python百科scale goes from 0 to whatever, with 0 through 1 being smaller than the image.

I need to get the scale into negatives, so that 0 is the same size as the original, 1 is double the size, and -1 is half the size.

I have vars:

var cssScale, factorScale;

How to get cssScale into factorScale and vice versa?

Thanks.


Seems like you want 2-to-the-power-of-n:

cssScale= Math.pow(2, factorScale);

To get back the other way would be log-base-2, which you'd have to implement using log-base-E:

factorScale= Math.log(cssScale)/Math.LN2;


Sounds like cssScale = Size * (2 ^ factorScale).

0

精彩评论

暂无评论...
验证码 换一张
取 消