mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Improved draw.js.
This commit is contained in:
parent
c6537a783d
commit
ee9b50264e
@ -74,13 +74,16 @@ function findClosestWoolColor(col) {
|
|||||||
return closestId;
|
return closestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sess = context.remember();
|
|
||||||
|
|
||||||
context.checkArgs(1, 2, "<image> <orientation>");
|
context.checkArgs(1, 2, "<image> <orientation>");
|
||||||
|
|
||||||
var f = context.getSafeFile("drawings", argv[1]);
|
var f = context.getSafeFile("drawings", argv[1]);
|
||||||
|
var sess = context.remember();
|
||||||
|
var upright = argv[2] == "v";
|
||||||
|
|
||||||
if (f != null) {
|
if (!f.exists()) {
|
||||||
|
player.error("Specified file doesn't exist.");
|
||||||
|
} else {
|
||||||
var img = ImageIO.read(f);
|
var img = ImageIO.read(f);
|
||||||
|
|
||||||
var width = img.getWidth();
|
var width = img.getWidth();
|
||||||
@ -92,11 +95,11 @@ if (f != null) {
|
|||||||
for (var y = 0; y < height; y++) {
|
for (var y = 0; y < height; y++) {
|
||||||
var c = new Color(img.getRGB(x, y));
|
var c = new Color(img.getRGB(x, y));
|
||||||
var data = findClosestWoolColor(c);
|
var data = findClosestWoolColor(c);
|
||||||
//added this to enable the user to create images stood up rather than flat on the ground
|
// Added this to enable the user to create images upright
|
||||||
if(argv[2]=="h"){
|
// rather than flat on the ground
|
||||||
|
if (!upright) {
|
||||||
sess.setBlock(origin.add(x, 0, y), new BaseBlock(35, data));
|
sess.setBlock(origin.add(x, 0, y), new BaseBlock(35, data));
|
||||||
}
|
} else {
|
||||||
if(argv[2]=="v"){
|
|
||||||
sess.setBlock(origin.add(x, height - y, 0), new BaseBlock(35, data));
|
sess.setBlock(origin.add(x, height - y, 0), new BaseBlock(35, data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user