char-renderer-ss13
v1.2.0
Published
Space Station 13 character renderer for Node.js - renders SS13 characters from preferences to PNG images
Downloads
453
Maintainers
Readme
char-renderer-ss13
Space Station 13 character renderer for Node.js
Target codebase: TGStation and downstream NovaStation > The Fluffy Frontier;
Renders SS13 characters from preferences JSON to PNG images with full support for:
- Multiple species (Human, Lizard, Moth, Mammal, Skrell, IPC/Synth, Plasmaman, etc.)
- Hairstyles with gradient support
- Facial hair with gradient support
- Skrell tentacle hair (separate system)
- Body markings
- Accessories (tails, ears, horns, snouts, wings)
- Augmentations/robotic limbs (all IPC chassis styles)
- IPC antennas
- Digitigrade legs
- All 4 directions (SOUTH, NORTH, EAST, WEST)
- Transparent background by default (or custom color/image)
Installation
npm install char-renderer-ss13Requirements
- Node.js >= 16.0.0
- The package uses
@napi-rs/canvaswhich is automatically installed as a dependency
Usage
Basic Example
const { renderCharacterToPNG } = require('char-renderer-ss13');
const characterPrefs = {
real_name: "John Doe",
species: "human",
age: 30,
gender: "male",
body_type: "male",
skin_tone: "caucasian1",
eye_color: "#0066cc",
hairstyle_name: "Short Hair",
hair_color: "#000000",
facial_style_name: "Shaved",
// ... other preferences
};
// Render with transparent background (default)
const pngBuffer = await renderCharacterToPNG(characterPrefs);
// Save to file
const fs = require('fs');
fs.writeFileSync('character.png', pngBuffer);Background Options
// Transparent background (default)
const png = await renderCharacterToPNG(prefs, 0);
// Solid color background
const png = await renderCharacterToPNG(prefs, 0, { color: '#333333' });
// Image background (scales to fit)
const bgImage = fs.readFileSync('background.png');
const png = await renderCharacterToPNG(prefs, 0, { image: bgImage });Render All Directions
const { renderCharacterAllDirections } = require('char-renderer-ss13');
// With transparent background
const images = await renderCharacterAllDirections(characterPrefs);
// With custom background
const images = await renderCharacterAllDirections(characterPrefs, { color: '#222222' });
// images contains: { south, north, east, west }
fs.writeFileSync('south.png', images.south);
fs.writeFileSync('north.png', images.north);
fs.writeFileSync('east.png', images.east);
fs.writeFileSync('west.png', images.west);Direction Constants
// 0 = SOUTH (default, facing down)
// 1 = NORTH (facing up)
// 2 = EAST (facing right)
// 3 = WEST (facing left)
const pngBuffer = await renderCharacterToPNG(characterPrefs, 2); // Facing EASTDiscord Bot Example
const { Client, GatewayIntentBits, AttachmentBuilder } = require('discord.js');
const { renderCharacterToPNG } = require('char-renderer-ss13');
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages]
});
client.on('messageCreate', async (message) => {
if (message.content === '!render') {
// Load character preferences from your database/file
const prefs = loadCharacterPreferences();
// Render character with custom background
const pngBuffer = await renderCharacterToPNG(prefs, 0, { color: '#1a1a2e' });
// Send to Discord
const attachment = new AttachmentBuilder(pngBuffer, {
name: `${prefs.real_name}.png`
});
await message.reply({
content: `Character: ${prefs.real_name}`,
files: [attachment]
});
}
});
client.login('YOUR_BOT_TOKEN');Character Preferences Structure
interface CharacterPreferences {
real_name: string;
species?: string; // 'human', 'lizard', 'moth', 'mammal', 'skrell', 'ipc', 'synth', etc.
age: number;
gender?: string; // 'male', 'female', 'plural'
body_type: string; // 'male', 'female', 'Use Gender'
skin_tone: string; // 'caucasian1', 'caucasian2', 'asian1', etc.
eye_color: string; // Hex color with #
hairstyle_name: string; // Hair style name from SS13
hair_color?: string; // Hex color
hair_gradient?: string; // Gradient type: 'Fade Up', 'Fade Down', 'Vertical Split', etc.
hair_gradient_color?: string; // Gradient color
facial_style_name: string; // 'Shaved', 'Beard', etc.
facial_hair_color?: string; // Hex color
facial_hair_gradient?: string;
facial_hair_gradient_color?: string;
// For non-human species
mutant_colors_color?: string[];
mutant_bodyparts?: {
legs?: { name?: string; color?: string[] };
skrell_hair?: { name?: string; color?: string[] };
[key: string]: any;
};
// Skrell specific
feature_skrell_hair?: string; // 'Short', 'Long', etc.
skrell_hair_toggle?: number;
skrell_hair_color?: string[];
// IPC/Synth specific
feature_ipc_chassis?: string; // 'Bishop Cyberkinetics', 'Zeng-Hu Pharmaceuticals', etc.
feature_ipc_head?: string;
feature_ipc_antenna?: string; // 'Angled Antennae', 'TV Antennae', etc.
ipc_antenna_color?: string[];
// Augmentations
augments?: {
[slot: string]: string; // 'Left Leg': '/obj/item/bodypart/leg/left/robot/weak'
};
augment_limb_styles?: {
[slot: string]: string; // 'Left Leg': 'Mariinsky Ballet Company'
};
// Accessories
feature_tail?: string;
tail_color?: string[];
tail_toggle?: number; // 0 = hidden, 1 = shown
feature_snout?: string;
snout_color?: string[];
snout_toggle?: number;
feature_ears?: string;
ears_color?: string[];
ears_toggle?: number;
feature_horns?: string;
horns_color?: string[];
horns_toggle?: number;
// Digitigrade legs
digitigrade_legs?: string; // 'Digitigrade Legs'
// Body markings
body_markings?: {
[bodypart: string]: { // 'head', 'chest', 'l_arm', 'r_arm', etc.
[markingName: string]: [string, number]; // [color, alpha]
};
};
}
interface BackgroundOptions {
color?: string; // Hex color like '#ff0000'
image?: Buffer; // PNG/JPG buffer - scales to fit
}Supported Species
- Human, Felinid, Hemophage
- Lizard, Synthliz
- Moth
- Mammal, Synthmammal, Vulpkanin
- Skrell (with tentacle hair)
- IPC/Synth (full robotic body)
- Plasmaman (with envirosuit)
- Akula, Aquatic
- Insect, Insectoid
- Vox
- Teshari, Nabber (simple sprites)
- And more...
Supported Augmentation Styles
- Cyborg, Surplus, Engineering, Mining, Security
- Bishop Cyberkinetics (1.0 & 2.0)
- Morpheus Cyberkinetics
- Hephaestus Industries (1.0 & 2.0)
- Shellguard Munitions Standard Series
- Ward-Takahashi Manufacturing
- Xion Manufacturing Group (1.0 & 2.0)
- Zeng-Hu Pharmaceuticals
- Mariinsky Ballet Company
- Zhenkov & Co. Foundries
- E3N AI
Output
- Image format: PNG (with alpha channel)
- Dimensions: 256x256 pixels (32x32 upscaled 8x with crisp pixel art)
- Background: Transparent by default (customizable)
- Pixel-perfect rendering with no smoothing
Performance
- First render: ~100-300ms (includes sprite loading and caching)
- Subsequent renders: ~50-100ms (sprites cached in memory)
- DMI sprites are cached automatically for better performance
Changelog
1.1.5
- Transparent background by default
- Added
BackgroundOptions- set solid color or image as background - Skrell tentacle hair support (
feature_skrell_hair,skrell_hair.dmi) - IPC/Synth antenna rendering
- Hand inherits augmentation style from arm automatically
- Added base lizard snouts (Sharp, Round, Sharp + Light, Round + Light)
- Added synthliz snouts
1.1.0
- Hair and facial hair gradient support
- IPC/Synth species rendering
- Full augmentation system
- Digitigrade legs support
1.0.0
- Initial release
License
MIT
Credits
Character sprites and assets are from Space Station 13:
