I'm scaling an value and it works as I intend when the scale is 1 or greater but it doesn't seem to scale as intended when scaling down.
// increase by 10%
amount = 10
scale = 1
total = scale + amount/100
// decrease by 10%
amount = 10
scale = 1
total = scale - amount/100
I know this is easy but I'm blanking on this.
Work as intended meaning, I'm zooming in on an image and zoom in is a nice gradient but scaling down the image disappears in 9 steps. I would like it to scale gradually at a consistent rate.
Edit. I found this in my other class. I think it does what I want but is there be another way to write it?
scaleByAmount = amount/100
if (currentScale<=1) {
newScale = currentScale+currentScale*scaleByAmount;
}
else {
newScale = currentScale+scaleByAmount;
}
It should be $size⋅1.1$ to zoom in, and $size⋅\frac{1}{1.1}$ to zoom out. Since $size⋅1$ is just the original size, so $size⋅0.1=size⋅(1−0.9)$, which is a $90$ percent decrease.
In general, if you want to increase by $x \%$, then the formula is $size \cdot (1+x \%)$. If you want to decrease by $x%$, then the formula is just $size \cdot (1-x \%)$.