NetAF.Imaging provides extensions to NetAF to add simple functions to convert images to visuals.
Clone the repo:
git clone https://github.com/benpollarduk/netaf.imaging.git
Or add the NuGet package:
dotnet add package NetAF.Imaging
Generating visuals is made easy with the VisualHelper class. The following example generates a visual on the console:
var displaySize = new Size(80, 50);
var adapter = new SystemConsoleAdapter();
var frame = VisualHelper.CreateFrame(@"C:\TestImage.jpg", displaySize, CellAspectRatio.Console);
adapter.RenderFrame(frame);
The generated visual:
This can be used in a game:
var frame = VisualHelper.CreateFrame(@"C:\TestImage.jpg", displaySize, CellAspectRatio.Console);
game.ChangeMode(new VisualMode(frame));
Here is a simple room that contains a command to look at the view.
return new Room("Hillside", "A wild hillside with a lone tree", commands:
[
new CustomCommand(new CommandHelp("Look at view", "Look at the current view."), true, true, (game, args) =>
{
var frame = VisualHelper.CreateFrame(@"C:\TestImage.jpg", game.Configuration.DisplaySize, CellAspectRatio.Console);
game.ChangeMode(new VisualMode(frame));
return new(ReactionResult.GameModeChanged, string.Empty);
})
]);
A texturizer can be applied to add extra depth to the image:
var frame = VisualHelper.CreateFrame(@"C:\TestImage.jpg", displaySize, CellAspectRatio.Console, new BrightnessTexturizer());
The generated visual:
Please visit https://benpollarduk.github.io/NetAF-docs/docs/visuals.html to view the NetAF.Imaging documentation.
Visit https://github.com/benpollarduk/NetAF.Imaging/issues