SpawnDev.BlazorJS.PixiJS
1.0.0-preview.0
This is a prerelease version of SpawnDev.BlazorJS.PixiJS.
dotnet add package SpawnDev.BlazorJS.PixiJS --version 1.0.0-preview.0
NuGet\Install-Package SpawnDev.BlazorJS.PixiJS -Version 1.0.0-preview.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="1.0.0-preview.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SpawnDev.BlazorJS.PixiJS --version 1.0.0-preview.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SpawnDev.BlazorJS.PixiJS, 1.0.0-preview.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.
// Install SpawnDev.BlazorJS.PixiJS as a Cake Addin #addin nuget:?package=SpawnDev.BlazorJS.PixiJS&version=1.0.0-preview.0&prerelease // Install SpawnDev.BlazorJS.PixiJS as a Cake Tool #tool nuget:?package=SpawnDev.BlazorJS.PixiJS&version=1.0.0-preview.0&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SpawnDev.BlazorJS.PixiJS
SpawnDev.BlazorJS.PixiJS brings the amazing PixiJS library to Blazor WebAssembly.
The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer in Blazor WebAssembly.
Demo
Getting started
Add the Nuget package SpawnDev.BlazorJS.PixiJS
to your project using your package manager of choice.
Modify the Blazor WASM Program.cs
to initialize SpawnDev.BlazorJS for Javascript interop.
Example Program.cs
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using SpawnDev.BlazorJS;
using SpawnDev.BlazorJS.PixiJS;
using SpawnDev.BlazorJS.PixiJS.Demo;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
// Add SpawnDev.BlazorJS interop
builder.Services.AddBlazorJSRuntime();
// Load the PixiJS Javascript library. Can be called in a component instead if desired, or loaded using a <script> tag in the index.html
await PixiJS.Init();
// Run app using BlazorJSRunAsync extension method
await builder.Build().BlazorJSRunAsync();
ContainerExample.razor
Source: Basic Container Example
@page "/examples/basic/container"
@using SpawnDev.BlazorJS.JSObjects
@using static SpawnDev.BlazorJS.PixiJS.PIXI
@using SpawnDev.BlazorJS.JsonConverters
@implements IDisposable
<p>
Source: <a href="https://pixijs.com/8.x/examples/basic/container">Basic Container Example</a>
</p>
<div style="width: 400px; height: 400px;" @ref="containerElRef"></div>
@code {
[Inject]
BlazorJSRuntime JS { get; set; }
ElementReference? containerElRef = null;
Application? app = null;
Container? container = null;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await Init();
}
}
async Task Init()
{
using var document = JS.GetDocument<Document>();
// Create a new application
app = new Application();
// Initialize the application
await app.Init(new ApplicationOptions { Background = "#1099bb", ResizeTo = containerElRef });
// Append the application canvas to the document body
using var htmlElement = new HTMLElement(containerElRef!.Value);
htmlElement!.AppendChild(app.Canvas);
// Create and add a container to the stage
container = new Container();
using var stage = app.Stage;
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 in the container
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);
}
// Move the container to the center
container.X = app.Screen.Width / 2;
container.Y = app.Screen.Height / 2;
// Center the bunny sprites in local container coordinates
container.Pivot.X = container.Width / 2;
container.Pivot.Y = container.Height / 2;
// Listen for animate update
using var ticker = app.Ticker;
ticker.Add(Tick);
}
void Tick(Ticker time)
{
// Continuously rotate the container!
// * use delta to create frame-independent transform *
container!.Rotation -= 0.01f * time.DeltaTime;
}
public void Dispose()
{
if (app != null)
{
using var ticker = app.Ticker;
ticker.Remove(Tick);
app.Dispose();
}
container?.Dispose();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Microsoft.AspNetCore.Components.WebAssembly (>= 6.0.25)
- SpawnDev.BlazorJS (>= 2.5.37)
-
net7.0
- Microsoft.AspNetCore.Components.WebAssembly (>= 7.0.14)
- SpawnDev.BlazorJS (>= 2.5.37)
-
net8.0
- Microsoft.AspNetCore.Components.WebAssembly (>= 8.0.1)
- SpawnDev.BlazorJS (>= 2.5.37)
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 |
---|---|---|
1.0.0-preview.0 | 31 | 1/25/2025 |
1.0.0-alpha.2 | 76 | 7/19/2024 |