From 7823772d920cd275c7ee652f56e254b2a861fbd2 Mon Sep 17 00:00:00 2001 From: "dev-docs-github-app[bot]" <178952281+dev-docs-github-app[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 00:36:45 +0000 Subject: [PATCH 1/2] Update 1 files --- docs/spriteai/index-js-technical-brief.md | 135 ++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 docs/spriteai/index-js-technical-brief.md diff --git a/docs/spriteai/index-js-technical-brief.md b/docs/spriteai/index-js-technical-brief.md new file mode 100644 index 000000000..93f17e1bd --- /dev/null +++ b/docs/spriteai/index-js-technical-brief.md @@ -0,0 +1,135 @@ +# SpriteAI: index.js Technical Brief + +## Overview + +This technical brief provides an in-depth look at the `index.js` file of the SpriteAI project. The file contains several key functions for generating game assets using AI, specifically focusing on character spritesheets, environment sprites, and item sprites. + +## Key Functions + +### 1. generateCharacterSpritesheet + +```javascript +export const generateCharacterSpritesheet = async function(description, options = {}) { + // ... implementation details +} +``` + +This function generates a character spritesheet based on a given description and options. + +#### Parameters: +- `description`: A string describing the character. +- `options`: An object containing configuration options such as: + - `states`: Array of animation states (default: ['idle', 'walk', 'run', 'attack']) + - `framesPerState`: Number of frames per animation state (default: 6) + - `size`: Image size (default: '1024x1024') + - `style`: Art style (default: 'pixel-art') + - `padding`: Padding between frames (default: 1) + - `direction`: Character facing direction (default: 'right') + +#### Returns: +An object containing: +- `original`: URL of the original generated image +- `spritesheet`: Base64 encoded spritesheet +- `metadata`: Detailed information about the spritesheet + +### 2. fetchAvailableAnimationStates + +```javascript +export const fetchAvailableAnimationStates = async function() { + // ... implementation details +} +``` + +This function returns an array of available animation states for character sprites. + +#### Returns: +An array of strings representing animation states: ['idle', 'walk', 'run', 'attack', 'jump', 'fall', 'hurt', 'die'] + +### 3. fetchAvailableSpriteStyles + +```javascript +export const fetchAvailableSpriteStyles = async function() { + // ... implementation details +} +``` + +This function returns an array of available sprite styles. + +#### Returns: +An array of strings representing sprite styles: ['pixel-art', 'vector', '3d', 'hand-drawn', 'anime'] + +### 4. generateEnvironmentSprites + +```javascript +export const generateEnvironmentSprites = async function(description, options = {}) { + // ... implementation details +} +``` + +This function generates environment sprites based on a given description and options. + +#### Parameters: +- `description`: A string describing the environment. +- `options`: An object containing configuration options such as: + - `elements`: Number of distinct environment pieces (default: 4) + - `size`: Image size (default: '1024x1024') + - `style`: Art style (default: 'pixel-art') + - `padding`: Padding between elements (default: 1) + - `theme`: Environment theme (default: 'fantasy') + +#### Returns: +An object containing: +- `original`: URL of the original generated image +- `tileset`: Base64 encoded tileset +- `metadata`: Detailed information about the tileset + +### 5. generateItemSprites + +```javascript +export const generateItemSprites = async function(description, options = {}) { + // ... implementation details +} +``` + +This function generates item sprites based on a given description and options. + +#### Parameters: +- `description`: A string describing the items. +- `options`: An object containing configuration options such as: + - `itemCount`: Number of distinct items (default: 4) + - `size`: Image size (default: '1024x1024') + - `style`: Art style (default: 'pixel-art') + - `padding`: Padding between items (default: 1) + - `itemType`: Type of items (default: 'equipment') + - `background`: Background color (default: 'white') + +#### Returns: +An object containing: +- `original`: URL of the original generated image +- `itemSheet`: Base64 encoded item sheet +- `metadata`: Detailed information about the item sheet + +## Utility Functions + +### removeBackgroundColor + +```javascript +async function removeBackgroundColor(inputPath, outputPath, targetColor, colorThreshold = 0, options = {}) { + // ... implementation details +} +``` + +This internal function removes a specified background color from an image. + +## Dependencies + +The module relies on several external libraries: +- OpenAI: For AI-powered image generation +- axios: For making HTTP requests +- sharp: For image processing +- Jimp: For image manipulation +- fs and path: For file system operations + +## Conclusion + +The `index.js` file provides a comprehensive set of functions for generating game assets using AI. It offers flexibility in terms of customization options and covers various aspects of game asset creation, including character animations, environment tiles, and item sprites. \ No newline at end of file From afd0c4214f99d198d27f0a02867a3c1b4f671b52 Mon Sep 17 00:00:00 2001 From: "dev-docs-github-app[bot]" <178952281+dev-docs-github-app[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 00:37:04 +0000 Subject: [PATCH 2/2] Update file --- docs/spriteai/index-js-technical-brief.md | 124 ++++++++++++++-------- 1 file changed, 82 insertions(+), 42 deletions(-) diff --git a/docs/spriteai/index-js-technical-brief.md b/docs/spriteai/index-js-technical-brief.md index 93f17e1bd..62045eba8 100644 --- a/docs/spriteai/index-js-technical-brief.md +++ b/docs/spriteai/index-js-technical-brief.md @@ -2,8 +2,6 @@ ## Overview -This technical brief provides an in-depth look at the `index.js` file of the SpriteAI project. The file contains several key functions for generating game assets using AI, specifically focusing on character spritesheets, environment sprites, and item sprites. - ## Key Functions ### 1. generateCharacterSpritesheet @@ -17,20 +15,32 @@ export const generateCharacterSpritesheet = async function(description, options This function generates a character spritesheet based on a given description and options. #### Parameters: -- `description`: A string describing the character. -- `options`: An object containing configuration options such as: - - `states`: Array of animation states (default: ['idle', 'walk', 'run', 'attack']) - - `framesPerState`: Number of frames per animation state (default: 6) - - `size`: Image size (default: '1024x1024') - - `style`: Art style (default: 'pixel-art') - - `padding`: Padding between frames (default: 1) - - `direction`: Character facing direction (default: 'right') + +* `description`: A string describing the character. + +* `options`: An object containing configuration options such as: + + * `states`: Array of animation states (default: \['idle', 'walk', 'run', 'attack']) + + * `framesPerState`: Number of frames per animation state (default: 6) + + * `size`: Image size (default: '1024x1024') + + * `style`: Art style (default: 'pixel-art') + + * `padding`: Padding between frames (default: 1) + + * `direction`: Character facing direction (default: 'right') #### Returns: + An object containing: -- `original`: URL of the original generated image -- `spritesheet`: Base64 encoded spritesheet -- `metadata`: Detailed information about the spritesheet + +* `original`: URL of the original generated image + +* `spritesheet`: Base64 encoded spritesheet + +* `metadata`: Detailed information about the spritesheet ### 2. fetchAvailableAnimationStates @@ -43,7 +53,8 @@ export const fetchAvailableAnimationStates = async function() { This function returns an array of available animation states for character sprites. #### Returns: -An array of strings representing animation states: ['idle', 'walk', 'run', 'attack', 'jump', 'fall', 'hurt', 'die'] + +An array of strings representing animation states: \['idle', 'walk', 'run', 'attack', 'jump', 'fall', 'hurt', 'die'] ### 3. fetchAvailableSpriteStyles @@ -56,7 +67,8 @@ export const fetchAvailableSpriteStyles = async function() { This function returns an array of available sprite styles. #### Returns: -An array of strings representing sprite styles: ['pixel-art', 'vector', '3d', 'hand-drawn', 'anime'] + +An array of strings representing sprite styles: \['pixel-art', 'vector', '3d', 'hand-drawn', 'anime'] ### 4. generateEnvironmentSprites @@ -69,19 +81,30 @@ export const generateEnvironmentSprites = async function(description, options = This function generates environment sprites based on a given description and options. #### Parameters: -- `description`: A string describing the environment. -- `options`: An object containing configuration options such as: - - `elements`: Number of distinct environment pieces (default: 4) - - `size`: Image size (default: '1024x1024') - - `style`: Art style (default: 'pixel-art') - - `padding`: Padding between elements (default: 1) - - `theme`: Environment theme (default: 'fantasy') + +* `description`: A string describing the environment. + +* `options`: An object containing configuration options such as: + + * `elements`: Number of distinct environment pieces (default: 4) + + * `size`: Image size (default: '1024x1024') + + * `style`: Art style (default: 'pixel-art') + + * `padding`: Padding between elements (default: 1) + + * `theme`: Environment theme (default: 'fantasy') #### Returns: + An object containing: -- `original`: URL of the original generated image -- `tileset`: Base64 encoded tileset -- `metadata`: Detailed information about the tileset + +* `original`: URL of the original generated image + +* `tileset`: Base64 encoded tileset + +* `metadata`: Detailed information about the tileset ### 5. generateItemSprites @@ -94,20 +117,32 @@ export const generateItemSprites = async function(description, options = {}) { This function generates item sprites based on a given description and options. #### Parameters: -- `description`: A string describing the items. -- `options`: An object containing configuration options such as: - - `itemCount`: Number of distinct items (default: 4) - - `size`: Image size (default: '1024x1024') - - `style`: Art style (default: 'pixel-art') - - `padding`: Padding between items (default: 1) - - `itemType`: Type of items (default: 'equipment') - - `background`: Background color (default: 'white') + +* `description`: A string describing the items. + +* `options`: An object containing configuration options such as: + + * `itemCount`: Number of distinct items (default: 4) + + * `size`: Image size (default: '1024x1024') + + * `style`: Art style (default: 'pixel-art') + + * `padding`: Padding between items (default: 1) + + * `itemType`: Type of items (default: 'equipment') + + * `background`: Background color (default: 'white') #### Returns: + An object containing: -- `original`: URL of the original generated image -- `itemSheet`: Base64 encoded item sheet -- `metadata`: Detailed information about the item sheet + +* `original`: URL of the original generated image + +* `itemSheet`: Base64 encoded item sheet + +* `metadata`: Detailed information about the item sheet ## Utility Functions @@ -124,12 +159,17 @@ This internal function removes a specified background color from an image. ## Dependencies The module relies on several external libraries: -- OpenAI: For AI-powered image generation -- axios: For making HTTP requests -- sharp: For image processing -- Jimp: For image manipulation -- fs and path: For file system operations + +* OpenAI: For AI-powered image generation + +* axios: For making HTTP requests + +* sharp: For image processing + +* Jimp: For image manipulation + +* fs and path: For file system operations ## Conclusion -The `index.js` file provides a comprehensive set of functions for generating game assets using AI. It offers flexibility in terms of customization options and covers various aspects of game asset creation, including character animations, environment tiles, and item sprites. \ No newline at end of file +The `index.js` file provides a comprehensive set of functions for generating game assets using AI. It offers flexibility in terms of customization options and covers various aspects of game asset creation, including character animations, environment tiles, and item sprites.