Skip to content

Commit

Permalink
Create readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
gitmylo committed Jun 8, 2023
1 parent 9e07516 commit 041f41a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion TavernAICardLibTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
TavernAiCard card = TavernAiCard.Load("character.json");

// Example: Load the character from a png card.
// TavernAiCard? card = TavernAiCard.Load("character.png");
// TavernAiCard card = TavernAiCard.Load("character.png");

// Example: Print the name of the loaded character.
Console.WriteLine(card.Name);
Expand Down
68 changes: 68 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# TavernAI card lib .net

<!-- TOC -->
* [TavernAI card lib .net](#tavernai-card-lib-net)
* [Description](#description)
* [Examples](#examples)
* [Loading](#loading)
* [Saving](#saving)
* [Data reading and writing](#data-reading-and-writing)
* [Image modification](#image-modification)
<!-- TOC -->

# Description
TavernAI card lib is a library for loading, modifying and saving TavernAI cards within a dotnet application.

It supports .json, .png, .webp, .jpg and .jpeg files. Although some of these formats have been untested so far.

# Examples

## Loading
* Loading a file from a JSON
```csharp
TavernAiCard card = TavernAiCard.Load("character.json");
```
* Loading a file from an image
```csharp
TavernAiCard card = TavernAiCard.Load("character.png");
```

## Saving
* Saving a .json
```csharp
card.Save("character_saved.json");
```

* Saving a .png
```csharp
card.Save("character_saved.png");
```

## Data reading and writing
* Reading the name
```csharp
string name = card.Name;
```

* Writing the name
```csharp
card.Name = "New name";
```

## Image modification
* Create an empty image for the card (**Windows only**).
```csharp
// Check if bitmap image editing is supported, Windows only.
if (TavernAiCard.ImageFullySupported())
{
// Create a transparent bitmap
card.Image = new Bitmap(400, 600);
}
```

* Setting the image to another image file
```csharp
// Set Image to null in case it was already set from loading from an image file on Windows.
card.Image = null;
card.ImagePath = "path/to/the/image.png";
```

0 comments on commit 041f41a

Please sign in to comment.