Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
textures : allTextures,
images : allImages
});
var color = defaultValue(diffuse, [1.0, 1.0, 1.0, 1.0]);
// For jimp
color[0] *= 255;
color[1] *= 255;
color[2] *= 255;
color[3] *= 255;
var newJimpImage = allImages[newImageID].extras._pipeline.jimpImage;
var resolution = state.resolution;
newJimpImage.resize(resolution, resolution);
var hexColor = Jimp.rgbaToInt(color[0], color[1], color[2], color[3]);
for (var x = 0; x < resolution; x++) {
for (var y = 0; y < resolution; y++) {
newJimpImage.setPixelColor(x, y, hexColor);
}
}
primitive.material = newMaterialID;
return allImages[newImageID];
}
var textureID = diffuse;
var imageID = allTextures[textureID].source;
if (materialsSeen.hasOwnProperty(materialID)) {
// Check if the material is unique. If not, clone material, texture, and image
cloneAndSetupMaterialTextureImage({
newMaterialID : newMaterialID,
// For every pixel in the image...
for (let x = 0; x < width; x++) {
for (let y = 0; y < height; y++) {
// Do some work to get the RGB value as an array: [R,G,B]
const originalColorHex = image.getPixelColor(x, y);
const originalColorRgb = jimp.intToRGBA(originalColorHex);
const pixelPoint = [originalColorRgb.r, originalColorRgb.g, originalColorRgb.b];
// Ask the KNN instance what the closest color from the scheme is
const closestColor = mapper.predict(pixelPoint);
// Then get that color in hex format, and set the pixel to the new color
const newColor = colors_16.data[colors_16.labels.indexOf(closestColor.label)];
const newColorHex = jimp.rgbaToInt(newColor[0], newColor[1], newColor[2], 255);
image.setPixelColor(newColorHex, x, y);
}
}
const ext = image.getExtension();
image.write(filename.replace('.'+ext, '') + '_16.' + ext);
})
.catch(err => {
var Tesseract = require('tesseract.js'); //For OCR
var Jimp = require('jimp'); //For image processing
var fs = require('fs');
var what2Scan = process.argv[2] || "keep2share.cc"; //Start parameter
var white = Jimp.rgbaToInt(255, 255, 255, 255);
var black = Jimp.rgbaToInt(0, 0, 0, 255);
var gray = Jimp.rgbaToInt(200, 200, 200, 255);
var inputPic = 'input.gif';
//inputPic = 'c2.PNG';
console.log("Running ->", what2Scan);
if (what2Scan == "keep2share.cc") {
console.log("keep2share.cc");
getKeep2shareSText(inputPic, function (content) {
fs.writeFile('result.txt', content["text"], (err) => {
if (err) throw err;
fs.writeFile('log.txt', JSON.stringify(content), (err) => {
process.exit();
});
input.set(i, j, 0, square.get(i, j, 0));
}
}
var predicted = net.forward(input);
var u = Utils.clamp(predicted.get(0,0,0), -U_MAX, U_MAX);
var v = Utils.clamp(predicted.get(0,0,0), -V_MAX, V_MAX);
var center = SQUARE_SIZE/2;
var rgb = YUVToRGB({
y: square.get(center, center, 0),
u: u,
v: v
});
colorized.setPixelColor(jimp.rgbaToInt(Math.floor(rgb.r*255), Math.floor(rgb.g*255), Math.floor(rgb.b*255), 255), x, y);
bar.tick();
}
}
colorized.write( "out.jpg", function() {
console.log("Wrote image...");
});
});
)).then(images => {
const output = new Jimp(ITEM_SIZE * 6, ITEM_SIZE + FONT_SIZE);
for (let i = 0; i < 6; i++) {
output.composite(images[i], ITEM_SIZE * i, FONT_SIZE);
}
fillRectangle(output, Jimp.rgbaToInt(0, 0, 0, 255), 0, 4, ITEM_SIZE * 6, FONT_SIZE - 4);
return fontPromise.then(font => {
const itemPower = event.Victim.AverageItemPower;
const gearScore = Math.round(itemPower).toLocaleString();
const scoreDistance = itemPower > 999 ? 52
: itemPower > 99 ? 35
: itemPower > 9 ? 27
: 19;
output.print(font, ITEM_SIZE * 6 - scoreDistance - FONT_SIZE, (FONT_SIZE - 18) / 2, gearScore);
const killFame = event.TotalVictimKillFame.toLocaleString();
output.print(font, FONT_SIZE + 12, (FONT_SIZE - 18) / 2, killFame);
if (event.TotalVictimKillFame < config.kill.minFame) {
output.crop(0, 0, ITEM_SIZE * 6, FONT_SIZE);
}
const toHex = (color) => rgbaToInt(color.r, color.g, color.b, color.a)
setPixel(x, y, color) {
const intColor = Jimp.rgbaToInt(
color.red() * 255,
color.green() * 255,
color.blue() * 255,
color.alpha() * 255
);
this.image.setPixelColor(intColor, x, y);
return intColor;
}
DRAW_MAP_PNG: function (options, callback) {
const COLORS = {
floor: Jimp.rgbaToInt(0, 118, 255, 255),
obstacle_weak: Jimp.rgbaToInt(102, 153, 255, 255),
obstacle_strong: Jimp.rgbaToInt(82, 174, 255, 255),
path: Jimp.rgbaToInt(255, 255, 255, 255)
};
const settings = Object.assign({
drawPath: true,
drawCharger: true,
drawRobot: true,
border: 2,
scale: 4,
crop_x1: 0,
crop_x2: Number.MAX_VALUE,
crop_y1: 0,
crop_y2: Number.MAX_VALUE
}, options.settings);
const BOUNDS = {
x1: Math.min(settings.crop_x1, options.parsedMapData.image.dimensions.width-1),
DRAW_MAP_PNG: function (options, callback) {
const COLORS = {
floor: Jimp.rgbaToInt(0, 118, 255, 255),
obstacle_weak: Jimp.rgbaToInt(102, 153, 255, 255),
obstacle_strong: Jimp.rgbaToInt(82, 174, 255, 255),
path: Jimp.rgbaToInt(255, 255, 255, 255)
};
const settings = Object.assign({
drawPath: true,
drawCharger: true,
drawRobot: true,
border: 2,
scale: 4,
crop_x1: 0,
crop_x2: Number.MAX_VALUE,
crop_y1: 0,
crop_y2: Number.MAX_VALUE
}, options.settings);
const BOUNDS = {