-
Notifications
You must be signed in to change notification settings - Fork 497
/
SubIcon.java
69 lines (56 loc) · 1.33 KB
/
SubIcon.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package buildcraft.core.lib.render;
import net.minecraft.util.IIcon;
public class SubIcon implements IIcon {
private final IIcon icon;
private float u, v;
private final int w, h;
private float uScale, vScale;
public SubIcon(IIcon icon, int u, int v) {
this(icon, u, v, 16, 16);
}
public SubIcon(IIcon icon, int u, int v, int w, int h) {
this.icon = icon;
this.uScale = icon.getMaxU() - icon.getMinU();
this.vScale = icon.getMaxV() - icon.getMinV();
this.u = icon.getMinU() + (this.uScale * u / icon.getIconWidth());
this.v = icon.getMinV() + (this.vScale * v / icon.getIconHeight());
this.w = w;
this.h = h;
}
@Override
public int getIconWidth() {
return w;
}
@Override
public int getIconHeight() {
return h;
}
@Override
public float getMinU() {
return u;
}
@Override
public float getMaxU() {
return u + (uScale * w / icon.getIconWidth());
}
@Override
public float getInterpolatedU(double uu) {
return u + (uScale * (float) uu / (float) icon.getIconWidth());
}
@Override
public float getMinV() {
return v;
}
@Override
public float getMaxV() {
return v + (vScale * h / icon.getIconHeight());
}
@Override
public float getInterpolatedV(double vv) {
return v + (vScale * (float) vv / (float) icon.getIconHeight());
}
@Override
public String getIconName() {
return icon.getIconName();
}
}