Compare commits
5 Commits
d39eca3159
...
4cb1d142c8
Author | SHA1 | Date |
---|---|---|
|
4cb1d142c8 | |
|
45612344a9 | |
|
db949a9bf9 | |
|
fbdacb1abd | |
|
3be25b7923 |
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package generateletters;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lars
|
||||
*/
|
||||
public class GenerateLetters {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
// TODO code application logic here
|
||||
JFrame frame=new JFrame("Fonts");
|
||||
JLabel label=new JLabel("The quick brown fox jumps over the lazy dog.");
|
||||
label.setFont(new Font("FreeMono",0,64));
|
||||
frame.add(label);
|
||||
frame.pack();
|
||||
for (char c=0; c < 256; c++) {
|
||||
BufferedImage img=new BufferedImage(48,64,BufferedImage.TYPE_INT_ARGB);
|
||||
label.setText(c+"");
|
||||
label.paint(img.createGraphics());
|
||||
new File("freemono_"+(int)c+".png").createNewFile();
|
||||
ImageIO.write(img, "PNG", new File("freemono_"+(int)c+".png"));
|
||||
|
||||
}
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class GenerateLetter {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
// TODO code application logic here
|
||||
JLabel label=new JLabel(args[0]);
|
||||
label.setFont(new Font("FreeMono",0,64));
|
||||
BufferedImage img=new BufferedImage(48*args[0].length(),64,BufferedImage.TYPE_INT_ARGB);
|
||||
label.paint(img.createGraphics());
|
||||
ImageIO.write(img, "PNG", new File(args[1]));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mithrilgalvorn;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author lars
|
||||
*/
|
||||
public class MithrilGalvorn {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
// TODO code application logic here
|
||||
String[][] parts = {{"3d_armor", "chestplate", "leggings", "boots", "helmet"}, {"shields", "shield"}};
|
||||
Object[][] colors = {{"mithril", 300, 300, 255}, {"galvorn", 33, 33, 33}};
|
||||
for (String[] pa: parts) {
|
||||
for (int i = 1; i < pa.length; i++) {
|
||||
String p=pa[i];
|
||||
for (String suffix : new String[]{".png", "_preview.png"}) {
|
||||
String file = pa[0]+"_" + p + "_steel" + suffix;
|
||||
System.out.println(System.getProperty("user.home") + "/.minetest/games/magicctf/mods/"+pa[0]+"/textures/" + file);
|
||||
BufferedImage im = ImageIO.read(new File(System.getProperty("user.home") + "/.minetest/games/magicctf/mods/"+pa[0]+"/textures/" + file));
|
||||
for (Object[] o : colors) {
|
||||
BufferedImage res = new BufferedImage(im.getWidth(), im.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
||||
for (int x = 0; x < im.getWidth(); x++) {
|
||||
for (int y = 0; y < im.getHeight(); y++) {
|
||||
Color col = new Color(im.getRGB(x, y), true);
|
||||
float r = Math.min(1, ((int) (o[1]) / 255.0f) * (float) col.getRed() / 255.0f);
|
||||
float g = Math.min(1, ((int) (o[2]) / 255.0f) * (float) col.getGreen() / 255.0f);
|
||||
float b = Math.min(1, ((int) (o[3]) / 255.0f) * (float) col.getBlue() / 255.0f);
|
||||
if (col.getAlpha() != 0 && col.getRed() != 0 && col.getBlue() != 0 && col.getGreen() != 0) {
|
||||
col = new Color(r, g, b, col.getAlpha() / 255.0f);
|
||||
} else {
|
||||
col = new Color(0, 0, 0, 0);
|
||||
}
|
||||
res.setRGB(x, y, col.getRGB());
|
||||
}
|
||||
}
|
||||
ImageIO.write(res, "PNG", new File(System.getProperty("user.home") + "/.minetest/games/magicctf/mods/"+pa[0]+"/textures/"+pa[0]+"_" + p + "_" + o[0].toString() + suffix));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,2 +1,7 @@
|
|||
# tp-creator
|
||||
Java Project to create TPs - by LMD.
|
||||
# Java Helpers
|
||||
|
||||
## tp-creator
|
||||
Java Project to create TPs - by LMD. No big deal.
|
||||
|
||||
## Galvorn & Mithril Armor Colorizer
|
||||
MT Texture Modifiers aren't stable enough, unfortunately. Therefore, I was too lazy to colorize 'em all by myself ;)
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.awt.Color;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
/**
|
||||
|
@ -17,11 +18,16 @@ import javax.imageio.ImageIO;
|
|||
*/
|
||||
public class TPCreator {
|
||||
|
||||
public static HashMap<String,Color> overlays=new HashMap();
|
||||
static {
|
||||
overlays.put("default_fence_overlay.png",new Color(255,126,126));
|
||||
overlays.put("farming_cotton.png",new Color(0,0,0));
|
||||
}
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
File[] mods=new File("magicctf/mods").listFiles();
|
||||
File[] mods=new File(System.getProperty("user.home")+"/.minetest/games/magicctf/mods").listFiles();
|
||||
float REDUCE=8;
|
||||
for (File mod:mods) {
|
||||
File tex=new File(mod.getCanonicalPath()+File.separator+"textures");
|
||||
|
@ -30,6 +36,7 @@ public class TPCreator {
|
|||
}
|
||||
|
||||
for (File img:tex.listFiles()) {
|
||||
Color c=overlays.get(img.getName());
|
||||
BufferedImage image=ImageIO.read(img);
|
||||
if (image==null) { System.out.println(img);continue; }
|
||||
String ext="";
|
||||
|
@ -40,7 +47,7 @@ public class TPCreator {
|
|||
}
|
||||
ext=img.getName().charAt(i)+ext;
|
||||
}
|
||||
BufferedImage result=null;
|
||||
BufferedImage result;
|
||||
if (ext.equals("png")) {
|
||||
result=new BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_INT_ARGB);
|
||||
}
|
||||
|
@ -51,16 +58,19 @@ public class TPCreator {
|
|||
for (int x=0; x < image.getWidth(); x++) {
|
||||
for (int y=0; y < image.getHeight(); y++) {
|
||||
Color col=new Color(image.getRGB(x, y),true);
|
||||
if (!(c != null && c.getRed() == col.getRed() && c.getBlue() == col.getBlue() && c.getGreen() == col.getGreen()) && col.getAlpha() != 0) {
|
||||
float r=Math.round(col.getRed()/255.0f*REDUCE)/REDUCE;
|
||||
float g=Math.round(col.getGreen()/255.0f*REDUCE)/REDUCE;
|
||||
float b=Math.round(col.getBlue()/255.0f*REDUCE)/REDUCE;
|
||||
col=new Color(r,g,b,col.getAlpha()/255.0f);
|
||||
}
|
||||
else { col=new Color(0,0,0,0); }
|
||||
result.setRGB(x,y,col.getRGB());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {System.out.println(img.getName());continue;}
|
||||
try {
|
||||
if (!ImageIO.write(result, ext, new File("tp/"+img.getName()))) { System.out.println("FAIL"); }
|
||||
if (!ImageIO.write(result, ext, new File(System.getProperty("user.home")+"/.minetest/textures/High Contrast/"+img.getName()))) { System.out.println("FAIL"); }
|
||||
|
||||
} catch (Exception e) {System.out.println(img.getName());}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue