mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-16 10:44:51 +00:00
Initial Commit
This commit is contained in:
1 parent
397135f687
commit
0f32dd8620
82 files changed
+10693
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package codechicken.lib.colour;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import codechicken.lib.math.MathHelper;
|
||||
import codechicken.lib.render.TextureUtils;
|
||||
|
||||
public class CustomGradient
|
||||
{
|
||||
public int[] gradient;
|
||||
|
||||
public CustomGradient(ResourceLocation textureFile)
|
||||
{
|
||||
BufferedImage img = TextureUtils.loadBufferedImage(textureFile);
|
||||
int[] data = new int[img.getWidth()];
|
||||
img.getRGB(0, 0, img.getWidth(), 1, data, 0, img.getWidth());
|
||||
gradient = new int[img.getWidth()];
|
||||
for(int i = 0; i < data.length; i++)
|
||||
gradient[i] = (data[i]<<8)|(((data[i])>>24)&0xFF);
|
||||
}
|
||||
|
||||
public ColourRGBA getColour(double position)
|
||||
{
|
||||
return new ColourRGBA(getColourI(position));
|
||||
}
|
||||
|
||||
public int getColourI(double position)
|
||||
{
|
||||
int off = (int)MathHelper.clip(gradient.length*position, 0, gradient.length-1);
|
||||
return gradient[off];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user