BlazorExtensions/Canvas

globalCompositeOperation and debugger behavior

Mteheran opened this issue · 2 comments

I am creating a whiteboard example with signalR and blazor
I am following the current code in JS and I noticed that I need to set a value for this property:
CanvasRenderingContext2D.globalCompositeOperation
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation

Do you know how to set the value for this property using BlazorExtensions.Canvas?

also for some reasons, the following code is only working (actually partially and very slow) when I have the developer tools open (F12):

async Task drawCanvas(double prev_x, double prev_y, double x, double y, string clr)
{
await this._context.BeginBatchAsync();
await this._context.BeginPathAsync();
await this._context.SetStrokeStyleAsync(clr);
await this._context.SetLineWidthAsync(3);
await this._context.MoveToAsync(x, y);
await this._context.LineToAsync(x, y);
await this._context.SetLineJoinAsync(LineJoin.Round);
await this._context.SetLineCapAsync(LineCap.Round);
await this._context.StrokeAsync();
await this._context.EndBatchAsync();
StateHasChanged();
}

This repo seems unmaintained to me. It should be very easy though to switch to https://github.com/excubo-ag/Blazor.Canvas which has a very similar API (batching is done a bit different). Excubo.Blazor.Canvas has support for globalCompositeOperation.

I will try it out! thanks!