SpawnDev.BlazorJS.PixiJS 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SpawnDev.BlazorJS.PixiJS --version 2.0.0
                    
NuGet\Install-Package SpawnDev.BlazorJS.PixiJS -Version 2.0.0
                    
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="SpawnDev.BlazorJS.PixiJS" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SpawnDev.BlazorJS.PixiJS" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SpawnDev.BlazorJS.PixiJS" />
                    
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 SpawnDev.BlazorJS.PixiJS --version 2.0.0
                    
#r "nuget: SpawnDev.BlazorJS.PixiJS, 2.0.0"
                    
#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 SpawnDev.BlazorJS.PixiJS@2.0.0
                    
#: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=SpawnDev.BlazorJS.PixiJS&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SpawnDev.BlazorJS.PixiJS&version=2.0.0
                    
Install as a Cake Tool

SpawnDev.BlazorJS.PixiJS

NuGet

SpawnDev.BlazorJS.PixiJS is a strongly-typed .NET wrapper for the PixiJS library (v8), bringing the functionality of the "HTML5 Creation Engine" to Blazor WebAssembly.

Create beautiful digital content with the fastest, most flexible 2D WebGL renderer directly in C#.

Demo

Examples Demo

Getting started

1. Installation

Add the Nuget package SpawnDev.BlazorJS.PixiJS to your project using your package manager of choice.

dotnet add package SpawnDev.BlazorJS.PixiJS
2. Configuration

Modify the Blazor WASM Program.cs to initialize SpawnDev.BlazorJS and load the PixiJS library.

Program.cs

using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using SpawnDev.BlazorJS;
using SpawnDev.BlazorJS.PixiJS;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

// Add SpawnDev.BlazorJS interop
builder.Services.AddBlazorJSRuntime();

// Initialize PixiJS. This loads the PixiJS Javascript library.
// It can also be called in a component, or you can manually add the script to index.html.
await PIXI.Init();

// Run app using BlazorJSRunAsync extension method
await builder.Build().BlazorJSRunAsync();

Note: PIXI.Init() loads the bundled pixi.min.js from _content/SpawnDev.BlazorJS.PixiJS/pixi.min.js.

Usage

Here is a comprehensive example of how to create a simple PixiJS application component in Blazor.

ContainerExample.razor
Based on: Basic Container Example

@page "/examples/basic/container"
@using SpawnDev.BlazorJS.JSObjects
@using SpawnDev.BlazorJS.PixiJS
@using static SpawnDev.BlazorJS.PixiJS.PIXI
@implements IDisposable

<h3>Basic Container Example</h3>

<div style="width: 400px; height: 400px;" @ref="containerElRef"></div>

@code {
    [Inject]
    BlazorJSRuntime JS { get; set; } = default!;

    ElementReference? containerElRef;
    Application? app;
    Container? container;

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            await Init();
        }
    }

    async Task Init()
    {
        // Ensure PIXI is initialized (safe to call multiple times)
        await PIXI.Init();

        // Create a new application
        app = new Application();

        // Initialize the application with options
        await app.Init(new ApplicationOptions 
        { 
            Background = "#1099bb", 
            ResizeTo = containerElRef 
        });

        // Append the application canvas to the container element
        using var htmlElement = new HTMLElement(containerElRef!.Value);
        htmlElement.AppendChild(app.Canvas);

        // Create and add a container to the stage
        container = new Container();
        app.Stage.AddChild(container);

        // Load the bunny texture
        using var texture = await Assets.Load<Texture>("https://pixijs.com/assets/bunny.png");

        // Create a 5x5 grid of bunnies
        for (var i = 0; i < 25; i++)
        {
            using var bunny = new Sprite(texture);
            bunny.X = (i % 5f) * 40f;
            bunny.Y = (float)Math.Floor(i / 5f) * 40f;
            container.AddChild(bunny);
        }

        // Center the container
        container.X = app.Screen.Width / 2;
        container.Y = app.Screen.Height / 2;

        // Center the pivot point
        container.Pivot.X = container.Width / 2;
        container.Pivot.Y = container.Height / 2;

        // Add a ticker for animation
        app.Ticker.Add(Tick);
    }

    void Tick(Ticker time)
    {
        if (container != null && !container.IsDisposed)
        {
            // Rotate the container
            container.Rotation -= 0.01f * time.DeltaTime;
        }
    }

    public void Dispose()
    {
        // Clean up resources
        if (app != null)
        {
            app.Ticker.Remove(Tick);
            app.Dispose();
        }
        container?.Dispose();
    }
}

Features

  • Full PixiJS v8 Support: Targets the latest major version of PixiJS.
  • Strongly Typed: Enjoy intellisense and compile-time checking for PixiJS APIs.
  • Blazor Friendly: Designed to work seamlessly with Blazor WebAssembly.
  • No Build Steps: Works directly with SpawnDev.BlazorJS without complex JS build pipelines.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 is compatible.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 176 3/24/2026
2.0.1 97 3/24/2026
2.0.0 101 3/24/2026
1.0.0 135 1/15/2026
1.0.0-preview.1 202 2/16/2025
1.0.0-preview.0 118 1/25/2025
1.0.0-alpha.2 142 7/19/2024