光滑潮湿或吐温算法光滑、算法、潮湿、吐温

2023-09-11 02:41:37 作者:热忱

我想知道的算法平滑潮湿或有人叫它,补间。我想它在Lua preferably但任何帮助。

I would like to know an algorithm for smooth damp or as some people call it, tween. I would like it in Lua preferably but anything will help.

我已经试过看统一的教程,但没有一个算法不能转移code来代替顺利潮湿的功能。

I have tried watching unity tutorials but can't transfer the code without a algorithm to substitute for the smooth damp function.

推荐答案

如果我理解正确的问题,你正在寻找一个宽松的功能。有一个Lua库,它提供了一套在GitHub上缓和功能: https://github.com/EmmanuelOga/easing

If I understand the question correctly, you're looking for an easing function. There is a Lua library that provides a set of easing functions on GitHub: https://github.com/EmmanuelOga/easing

一个例子是:

local function inOutQuad(t, b, c, d)
  t = t / d * 2
  if t < 1 then
    return c / 2 * pow(t, 2) + b
  else
    return -c / 2 * ((t - 1) * (t - 3) - 1) + b
  end
end

其中t =时间,B =开始值,C =价值变动,以及d =持续的时间。

Where t = time, b = begin value, c = change in value, and d = duration.

在这些缓和功能的更多信息,请直接从罗伯特·彭纳在这里(这是上述功能源自)的 http://www.robertpenner.com/easing/

More information on these easing functions is available directly from Robert Penner here (this is where the function above is derived from): http://www.robertpenner.com/easing/