影响线性百分比计算在开始时上升得更快?
我正在做一个非常基本的进度百分比计算,目前它是一个线性计算,所以:
0 -> 0%
max/10 -> 10%
max -> 100%
计算就像这样:
$max = 4000;
$current = 1450;
$percent = ceil($current/$max*100);
简单。
但我需要它让它看起来好像进度条在开始时增加得更快,基本上提高了最初的视觉进度。
我真的应该知道这一点,但我的大脑无法检索古老的数学知识(我责怪喝太多咖啡)。
我想这是我所追求的一种放松;我怎样才能改变这个 - 非常简单 - 公式以对进展曲线产生不同的影响?
注意:这显然是 php,但在任何语言中都应该是相同的。
I'm doing a really basic progress percentage calculation, at the moment it's a linear calculation so:
0 -> 0%
max/10 -> 10%
max -> 100%
The calculation is simply like this:
$max = 4000;
$current = 1450;
$percent = ceil($current/$max*100);
Easy as.
but I need it to make it look as if the progress bar increases quicker at the beginning, basically boosting the initial visual progress.
I really should know that but my brain isn't retrieving way old maths (I blame too much coffee).
I guess it's a kind of easing I'm after; how can I change this - very simple - formula to have a different affect on the progression curve?
Note: That's php obviously, but that should be the same in any language.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用带有小参数的二次调整 (
$sf
)。这与您的
$sf=0
相同。但是您可以调整 $sf 以获得您想要的行为。You can use a quadratic adjustment with a small parameter (
$sf
).This is the same as yours for
$sf=0
. However you can tweak $sf to get the behavior you want.一种这样的曲线是正弦曲线。
打印:
One such curve is sine.
That prints: