https://github.com/trigger-segfault/triggerstools.steinsgate
A library for generating divergence meter displays. May contain other Steins;Gate features in the future.
https://github.com/trigger-segfault/triggerstools.steinsgate
divergence-meter drawing fun steins-gate
Last synced: 6 months ago
JSON representation
A library for generating divergence meter displays. May contain other Steins;Gate features in the future.
- Host: GitHub
- URL: https://github.com/trigger-segfault/triggerstools.steinsgate
- Owner: trigger-segfault
- License: mit
- Created: 2018-06-16T21:21:13.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-02T03:08:57.000Z (over 1 year ago)
- Last Synced: 2024-11-09T08:43:02.039Z (6 months ago)
- Topics: divergence-meter, drawing, fun, steins-gate
- Language: C#
- Homepage: https://trigger-testing.github.io/pwa-examples/divergence-meter/
- Size: 3.54 MB
- Stars: 25
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License.md
Awesome Lists containing this project
README
# TriggersTools.SteinsGate
A [web tool](https://trigger-testing.github.io/pwa-examples/divergence-meter/) is also available for drawing divergence meters without needing to download a program.
***
A .NET Standard library for generating divergence meter displays. It may contain other Steins;Gate features in the future. Drawing is done using the .NET Standard library `System.Drawing.Common`, which is available as a Nuget package.
[](https://discord.gg/vB7jUbY)
***
# Divergence 
[](https://www.nuget.org/packages/TriggersTools.SteinsGate.Divergence/)
[](https://www.nuget.org/packages/TriggersTools.SteinsGate.Divergence/)
[](https://github.com/trigger-death/TriggersTools.SteinsGate/commit/e1f8a6657c45ef51beec4babcd89226ce4874686)The only existing feature in the library at the moment. Allows you to programatically draw [Divergence Meter](http://steins-gate.wikia.com/wiki/Divergence_Meter) nixie tubes from the visual novel & anime: [Steins;Gate](https://vndb.org/v2002).
`Divergence` uses graphics taken from the Steins;Gate visual novel for drawing the tubes, digits, and decimal point. The rest of the available characters are drawn with the [Oslo II font, by Antonio Rodrigues Jr](http://www.1001fonts.com/oslo-ii-font.html). This font was chosen as it had a similar style as well as perfect aspect ratio for each character.
## Basic Examples
Below is example code used to draw nixie tubes using the `Divergence` static class. At the moment, nixie tubes can be drawn at 3 pre-scaled sizes: `Large` (132x428px per tube), `Medium` (66x214px per tube), or `Small` (33x107px per tube). The library currently doesn't support drawing at other scales, but that could be added later.
```cs
using TriggersTools.SteinsGate;// Draw Figure A
var args = new DivergenceArgs {
Scale = DivergenceScale.Medium,
Spacing = new DivergenceSpacing(8, 8),
Background = Color.FromArgb(224, 224, 224),
};
string text = "Oslo II";
using (Bitmap bmp = Divergence.Draw(text, args))
bmp.Save("OsloII.png");// Draw Figure B
args.Scale = DivergenceScale.Small;
args.Spacing = new DivergenceSpacing(5, 5);
DateTime date = DateTime.Now;
text = $"{date:MM\\/dd\\/yy}\n{date.TimeOfDay:hh\\:mm\\:ss}";
using (Bitmap bmp = Divergence.Draw(text, args))
bmp.Save("DateTime.png");
```
*(Figure B: Displaying the date and time)*
*(Figure A: Displaying the name of the font used for all other characters)*## Backgrounds
As you can see in the code below, `DivergenceArgs.Background` accepts `string` as well. `DivergenceArgs.Background` is actually a struct called `DivergenceBackground` that can draw a background color, and/or a bitmap that is optionally scaled to fit the output image size.
```cs
// Draw Figure C
args = new DivergenceArgs {
Scale = DivergenceScale.Small,
Background = "EV_Z02A.PNG", // The CG background
};
text = "1.130426";
Divergence.CalculateSpacingFor(1920 / 2, 1080 / 2, text, ref args, left: 5, top: 2);
using (Bitmap bmp = Divergence.Draw(text, args))
bmp.Save("Original Worldline.png");
```
*(Figure C: Drawing the divergence meter onto a CG to display the worldline)*
## Escaping
In many scenarios, the user may not be able to pass actual new line characters if not done programmatically. `DivergenceArgs.Escape` uses the `DivergenceEscape` enum to allow 3 choices: `None` (Don't escape anything), `NewLines` (Only escape \r and \n), and `All` (Escape any character after '\\').
An example would be in the command line: `divergence.exe "#1\n#2"`. (Note: No command line program exists for this library at the moment.)

*(Figure D: The supposed output from the command line example above)*
## Example use of this library
`Divergence` isn't extremely useful or anything, but it can be fun to use as a bot command. Some of the features were specifically designed for use with an automated system.
```cs
// Automatically throw an ArgumentException if a formatted line
// is longer than 24 characters or there are more than 3 lines.
Divergence.EnabledLimits = true;
Divergence.MaxLength = 24;
Divergence.MaxLines = 3;
```
*(Figure E: The '\\' before the space is used to escape it so that it is included in the command)*