Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions docs/api/generateNinja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# generateNinja

`generateNinja` is a convenience function provided by the SpriteAI library to generate a ninja character spritesheet with predefined animation states.

## Overview

The `generateNinja` function creates a pixel-art style spritesheet for a ninja character with black outfit and mask. It utilizes the more general `generateCharacterSpritesheet` function with preset options tailored for a ninja character.

## Syntax

```javascript
export const generateNinja = async function(options = {}) {
const defaultOptions = {
states: ['idle', 'walk', 'run', 'attack', 'sneak'],
style: 'pixel-art',
framesPerState: 6
};
const mergedOptions = { ...defaultOptions, ...options };

return generateCharacterSpritesheet('ninja character with black outfit and mask', mergedOptions);
}
```

## Parameters

- `options` (optional): An object containing custom options to override the default settings.

### Default Options

```javascript
{
states: ['idle', 'walk', 'run', 'attack', 'sneak'],
style: 'pixel-art',
framesPerState: 6
}
```

## Return Value

The function returns a Promise that resolves to an object containing:

- `original`: URL of the original generated image
- `spritesheet`: Base64-encoded string of the processed spritesheet
- `metadata`: Object containing information about the generated spritesheet

## Usage Example

```javascript
import { generateNinja } from 'spriteAI';

async function createNinjaSprite() {
try {
const ninjaSprite = await generateNinja();
console.log('Ninja sprite generated:', ninjaSprite);
// Use the generated sprite in your game or application
} catch (error) {
console.error('Error generating ninja sprite:', error);
}
}

createNinjaSprite();
```

## Customization

You can customize the ninja sprite generation by passing options:

```javascript
const customNinja = await generateNinja({
framesPerState: 8,
style: 'hand-drawn'
});
```

This will generate a ninja sprite with 8 frames per animation state in a hand-drawn style instead of pixel-art.

## Notes

- The function uses AI-powered image generation, so results may vary slightly between calls.
- The generated spritesheet is optimized for game development use, with clear separation between animation states.
- For more control over the sprite generation process, consider using the `generateCharacterSpritesheet` function directly.

## See Also

- [generateCharacterSpritesheet](./generateCharacterSpritesheet.md)
- [generateSpaceman](./generateSpaceman.md)
- [generateRobot](./generateRobot.md)
76 changes: 76 additions & 0 deletions docs/api/generateRobot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# generateRobot

## Overview

The `generateRobot` function is a convenience method for generating a robot character spritesheet using the SpriteAI library. This function streamlines the process of creating a pixel art robot character with predefined animation states.

## Syntax

```javascript
generateRobot(options = {})
```

## Parameters

- `options` (optional): An object containing configuration options for the robot sprite generation.
- `states` (array of strings): Animation states for the robot. Default: `['idle', 'walk', 'run', 'attack', 'power-up']`
- `style` (string): The art style for the sprite. Default: `'pixel-art'`
- `framesPerState` (number): Number of frames for each animation state. Default: `6`

## Returns

- A Promise that resolves to an object containing:
- `original`: URL of the original generated image
- `spritesheet`: Base64-encoded PNG data of the processed spritesheet
- `metadata`: Object containing information about the generated spritesheet

## Description

The `generateRobot` function is built on top of the `generateCharacterSpritesheet` function, providing a simplified interface for creating robot character sprites. It uses predefined settings tailored for robot characters, including specific animation states and a default description.

By default, the function generates a pixel art robot character with mechanical limbs and glowing eyes. The spritesheet includes five animation states: idle, walk, run, attack, and power-up.

## Example Usage

```javascript
import { generateRobot } from 'spriteAI';

async function createRobotSprite() {
try {
const robotSprite = await generateRobot({
framesPerState: 8,
style: 'pixel-art'
});
console.log('Robot sprite generated:', robotSprite);
// Use the robotSprite.spritesheet data in your game or application
} catch (error) {
console.error('Error generating robot sprite:', error);
}
}

createRobotSprite();
```

## Customization

You can customize the robot sprite generation by passing options to the `generateRobot` function. For example, you can change the number of frames per state or add additional animation states:

```javascript
const customRobot = await generateRobot({
states: ['idle', 'walk', 'run', 'attack', 'power-up', 'shutdown'],
framesPerState: 4,
style: 'vector'
});
```

## Notes

- The function uses AI-powered image generation, so results may vary slightly between calls.
- The generated spritesheet is optimized for game development and can be easily integrated into game engines or frameworks that support spritesheets.
- For more complex customizations, consider using the `generateCharacterSpritesheet` function directly.

## See Also

