Merge branch 'develop-textures' into develop
# Conflicts: # .idea/modules.xml # src/main/java/eu/mhsl/minecraft/pixelpics/Main.java # src/main/java/eu/mhsl/minecraft/pixelpics/render/raytrace/AdvancedRaytracer.java # src/main/java/eu/mhsl/minecraft/pixelpics/render/raytrace/DefaultRaytracer.java # src/main/java/eu/mhsl/minecraft/pixelpics/render/registry/AdvancedModelRegistry.java # src/main/resources/plugin.yml
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
package eu.mhsl.minecraft.pixelpics;
|
||||
package eu.mhsl.minecraft.pixelpic;
|
||||
|
||||
import eu.mhsl.minecraft.pixelpics.commands.PixelPicsCommand;
|
||||
import eu.mhsl.minecraft.pixelpics.render.render.DefaultScreenRenderer;
|
||||
import eu.mhsl.minecraft.pixelpics.render.render.Renderer;
|
||||
import eu.mhsl.minecraft.pixelpic.commands.PixelPicCommand;
|
||||
import eu.mhsl.minecraft.pixelpic.render.render.DefaultScreenRenderer;
|
||||
import eu.mhsl.minecraft.pixelpic.render.render.Renderer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
private static Main instance;
|
||||
private Renderer screenRenderer;
|
||||
@@ -13,68 +24,78 @@ public final class Main extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
Bukkit.getPluginCommand("pixelPics").setExecutor(new PixelPicsCommand());
|
||||
//
|
||||
// Bukkit.getPluginCommand("test2").setExecutor((sender, command, label, args) -> {
|
||||
// if(!(sender instanceof Player player)) return false;
|
||||
// Bukkit.broadcast(Component.text("HI"));
|
||||
//
|
||||
// Resolution.Pixels pixels = Resolution.Pixels._256P;
|
||||
// Resolution.AspectRatio aspectRatio = Resolution.AspectRatio._1_1;
|
||||
// Resolution resolution = new Resolution(pixels, aspectRatio);
|
||||
// BufferedImage image = screenRenderer.render((Player) sender, resolution);
|
||||
// Bukkit.broadcast(Component.text(image.toString()));
|
||||
//
|
||||
// File file = new File(getDataFolder(), "Bild" + ".png");
|
||||
// try {
|
||||
// getDataFolder().mkdir();
|
||||
// ImageIO.write(image, "png", file);
|
||||
// } catch (Exception e) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// ItemStack map = new ItemStack(Material.FILLED_MAP, 1);
|
||||
// MapMeta meta = (MapMeta) map.getItemMeta();
|
||||
// MapView mapView = Bukkit.createMap(Bukkit.getWorlds().getFirst());
|
||||
// mapView.addRenderer(new ImageMapRenderer(image, 0, 0));
|
||||
// meta.setMapView(mapView);
|
||||
// map.setItemMeta(meta);
|
||||
// player.getInventory().addItem(map);
|
||||
//
|
||||
// ItemStack map2 = new ItemStack(Material.FILLED_MAP, 1);
|
||||
// MapMeta meta1 = (MapMeta) map2.getItemMeta();
|
||||
// MapView mapView4 = Bukkit.createMap(Bukkit.getWorlds().getFirst());
|
||||
// mapView4.addRenderer(new ImageMapRenderer(image, 1, 0));
|
||||
// meta1.setMapView(mapView4);
|
||||
// map2.setItemMeta(meta1);
|
||||
// player.getInventory().addItem(map2);
|
||||
//
|
||||
// ItemStack map3 = new ItemStack(Material.FILLED_MAP, 1);
|
||||
// MapMeta meta2 = (MapMeta) map3.getItemMeta();
|
||||
// MapView mapView3 = Bukkit.createMap(Bukkit.getWorlds().getFirst());
|
||||
// mapView3.addRenderer(new ImageMapRenderer(image, 0, 1));
|
||||
// meta2.setMapView(mapView3);
|
||||
// map3.setItemMeta(meta2);
|
||||
// player.getInventory().addItem(map3);
|
||||
//
|
||||
// ItemStack map4 = new ItemStack(Material.FILLED_MAP, 1);
|
||||
// MapMeta meta3 = (MapMeta) map4.getItemMeta();
|
||||
// MapView mapView2 = Bukkit.createMap(Bukkit.getWorlds().getFirst());
|
||||
// mapView2.addRenderer(new ImageMapRenderer(image, 1, 1));
|
||||
// meta3.setMapView(mapView2);
|
||||
// map4.setItemMeta(meta3);
|
||||
// player.getInventory().addItem(map4);
|
||||
//
|
||||
// player.updateInventory();
|
||||
//
|
||||
// return true;
|
||||
// });
|
||||
extractJsonResources();
|
||||
|
||||
Bukkit.getPluginCommand("pixelPic").setExecutor(new PixelPicCommand());
|
||||
|
||||
Bukkit.getPluginCommand("test").setExecutor((sender, command, label, args) -> {
|
||||
Material.getMaterial("acacia_button");
|
||||
Bukkit.broadcast(Component.text(Material.STONE.getBlockTranslationKey().replace("block.minecraft.", "")));
|
||||
|
||||
if(!(sender instanceof Player player))
|
||||
throw new IllegalStateException("Dieser Command kann nur von einem Spieler ausgeführt werden!");
|
||||
|
||||
File blockDir = new File(getDataFolder(), "models/block");
|
||||
for (File file : blockDir.listFiles()) {
|
||||
String blockName = file.getName().substring(0, file.getName().lastIndexOf('.'));
|
||||
Material material = Material.getMaterial(blockName.toUpperCase());
|
||||
System.out.println(material);
|
||||
if(material == null) {
|
||||
System.out.println(blockName);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
public void extractJsonResources() {
|
||||
String resourcePath = "models/block/"; // Pfad im JAR
|
||||
File outputDir = new File(getDataFolder(), resourcePath);
|
||||
if (outputDir.exists()) return;
|
||||
outputDir.mkdirs();
|
||||
|
||||
try {
|
||||
URL jarUrl = getClass().getProtectionDomain().getCodeSource().getLocation();
|
||||
File jarFile = new File(jarUrl.toURI());
|
||||
|
||||
try (JarFile jar = new JarFile(jarFile)) {
|
||||
Enumeration<JarEntry> entries = jar.entries();
|
||||
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
String entryName = entry.getName();
|
||||
|
||||
// Nur JSON-Dateien im gewünschten Ordner
|
||||
if (entryName.startsWith(resourcePath) && entryName.endsWith(".json")) {
|
||||
InputStream in = getResource(entryName);
|
||||
if (in == null) continue;
|
||||
|
||||
File outFile = new File(getDataFolder(), entryName);
|
||||
outFile.getParentFile().mkdirs(); // Ordnerstruktur sicherstellen
|
||||
|
||||
try (OutputStream out = new FileOutputStream(outFile)) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
System.out.println("Extrahiert: " + entryName);
|
||||
}
|
||||
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Renderer getScreenRenderer() {
|
||||
if(this.screenRenderer == null) this.screenRenderer = new DefaultScreenRenderer();
|
||||
return this.screenRenderer;
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package eu.mhsl.minecraft.pixelpic.render.raytrace;
|
||||
|
||||
import eu.mhsl.minecraft.pixelpic.render.model.Model;
|
||||
import eu.mhsl.minecraft.pixelpic.render.registry.AdvancedModelRegistry;
|
||||
import eu.mhsl.minecraft.pixelpic.render.registry.ModelRegistry;
|
||||
import eu.mhsl.minecraft.pixelpic.render.util.BlockRaytracer;
|
||||
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
|
||||
import eu.mhsl.minecraft.pixelpic.render.util.MathUtil;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class AdvancedRaytracer implements Raytracer {
|
||||
private final int maxDistance;
|
||||
private final int reflectionDepth;
|
||||
|
||||
private final AdvancedModelRegistry textureRegistry;
|
||||
private Block reflectedBlock;
|
||||
|
||||
public AdvancedRaytracer() {
|
||||
this(300, 10);
|
||||
}
|
||||
|
||||
public AdvancedRaytracer(int maxDistance, int reflectionDepth) {
|
||||
this.maxDistance = maxDistance;
|
||||
this.reflectionDepth = reflectionDepth;
|
||||
|
||||
this.textureRegistry = new AdvancedModelRegistry();
|
||||
this.textureRegistry.initialize();
|
||||
|
||||
this.reflectedBlock = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int trace(World world, Vector point, Vector direction) {
|
||||
return trace(world, point, direction, reflectionDepth);
|
||||
}
|
||||
|
||||
private int trace(World world, Vector point, Vector direction, int reflectionDepth) {
|
||||
Location loc = point.toLocation(world);
|
||||
loc.setDirection(direction);
|
||||
BlockRaytracer iterator = new BlockRaytracer(loc);
|
||||
int baseColor = Color.fromRGB(65, 89, 252).asRGB();
|
||||
Vector finalIntersection = null;
|
||||
|
||||
int reflectionColor = 0;
|
||||
double reflectionFactor = 0;
|
||||
boolean reflected = false;
|
||||
|
||||
Vector transparencyStart = null;
|
||||
int transparencyColor = 0;
|
||||
double transparencyFactor = 0;
|
||||
|
||||
Material occlusionMaterial = null;
|
||||
BlockData occlusionData = null;
|
||||
|
||||
for (int i = 0; i < maxDistance; i++) {
|
||||
if (!iterator.hasNext()) break;
|
||||
Block block = iterator.next();
|
||||
if (reflectedBlock != null && reflectedBlock.equals(block)) continue;
|
||||
reflectedBlock = null;
|
||||
|
||||
Material material = block.getType();
|
||||
if (material == Material.AIR) {
|
||||
occlusionMaterial = null;
|
||||
occlusionData = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
Model textureModel = textureRegistry.getModel(block.getType(), block.getBlockData(), block.getTemperature(), block.getHumidity());
|
||||
Intersection currentIntersection = Intersection.of(
|
||||
MathUtil.toVector(iterator.getIntersectionFace()),
|
||||
i == 0 ? point : iterator.getIntersectionPoint(),
|
||||
direction
|
||||
);
|
||||
Intersection newIntersection = textureModel.intersect(block, currentIntersection);
|
||||
|
||||
if (newIntersection == null) continue;
|
||||
|
||||
int color = newIntersection.getColor();
|
||||
|
||||
if (!reflected && textureModel.getReflectionFactor() > 0 && reflectionDepth > 0 && (color >> 24) != 0) {
|
||||
reflectedBlock = block;
|
||||
reflectionColor = trace(
|
||||
world,
|
||||
newIntersection.getPoint(),
|
||||
MathUtil.reflectVector(
|
||||
point,
|
||||
direction,
|
||||
newIntersection.getPoint(),
|
||||
newIntersection.getNormal()
|
||||
),
|
||||
reflectionDepth - 1
|
||||
);
|
||||
reflectionFactor = textureModel.getReflectionFactor();
|
||||
reflected = true;
|
||||
}
|
||||
|
||||
if (transparencyStart == null && textureModel.getTransparencyFactor() > 0) {
|
||||
transparencyStart = newIntersection.getPoint();
|
||||
transparencyColor = newIntersection.getColor();
|
||||
transparencyFactor = textureModel.getTransparencyFactor();
|
||||
}
|
||||
|
||||
if (textureModel.isOccluding()) {
|
||||
BlockData data = block.getBlockData();
|
||||
|
||||
if (material == occlusionMaterial && data.equals(occlusionData)) continue;
|
||||
|
||||
occlusionMaterial = material;
|
||||
occlusionData = data;
|
||||
} else {
|
||||
occlusionMaterial = null;
|
||||
occlusionData = null;
|
||||
}
|
||||
|
||||
if (transparencyStart != null && textureModel.getTransparencyFactor() > 0) continue;
|
||||
if ((color >> 24) == 0) continue;
|
||||
|
||||
baseColor = color;
|
||||
finalIntersection = newIntersection.getPoint();
|
||||
break;
|
||||
}
|
||||
|
||||
if (transparencyStart != null) {
|
||||
baseColor = MathUtil.weightedColorSum(
|
||||
baseColor,
|
||||
transparencyColor,
|
||||
transparencyFactor,
|
||||
(1
|
||||
- transparencyFactor)
|
||||
* (1 + transparencyStart.distance(finalIntersection == null ? transparencyStart : finalIntersection)
|
||||
/ 5.0));
|
||||
}
|
||||
if (reflected) {
|
||||
baseColor = MathUtil.weightedColorSum(
|
||||
baseColor,
|
||||
reflectionColor,
|
||||
1 - reflectionFactor,
|
||||
reflectionFactor
|
||||
);
|
||||
}
|
||||
|
||||
return baseColor & 0xFFFFFF;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
package eu.mhsl.minecraft.pixelpics.render.raytrace;
|
||||
package eu.mhsl.minecraft.pixelpic.render.raytrace;
|
||||
|
||||
import eu.mhsl.minecraft.pixelpics.render.model.Model;
|
||||
import eu.mhsl.minecraft.pixelpics.render.registry.DefaultModelRegistry;
|
||||
import eu.mhsl.minecraft.pixelpics.render.registry.ModelRegistry;
|
||||
import eu.mhsl.minecraft.pixelpics.render.util.BlockRaytracer;
|
||||
import eu.mhsl.minecraft.pixelpics.render.util.Intersection;
|
||||
import eu.mhsl.minecraft.pixelpics.render.util.MathUtil;
|
||||
import eu.mhsl.minecraft.pixelpic.render.model.Model;
|
||||
import eu.mhsl.minecraft.pixelpic.render.registry.AdvancedModelRegistry;
|
||||
import eu.mhsl.minecraft.pixelpic.render.registry.ModelRegistry;
|
||||
import eu.mhsl.minecraft.pixelpic.render.util.BlockRaytracer;
|
||||
import eu.mhsl.minecraft.pixelpic.render.util.Intersection;
|
||||
import eu.mhsl.minecraft.pixelpic.render.util.MathUtil;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -29,7 +30,7 @@ public class DefaultRaytracer implements Raytracer {
|
||||
this.maxDistance = maxDistance;
|
||||
this.reflectionDepth = reflectionDepth;
|
||||
|
||||
this.textureRegistry = new DefaultModelRegistry();
|
||||
this.textureRegistry = new AdvancedModelRegistry();
|
||||
this.textureRegistry.initialize();
|
||||
|
||||
this.reflectedBlock = null;
|
||||
@@ -71,6 +72,7 @@ public class DefaultRaytracer implements Raytracer {
|
||||
continue;
|
||||
}
|
||||
|
||||
Biome biome = block.getBiome();
|
||||
Model textureModel = textureRegistry.getModel(block);
|
||||
Intersection currentIntersection = Intersection.of(
|
||||
MathUtil.toVector(iterator.getIntersectionFace()),
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
package eu.mhsl.minecraft.pixelpic.render.registry;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import eu.mhsl.minecraft.pixelpic.Main;
|
||||
import eu.mhsl.minecraft.pixelpic.render.model.AbstractModel;
|
||||
import eu.mhsl.minecraft.pixelpic.render.model.Model;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
|
||||
import static eu.mhsl.minecraft.pixelpic.render.registry.DefaultModelRegistry.TEXTURE_SIZE;
|
||||
|
||||
public class AdvancedModelRegistry implements ModelRegistry {
|
||||
private final Gson gson = new Gson();
|
||||
|
||||
private final Map<Material, Map<BlockData, Model>> modelMap = new HashMap<>();
|
||||
private final Set<String> tintedBlocks = Set.of("grass", "grass_block", "leaves", "oak_leaves", "water", "vine", "sugar_cane");
|
||||
|
||||
public record BlockInfo(String parent, BlockTextures textures){}
|
||||
public record BlockTextures(
|
||||
String texture,
|
||||
String bottom,
|
||||
String top,
|
||||
String all,
|
||||
String particle,
|
||||
String end,
|
||||
String side,
|
||||
String cross,
|
||||
String rail,
|
||||
String overlay
|
||||
){}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
System.out.println(modelMap);
|
||||
|
||||
File blockDir = new File(Main.getInstance().getDataFolder(), "models/block");
|
||||
for (File file : Objects.requireNonNull(blockDir.listFiles())) {
|
||||
addModelFromFile(file);
|
||||
}
|
||||
|
||||
try {
|
||||
registerModel(Material.LAVA, AbstractModel.Builder.createSimple(getTextureArray("lava_still"))
|
||||
.transparency(0.15).reflection(0.05).occlusion().build());
|
||||
registerModel(Material.WATER, AbstractModel.Builder.createSimple(getTextureArray("water_still"))
|
||||
.transparency(0.60).reflection(0.1).occlusion().build());
|
||||
} catch (Exception ignored) { }
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getModel(Block block) {
|
||||
return ModelRegistry.super.getModel(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getModel(Material material, BlockData blockData) {
|
||||
return getModel(material, blockData, 0.8, 0.4);
|
||||
}
|
||||
|
||||
public Model getModel(Material material, BlockData blockData, double temperature, double humidity) {
|
||||
return modelMap.computeIfAbsent(material, key -> new HashMap<>()).getOrDefault(blockData,
|
||||
blockData == null ? getDefaultModel()
|
||||
: modelMap.get(material).getOrDefault(null, getDefaultModel()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model getDefaultModel() {
|
||||
return AbstractModel.Builder.createStatic(Color.PURPLE.asRGB()).build();
|
||||
}
|
||||
|
||||
private void registerModel(Material material, Model blockModel) {
|
||||
modelMap.computeIfAbsent(material, key -> new HashMap<>())
|
||||
.put(null, blockModel);
|
||||
}
|
||||
|
||||
private void addModelFromFile(File file) {
|
||||
String blockName = file.getName().substring(0, file.getName().lastIndexOf('.'));
|
||||
Material material = Material.getMaterial(blockName.toUpperCase());
|
||||
if(material == null) return;
|
||||
|
||||
Model model = getModelFromFile(file);
|
||||
if(model == null) return;
|
||||
|
||||
registerModel(material, model);
|
||||
}
|
||||
|
||||
private Model getModelFromFile(File file) {
|
||||
try (Reader reader = new FileReader(file)) {
|
||||
BlockInfo blockInfo = gson.fromJson(reader, BlockInfo.class);
|
||||
|
||||
if(blockInfo.textures.all != null) {
|
||||
return AbstractModel.Builder.createSimple(
|
||||
getTextureArray(blockInfo.textures.all.substring(blockInfo.textures.all.lastIndexOf('/') + 1))
|
||||
).build();
|
||||
}
|
||||
if(blockInfo.textures.cross != null) {
|
||||
return AbstractModel.Builder.createCross(
|
||||
getTextureArray(blockInfo.textures.cross.substring(blockInfo.textures.cross.lastIndexOf('/') + 1))
|
||||
).build();
|
||||
}
|
||||
if(blockInfo.textures.side != null && blockInfo.textures.bottom != null && blockInfo.textures.top != null) {
|
||||
return AbstractModel.Builder.createMulti(
|
||||
getTextureArray(blockInfo.textures.top.substring(blockInfo.textures.top.lastIndexOf('/') + 1)),
|
||||
getTextureArray(blockInfo.textures.side.substring(blockInfo.textures.side.lastIndexOf('/') + 1)),
|
||||
getTextureArray(blockInfo.textures.bottom.substring(blockInfo.textures.bottom.lastIndexOf('/') + 1))
|
||||
).build();
|
||||
}
|
||||
if(blockInfo.textures.side != null && blockInfo.textures.end != null) {
|
||||
return AbstractModel.Builder.createMulti(
|
||||
getTextureArray(blockInfo.textures.end.substring(blockInfo.textures.end.lastIndexOf('/') + 1)),
|
||||
getTextureArray(blockInfo.textures.side.substring(blockInfo.textures.side.lastIndexOf('/') + 1)),
|
||||
getTextureArray(blockInfo.textures.end.substring(blockInfo.textures.end.lastIndexOf('/') + 1))
|
||||
).build();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int[][] getTextureArray(String textureName) {
|
||||
int[][] texture = new int[TEXTURE_SIZE][TEXTURE_SIZE];
|
||||
BufferedImage img;
|
||||
URL url = this.getClass().getClassLoader().getResource(String.format("textures/block/%s.png", textureName));
|
||||
if (url == null) {
|
||||
throw new RuntimeException("Block Texture Resource not found.");
|
||||
}
|
||||
try (InputStream input = url.openConnection().getInputStream()) {
|
||||
img = ImageIO.read(input);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
for (int pixelY = 0; pixelY < TEXTURE_SIZE; pixelY++) {
|
||||
for (int pixelX = 0; pixelX < TEXTURE_SIZE; pixelX++) {
|
||||
texture[TEXTURE_SIZE - 1 - pixelY][TEXTURE_SIZE - 1 - pixelX] = img.getRGB(pixelX, pixelY);
|
||||
}
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
private int tintPixel(int baseColor, int tintColor) {
|
||||
int a = (baseColor >> 24) & 0xFF;
|
||||
int r = ((baseColor >> 16) & 0xFF) * ((tintColor >> 16) & 0xFF) / 255;
|
||||
int g = ((baseColor >> 8) & 0xFF) * ((tintColor >> 8) & 0xFF) / 255;
|
||||
int b = (baseColor & 0xFF) * (tintColor & 0xFF) / 255;
|
||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user