|
@@ -26,6 +26,8 @@ function removeTransparency(canvas) {
|
|
|
return canvas;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+// checks if the given +canvas+ has any pixel that is not fully opaque
|
|
|
function hasTransparency(canvas) {
|
|
|
var ctx = canvas.getContext("2d");
|
|
|
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
|
|
@@ -38,6 +40,8 @@ function hasTransparency(canvas) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+// resize the +src+ canvas by +scale+
|
|
|
+// returns a new canvas
|
|
|
function resize(src, scale) {
|
|
|
var dst = new Canvas();
|
|
|
dst.width = scale * src.width;
|
|
@@ -51,6 +55,8 @@ function resize(src, scale) {
|
|
|
return dst;
|
|
|
}
|
|
|
|
|
|
+// 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();
|
|
|
dst.width = scale * width;
|
|
@@ -64,6 +70,7 @@ function getPart(src, x, y, width, height, scale) {
|
|
|
return dst;
|
|
|
}
|
|
|
|
|
|
+// flip the +src+ canvas horizontally
|
|
|
function flip(src) {
|
|
|
var dst = new Canvas();
|
|
|
dst.width = src.width;
|
|
@@ -78,6 +85,11 @@ function flip(src) {
|
|
|
var skew_a = 26 / 45; // 0.57777777
|
|
|
var skew_b = skew_a * 2; // 1.15555555
|
|
|
|
|
|
+// renders a player model with the given skin +img+ and +scale+
|
|
|
+// +overlay+ - wether the extra skin layer is rendered
|
|
|
+// +is_body+ - false for head only
|
|
|
+// +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();
|
|
|
canvas.width = scale * 20;
|