Blazor.Extensions.RCanvas
8.0.0
dotnet add package Blazor.Extensions.RCanvas --version 8.0.0
NuGet\Install-Package Blazor.Extensions.RCanvas -Version 8.0.0
<PackageReference Include="Blazor.Extensions.RCanvas" Version="8.0.0" />
<PackageVersion Include="Blazor.Extensions.RCanvas" Version="8.0.0" />
<PackageReference Include="Blazor.Extensions.RCanvas" />
paket add Blazor.Extensions.RCanvas --version 8.0.0
#r "nuget: Blazor.Extensions.RCanvas, 8.0.0"
#:package Blazor.Extensions.RCanvas@8.0.0
#addin nuget:?package=Blazor.Extensions.RCanvas&version=8.0.0
#tool nuget:?package=Blazor.Extensions.RCanvas&version=8.0.0
Blazor.Extensions.RCanvas
This repository consists of Canvas integration or Canvas Reference in Blazor. we can use the exact methods and properties of canvas javascript in blazor to draw a 2D context.
Run below npm commands in vscode terminal.
- install nuget package "Blazor.Extensions.RCanvas" to the Project
- Please ensure that "OnAfterRenderAsync" method is get called, because it will get called on Interactive RenderMode.
How to use
Add the Below script tag in head section.
<script src="_content/Blazor.Extensions.RCanvas/Canvas/RCanvas.razor.js" type="text\javascript">
</script>Add the below namespaces in the component or page.
@using Blazor.Extensions.RCanvas.Canvas; @using WebComponents.Components.Controls.Canvas
Use the Canvas by add the below html tag.
<RCanvas @ref="Canv" Width="400" Height="400"></RCanvas>
In CS code how to access, see the below snippet.
@code {
private RCanvas Canv {get; set;}
private CanvasContext canvasContext;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
try {
if(firstRender) {
this.Canv.ScriptLoaded = async () =>
{
await CreateCanvas();
};
}
}
catch(Exception ex){
string m = ex.Message;
}
await base.OnAfterRenderAsync(firstRender);
}
private async Task CreateCanvas(){
if (this.Canv.IsScriptLoaded)
{
canvasContext = await this.Canv.CreateContext2DAsync();
if(canvasContext!=null)
{
await canvasContext.BeginPathAsync();
canvasContext.LineWidth = 2;
var met = await canvasContext.MeasureTextAsync("Sample Title");
await canvasContext.MoveToAsync(0, 0);
await canvasContext.LineToAsync(300, 170);
await canvasContext.StrokeAsync();
await canvasContext.ClosePathAsync();
await canvasContext.BeginPathAsync();
var res = await canvasContext.CreateLinearGradientAsync(0,0,270, 0);
await res.AddColorStopAsync(0, "blue");
await res.AddColorStopAsync(0.7, "yellow");
await res.AddColorStopAsync(1, "red");
canvasContext.FillStyle = res.RsubId;
await canvasContext.FillRectAsync(20,20,150,100);
await canvasContext.ClosePathAsync();
}
}
}
Product | Versions 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 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. 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. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.10)
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 |
---|