update to node 12

This commit is contained in:
jomo
2020-03-21 01:50:50 +01:00
parent 1816b18b12
commit 168457dfd9
7 changed files with 1533 additions and 748 deletions

View File

@@ -91,7 +91,7 @@ exp.get_uuid_info = function(profile, type, callback) {
var properties = Object.get(profile, "properties") || [];
properties.forEach(function(prop) {
if (prop.name === "textures") {
var json = new Buffer(prop.value, "base64").toString();
var json = new Buffer.from(prop.value, "base64").toString();
profile = JSON.parse(json);
}
});

View File

@@ -4,8 +4,7 @@
var logging = require("./logging");
var fs = require("fs");
var Canvas = require("canvas");
var Image = Canvas.Image;
var cvs = require("canvas");
var exp = {};
// set alpha values to 255
@@ -43,7 +42,7 @@ function hasTransparency(canvas) {
// resize the +src+ canvas by +scale+
// returns a new canvas
function resize(src, scale) {
var dst = new Canvas();
var dst = cvs.createCanvas();
dst.width = scale * src.width;
dst.height = scale * src.height;
var context = dst.getContext("2d");
@@ -58,7 +57,7 @@ function resize(src, scale) {
// get a rectangular part of the +src+ canvas
// the returned canvas is scaled by factor +scale+
function getPart(src, x, y, width, height, scale) {
var dst = new Canvas();
var dst = cvs.createCanvas();
dst.width = scale * width;
dst.height = scale * height;
var context = dst.getContext("2d");
@@ -72,7 +71,7 @@ function getPart(src, x, y, width, height, scale) {
// flip the +src+ canvas horizontally
function flip(src) {
var dst = new Canvas();
var dst = cvs.createCanvas();
dst.width = src.width;
dst.height = src.height;
var context = dst.getContext("2d");
@@ -91,14 +90,12 @@ var skew_b = skew_a * 2; // 1.15555555
// +slim+ - wether the player has a slim skin model
// callback: error, image buffer
exp.draw_model = function(rid, img, scale, overlay, is_body, slim, callback) {
var canvas = new Canvas();
var canvas = cvs.createCanvas();
canvas.width = scale * 20;
canvas.height = scale * (is_body ? 45.1 : 18.5);
var ctx = canvas.getContext("2d");
var skin = new Image();
skin.onload = function() {
cvs.loadImage(img).then((skin) => {
var old_skin = skin.height === 32;
var arm_width = slim ? 3 : 4;
@@ -182,7 +179,7 @@ exp.draw_model = function(rid, img, scale, overlay, is_body, slim, callback) {
if (is_body) {
// pre-render front onto separate canvas
var front = new Canvas();
var front = cvs.createCanvas();
front.width = scale * 16;
front.height = scale * 24;
var frontc = front.getContext("2d");
@@ -243,7 +240,7 @@ exp.draw_model = function(rid, img, scale, overlay, is_body, slim, callback) {
y = 0;
z = z_offset;
ctx.setTransform(1, skew_a, 0, skew_b, 0, 0);
ctx.drawImage(head_right, x + y, z - y - 0.5, head_right.width, head_right.height + 1);
ctx.drawImage(head_right, x + y, z - y - 0.5, head_right.width + 0.5, head_right.height + 1);
canvas.toBuffer(function(err, buf) {
if (err) {
@@ -251,9 +248,7 @@ exp.draw_model = function(rid, img, scale, overlay, is_body, slim, callback) {
}
callback(err, buf);
});
};
skin.src = img;
});
};
// helper method to open a render from +renderpath+

View File

@@ -2,7 +2,7 @@ var helpers = require("../helpers");
var skins = require("../skins");
var cache = require("../cache");
var path = require("path");
var lwip = require("pajk-lwip");
var lwip = require("@randy.tarampi/lwip");
var url = require("url");
// handle the appropriate 'default=' response

View File

@@ -1,5 +1,5 @@
var logging = require("./logging");
var lwip = require("pajk-lwip");
var lwip = require("@randy.tarampi/lwip");
var fs = require("fs");
var exp = {};