- [generateCharacterSpritesheet](./generateCharacterSpritesheet.md)
- [generateNinja](./generateNinja.md)
- [generateSpaceman](./generateSpaceman.md)
76 changes: 76 additions & 0 deletions docs/api/generateSpaceman.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# generateSpaceman

## Overview

The `generateSpaceman` function is a convenience method for generating a sprite sheet of an astronaut character. This function is part of the SpriteAI library and utilizes the more general `generateCharacterSpritesheet` function with pre-configured options suitable for a spaceman character.

## Syntax

```javascript
export const generateSpaceman = async function(options = {}) {
// Function implementation
}
```

## Parameters

- `options` (optional): An object containing configuration options to customize the sprite generation. If not provided, default values will be used.

### Default Options

```javascript
{
states: ['idle', 'walk', 'run', 'float'],
style: 'pixel-art',
framesPerState: 6
}
```

## Return Value

The function returns a Promise that resolves to an object containing:

- `original`: The URL of the original generated image.
- `spritesheet`: A base64-encoded string of the processed sprite sheet.
- `metadata`: An object containing information about the generated sprite sheet.

## Usage

```javascript
import { generateSpaceman } from 'spriteAI';

// Generate a spaceman sprite with default options
const result = await generateSpaceman();

// Generate a spaceman sprite with custom options
const customResult = await generateSpaceman({
states: ['idle', 'walk', 'run', 'float', 'jump'],
framesPerState: 8
});
```

## Description

The `generateSpaceman` function creates a pixel-art style sprite sheet of an astronaut character. By default, it includes four animation states: idle, walk, run, and float. Each state is represented by 6 frames in the resulting sprite sheet.

Internally, this function calls `generateCharacterSpritesheet` with a pre-defined description: "astronaut character with space suit and helmet". This ensures consistency in the generated spaceman character across different calls.

## Customization

While the function comes with default options, you can customize various aspects of the sprite generation by passing an `options` object. This allows you to:

- Add or remove animation states
- Change the number of frames per state
- Alter the art style (though 'pixel-art' is recommended for consistency)

## Notes

- The generated sprite sheet is optimized for use in 2D games or applications requiring animated astronaut characters.
- The 'float' state is unique to the spaceman character, simulating low-gravity or zero-gravity movement.
- For more control over the sprite generation process, consider using the `generateCharacterSpritesheet` function directly.

## See Also

- [generateCharacterSpritesheet](./generateCharacterSpritesheet.md)
- [generateNinja](./generateNinja.md)
- [generateRobot](./generateRobot.md)
52 changes: 44 additions & 8 deletions docs/changelogs/changelog-2025-04-18.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,50 @@
## [Unreleased] - 2025-04-18

### Added
- New function `generateItemSprites()` for creating game item sprite collections
- Supports various options including item count, size, style, padding, item type, and background
- Generates a sprite sheet with multiple items arranged in a grid
- Returns both the original image URL and the processed item sheet
- Includes metadata about the generated sprites
- New convenience functions for generating specific character types:
- `generateNinja()`: Creates a ninja character spritesheet
- `generateSpaceman()`: Creates an astronaut character spritesheet
- `generateRobot()`: Creates a robot character spritesheet

### Changed
- Enhanced `generateEnvironmentSprites()` function (modifications inferred from the context of the new function)
- Enhanced `generateCharacterSpritesheet()` function to support new character types

### Other
- Added a test file `.github-write-test`
### Details

#### New Character Generation Functions

Three new functions have been added to simplify the creation of specific character types:

1. `generateNinja(options = {})`
- Default animation states: idle, walk, run, attack, sneak
- Generates a ninja character with a black outfit and mask

2. `generateSpaceman(options = {})`
- Default animation states: idle, walk, run, float
- Generates an astronaut character with a space suit and helmet

3. `generateRobot(options = {})`
- Default animation states: idle, walk, run, attack, power-up
- Generates a robot character with mechanical limbs and glowing eyes

Each function uses the `generateCharacterSpritesheet()` internally with pre-configured options suitable for the specific character type. Users can customize these options by passing an `options` object to the functions.

#### Usage Example

```javascript
import { generateNinja, generateSpaceman, generateRobot } from 'spriteAI';

// Generate a ninja character spritesheet
const ninjaSprite = await generateNinja();

// Generate a spaceman character spritesheet with custom options
const spacemanSprite = await generateSpaceman({
framesPerState: 8,
style: 'vector'
});

// Generate a robot character spritesheet
const robotSprite = await generateRobot();
```

These new functions aim to streamline the character creation process for common game character types, enhancing developer productivity and maintaining consistency across sprite generations.