Skip to content

benpollarduk/NetAF.Imaging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetAF.Imaging

Extension to add simple imaging capabilities to NetAF.

icon

main-ci GitHub release NuGet NuGet Downloads codecov Quality Gate Status Maintainability Rating Security Rating Vulnerabilities Bugs License

Overview

NetAF.Imaging provides extensions to NetAF to add simple functions to convert images to visuals.

Getting Started

Clone the repo/pull NuGet

Clone the repo:

git clone https://github.com/benpollarduk/netaf.imaging.git

Or add the NuGet package:

dotnet add package NetAF.Imaging

Hello World

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:

image

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);
    })
 ]);

Applying Textures

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:

image

Documentation

Please visit https://benpollarduk.github.io/NetAF-docs/docs/visuals.html to view the NetAF.Imaging documentation.

For Open Questions

Visit https://github.com/benpollarduk/NetAF.Imaging/issues