add missing documentation

This commit is contained in:
jomo 2016-02-19 19:24:27 +01:00
parent fe16821cb7
commit 96b277b806
6 changed files with 23 additions and 2 deletions

View File

@ -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;

View File

@ -5,6 +5,9 @@ var cache = require("../cache");
var path = require("path");
var url = require("url");
// handle the appropriate 'default=' response
// uses either mhf_steve or mhf_alex (based on +userId+) if no +def+ given
// callback: response object
function handle_default(img_status, userId, size, def, req, err, callback) {
def = def || skins.default_skin(userId);
var defname = def.toLowerCase();

View File

@ -15,6 +15,7 @@ function compile() {
compile();
// GET index request
module.exports = function(req, callback) {
if (config.server.debug_enabled) {
// allow changes without reloading

View File

@ -8,8 +8,9 @@ var path = require("path");
var url = require("url");
var fs = require("fs");
// valid types: head, body
// overlay is query param
// handle the appropriate 'default=' response
// uses either mhf_steve or mhf_alex (based on +userId+) if no +def+ given
// callback: response object
function handle_default(rid, scale, overlay, body, img_status, userId, size, def, req, err, callback) {
def = def || skins.default_skin(userId);
var defname = def.toLowerCase();

View File

@ -5,6 +5,9 @@ var path = require("path");
var lwip = require("lwip");
var url = require("url");
// handle the appropriate 'default=' response
// uses either mhf_steve or mhf_alex (based on +userId+) if no +def+ given
// callback: response object
function handle_default(img_status, userId, def, req, err, callback) {
def = def || skins.default_skin(userId);
var defname = def.toLowerCase();

View File

@ -56,6 +56,7 @@ function path_list(pathname) {
return list;
}
// handles the +req+ by routing to the request to the appropriate module
function requestHandler(req, res) {
req.url = url.parse(req.url, true);
req.url.query = req.url.query || {};