Jake 10 роки тому
батько
коміт
a2f40045a9
3 змінених файлів з 17 додано та 2 видалено
  1. 9 1
      modules/renders.js
  2. 2 0
      modules/skins.js
  3. 6 1
      routes/renders.js

+ 9 - 1
modules/renders.js

@@ -1,4 +1,4 @@
-// Skin locations are based on the work of Confuser
+// Skin locations are based on the work of Confuser, with 1.8 updates by Jake0oo0
 // https://github.com/confuser/serverless-mc-skin-viewer
 // Permission to use & distribute https://github.com/confuser/serverless-mc-skin-viewer/blob/master/LICENSE
 
@@ -126,6 +126,10 @@ exp.draw_body = function(skin_canvas, model_ctx, scale) {
   }
 };
 
+// sets up the necessary components to draw the skin model
+// uses the +img+ skin from the +uuid+ with options of drawing
+// the +helm+ and the +body+
+// callback contains error, image buffer
 exp.draw_model = function(uuid, img, scale, helm, body, callback) {
   var image = new Image();
 
@@ -168,6 +172,8 @@ exp.draw_model = function(uuid, img, scale, helm, body, callback) {
   image.src = img;
 };
 
+// helper method to open a render from +renderpath+
+// callback contains error, image buffer
 exp.open_render = function(renderpath, callback) {
   fs.readFile(renderpath, function (err, buf) {
     if (err) {
@@ -177,6 +183,8 @@ exp.open_render = function(renderpath, callback) {
   });
 };
 
+// scales an image from the +imagedata+ onto the +context+
+// scaled by a factor of +scale+ with options +d_x+ and +d_y+
 function scale_image(imageData, context, d_x, d_y, scale) {
   var width = imageData.width;
   var height = imageData.height;

+ 2 - 0
modules/skins.js

@@ -93,6 +93,8 @@ exp.default_skin = function(uuid) {
   }
 };
 
+// helper method for opening a skin file from +skinpath+
+// callback contains error, image buffer
 exp.open_skin = function(skinpath, callback) {
   fs.readFile(skinpath, function (err, buf) {
     if (err) {

+ 6 - 1
routes/renders.js

@@ -77,6 +77,9 @@ router.get('/:type/:uuid.:ext?', function(req, res) {
     handle_default(500, status);
   }
 
+
+  // default alex/steve images can be rendered, but
+  // custom images will not be
   function handle_default(http_status, img_status) {
     if (def && def != "steve" && def != "alex") {
       res.writeHead(301, {
@@ -91,8 +94,10 @@ router.get('/:type/:uuid.:ext?', function(req, res) {
       def = def || skins.default_skin(uuid);
       fs.readFile("public/images/" + def + "_skin.png", function (err, buf) {
         if (err) {
-          logging.error("error rendering default image: " + err);
+          // errored while loading the default image, continuing with null image
+          logging.error("error loading default render image: " + err);
         }
+        // we render the default skins, but not custom images
         renders.draw_model(uuid, buf, scale, helm, body, function(err, def_img) {
           if (err) {
             logging.log("error while rendering default image: " + err);