瀏覽代碼

Update documentation & README for renders

Jake 10 年之前
父節點
當前提交
f674775520
共有 3 個文件被更改,包括 53 次插入20 次删除
  1. 2 1
      README.md
  2. 15 17
      modules/config.js
  3. 36 2
      views/index.jade

+ 2 - 1
README.md

@@ -5,7 +5,7 @@ https://crafatar.com
 Crafatar serves Minecraft avatars based on the skin for use in external applications.
 Inspired by [Gravatar](https://gravatar.com) (hence the name) and [Minotar](https://minotar.net).
 
-Image manipulation is done by [lwip](https://github.com/EyalAr/lwip)
+Image manipulation is done by [lwip](https://github.com/EyalAr/lwip). Renders are created with [node-canvas](https://github.com/Automattic/node-canvas), based on math by [confuser](https://github.com/confuser/serverless-mc-skin-viewer).
 
 ![redstone_sheep's avatar](https://crafatar.com/avatars/ae795aa86327408e92ab25c8a59f3ba1?size=128) ![Jake0oo0's avatar](https://crafatar.com/avatars/2d5aa9cdaeb049189930461fc9b91cc5?size=128) ![Notch's avatar](https://crafatar.com/avatars/069a79f444e94726a5befca90e38aaf5?size=128) ![sk89q's avatar](https://crafatar.com/avatars/0ea8eca3dbf647cc9d1ac64551ca975c?size=128) ![md_5's avatar](https://crafatar.com/avatars/af74a02d19cb445bb07f6866a861f783?size=128) 
 ## Usage / Documentation
@@ -19,6 +19,7 @@ You can [join us](https://webchat.esper.net/?channels=spongy) in #spongy on irc.
 ## Install
 
 * Clone the repository
+* Install [node-canvas](https://github.com/Automattic/node-canvas/wiki#desktop) dependencies.
 * `npm install`
 * `redis-server`
 * `cp "modules/config.example.js" "modules/config.js"`

+ 15 - 17
modules/config.js

@@ -1,21 +1,19 @@
 var config = {
-  min_size: 1,                   // for avatars
-  max_size: 512,                 // for avatars; too big values might lead to slow response time or DoS
-  default_size: 160,             // for avatars; size to be used when no size given
-  local_cache_time: 1200,        // seconds until we will check if the image changed. should be > 60 to prevent mojang 429 response
-  browser_cache_time: 3600,      // seconds until browser will request image again
-  cleaning_interval: 3,       // seconds interval: deleting images if disk size at limit
-  cleaning_limit: 900000000000,         // minumum required available KB on disk to trigger cleaning
-  cleaning_amount: 50000,        // amount of avatar (and their helm) files to clean
-  http_timeout: 1000,            // ms until connection to mojang is dropped
-  faces_dir: 'skins/faces/',     // directory where faces are kept. should have trailing '/'
-  helms_dir: 'skins/helms/',     // directory where helms are kept. should have trailing '/'
-  skins_dir: 'skins/skins/',     // directory where skins are kept. should have trailing '/'
-  renders_dir: 'skins/renders/', // Directory where rendered skins are kept. should have trailing '/'
-  debug_enabled: true,          // enables logging.debug
-  min_scale: 1,                  // for renders
-  max_scale: 100,                 // for renders; too big values might lead to slow response time or DoS
-  default_scale: 6,              // for renders; scale to be used when no scale given
+  min_size: 1,               // < 1 will (obviously) cause crash
+  max_size: 512,             // too big values might lead to slow response time or DoS
+  default_size: 160,         // size to be used when no size given
+  local_cache_time: 30,      // seconds until we will check if the image changed. should be > 60 to prevent mojang 429 response
+  browser_cache_time: 30,    // seconds until browser will request image again
+  http_timeout: 3000,        // ms until connection to mojang is dropped
+  cleaning_interval: 1800,   // seconds interval: deleting images if disk size at limit
+  cleaning_limit: 10240,     // minumum required available KB on disk to trigger cleaning
+  cleaning_amount: 50000,    // amount of avatar (and their helm) files to clean
+  http_timeout: 1000,        // ms until connection to mojang is dropped
+  faces_dir: 'skins/faces/', // directory where faces are kept. should have trailing '/'
+  helms_dir: 'skins/helms/', // directory where helms are kept. should have trailing '/'
+  debug_enabled: true,       // enables logging.debug
+  default_scale: 6,          // the scale of rendered avatars
+  maximum_sale: 10           // the maximum scale of rendered avatars
 };
 
 module.exports = config;

+ 36 - 2
views/index.jade

@@ -63,12 +63,42 @@ block content
           | Replace 
           mark.green id 
           | with a Mojang <b>UUID</b> or <b>username</b> to get the related skin.
-          | You are redirected to the textures URL, or the default image is served.<br>
+          | The user's skin will be returned, or the default image is served.<br>
           | You can use the default parameter here as well.
         .code
           | #{domain}/skins/
           mark.green id
 
+        a(id="renders", class="anchor")
+        a(href="renders")
+          h3 3D Renders
+        p
+          | Crafatar also provides support for 3D renders of Minecraft skins.
+          | Replace
+          mark.green id
+          | with a Mojang <b>UUID</b> or <b>username</b> to get an render for the skin.
+        .code
+          | #{domain}/renders/head/
+          mark.green id
+        .code
+          | #{domain}/renders/body/
+          mark.green id
+        | The <b>default</b> parameter can also be used here. The scale factor will not be applied.
+        | Using the <b>helm</b> parameter is also allowed, which will be overlayed onto the head.
+        | The <b>head</b> render type will return only a render of the skin's head, while the
+        | <b>body</b> render will return a render of the entire skin.
+
+        a(id="#render-parameters", class="#render-anchor")
+        a(href="#render-parameters")
+          h3 Render Parameters
+        a(id="scale", class="anchor")
+        a(href="#scale")
+          h4 scale
+        p
+          | The scale factor of the image #{config.min_scale} - #{config.max_scale}.<br>
+          | Default is #{config.default_scale}. The actual size differs between the type of render.
+
+
         a(id="http-headers", class="anchor")
         a(href="#http-headers")
           h3 HTTP headers
@@ -126,7 +156,7 @@ block content
         .code #{domain}/avatars/853c80ef3c3749fdaa49938b674adae6
         p Jeb's avatar, 64 × 64
         .code #{domain}/avatars/853c80ef3c3749fdaa49938b674adae6?size=64
-        p Jeb's avatar, 64 × 64, with helm
+        p Jeb's avatar, 64 × 64, with helmet
         .code #{domain}/avatars/853c80ef3c3749fdaa49938b674adae6?size=64&amp;helm
         p Jeb's avatar, or fall back to steve
         .code #{domain}/avatars/853c80ef3c3749fdaa49938b674adae6?default=steve
@@ -138,6 +168,10 @@ block content
         .code #{domain}/skins/853c80ef3c3749fdaa49938b674adae6
         p Jeb's skin by username
         .code #{domain}/skins/jeb_
+        p Render of Jeb's Head
+        .code #{domain}/renders/head/853c80ef3c3749fdaa49938b674adae6
+        p Render of Jeb's Body, with helmet, by username
+        .code #{domain}/renders/body/jeb_?helm
       .col-md-2.center
         .sideface.redstone_sheep(title="redstone_sheep")
         .sideface.Jake0oo0(title="Jake0oo0")