Mercurial > hg > ristipolku
annotate game/Interpolate.java @ 187:c9b743e32567
Improve IDMButton scaled click movement.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 16 Mar 2017 14:19:25 +0200 |
parents | e8eeac403e5f |
children |
rev | line source |
---|---|
1 | 1 /* |
2 * Class for smooth non-linear interpolation between two given values in N steps | |
151 | 3 * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org> |
1 | 4 */ |
5 package game; | |
6 | |
7 import java.util.*; | |
8 | |
9 public class Interpolate | |
10 { | |
106
41c6cca69d60
Make new pieces appear gradually, and same effect for swapping.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
11 public float start, end, steps; |
1 | 12 |
7 | 13 public Interpolate(float start, float end, float steps) |
1 | 14 { |
15 | 15 this.start = start; |
16 this.end = end; | |
17 this.steps = steps; | |
1 | 18 } |
134
4c0dec72e2f0
Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
19 |
7 | 20 public float getValue(float step) |
1 | 21 { |
15 | 22 float n = step / steps; |
23 float v = n * n * (3.0f - 2.0f * n); | |
24 return (start * v) + (end * (1.0f - v)); | |
1 | 25 } |
26 } |