You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

Blazorex

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Blazorex

Blazorex is an HTML Canvas wrapper library for Blazor, written with .NET.

1.1.6
Source
nugetNuGet
Version published
Maintainers
1
Created
Source

Blazorex

Nuget

Blazorex

Description

Blazorex is an HTML Canvas wrapper library for Blazor.

Doom fire effect with Blazorex

It has some interesting functionalities like:

  • multiple canvases
  • background rendering
  • image rendering
  • procedural image generation (yes, the fire on the background is fully procedural! Thanks filipedeschamps for the awesome repository showing how to render the Doom fire! )

Installation

Blazorex can be installed as Nuget package: https://www.nuget.org/packages/Blazorex/

Usage

Simple scenario

Just add the Canvas Component to your Razor page and register to the OnCanvasReady to receive the CanvasBase instance.

Then use OnFrameReady to define your update/render logic:

<Canvas Width="800" Height="600" 
        OnFrameReady="(t) => OnFrameReady(t)"
        OnCanvasReady="(ctx) => OnCanvasReady(ctx)" />

@code{
    CanvasBase _canvas;

    private void OnCanvasReady(CanvasBase canvas)
    {
        _canvas = canvas;
    }

    private void OnFrameReady(float timeStamp)
    {
        // your render logic goes here
    }
}

You might also need to update your index.html to include the library's CSS:

<head>
    <!-- other tags... -->
    <link href="_content/Blazorex/blazorex.css" rel="stylesheet" />
</head>

Multiple Canvases

In case you want to have multiple canvases on the same page, you can use the CanvasManager component instead:

<CanvasManager @ref="_canvasManager" />

@code{
        CanvasManager _canvasManager;
        
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (!firstRender)
                return;
        
            _canvasManager.CreateCanvas("myCanvas", new CanvasCreationOptions()
            {
                Width = 800,
                Height = 600,
                Hidden = false,
                OnCanvasReady = this.OnMyCanvasReady,
                OnFrameReady = this.OnMyCanvasFrameReady,
            });
        }
}

You simply have to get a reference to the CanvasManager and then call the CreateCanvas passing an instance of CanvasCreationOptions with the desired parameters.

For a complete list of options for Canvas initialization, see here.

For the complete documentation, check the official website

The ./samples folder contains some examples of how to setup the canvas and draw some cool stuff :)

A sample game can be found here: Blazeroids

Keywords

blazor

FAQs

Package last updated on 03 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts