SimulationTree.Textures 0.3.9

Prefix Reserved
dotnet add package SimulationTree.Textures --version 0.3.9
                    
NuGet\Install-Package SimulationTree.Textures -Version 0.3.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimulationTree.Textures" Version="0.3.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimulationTree.Textures" Version="0.3.9" />
                    
Directory.Packages.props
<PackageReference Include="SimulationTree.Textures" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimulationTree.Textures --version 0.3.9
                    
#r "nuget: SimulationTree.Textures, 0.3.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimulationTree.Textures@0.3.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimulationTree.Textures&version=0.3.9
                    
Install as a Cake Addin
#tool nuget:?package=SimulationTree.Textures&version=0.3.9
                    
Install as a Cake Tool

Textures

Definitions for images, and for atlases with their sprites.

Importing images

Texture texture = new(world, "*/texture.png");
while (!texture.IsCompliant)
{
    simulator.Broadcast(new DataUpdate()); //to load the bytes
    simulator.Broadcast(new TextureUpdate()); //load import the texture from the bytes
}

Assert.That(texture.Width, Is.EqualTo(1024));
Assert.That(texture.Height, Is.EqualTo(1024));

ReadOnlySpan<Pixel> pixels = texture.Pixels;
Assert.That(pixels.Length, Is.EqualTo(1024 * 1024));

Evaluating pixels

When textures are loaded, their colours can be evaluated at floating point coordinates, or exact coordinates:

Color color = texture.Evaluate(0.5f, 0.5f);
Pixel exactPixel = texture[512, 512];

Creating atlases from inputs

An AtlasTexture can be created from a series of sprites, each with individual pixel data into the smallest possible texture:

Span<AtlasTexture.InputSprite> sprites = stackalloc AtlasTexture.InputSprite[1];
AtlasTexture.InputSprite firstSprite = new("firstSprite", 32, 32);
Span<Pixel> firstSpritePixels = firstSprite.Pixels;
firstSpritePixels.Fill(new Pixel(255, 0, 0, 255));
sprites[0] = firstSprite;

AtlasTexture atlas = new(world, sprites);
if (atlas.TryGetSprite("firstSprite", out AtlasSprite sprite))
{
    Vector4 region = sprite.region;
}

Console.WriteLine($"Atlas texture size: {atlas.Width}x{atlas.Height}");
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on SimulationTree.Textures:

Package Downloads
SimulationTree.TextRendering

Package Description

SimulationTree.Textures.Systems

Package Description

SimulationTree.VulkanRenderer

Package Description

SimulationTree.Skyboxes

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.9 311 9/24/2025