easeInOutCubic maps t ∈ [0,1] to [0,1] with a smooth-start/smooth-end shape: slow entrance, fast middle, slow exit. The classic curve for "object passing through" motion.
(t float64)
| 235 | // shape: slow entrance, fast middle, slow exit. The classic curve for |
| 236 | // "object passing through" motion. |
| 237 | func easeInOutCubic(t float64) float64 { |
| 238 | if t < 0 { |
| 239 | return 0 |
| 240 | } |
| 241 | if t > 1 { |
| 242 | return 1 |
| 243 | } |
| 244 | if t < 0.5 { |
| 245 | return 4 * t * t * t |
| 246 | } |
| 247 | p := 2*t - 2 |
| 248 | return 0.5*p*p*p + 1 |
| 249 | } |
| 250 | |
| 251 | func (m harness) Update(msg tea.Msg) (tea.Model, tea.Cmd) { |
| 252 | switch msg := msg.(type) { |