From ef98f9b494adec328617a8bc85d90b78cff0bfa9 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Sat, 11 Nov 2023 17:07:10 -0500 Subject: [PATCH] De la couleur! --- BlazorCanvas/BlazorCanvas/Pages/Index.razor | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/BlazorCanvas/BlazorCanvas/Pages/Index.razor b/BlazorCanvas/BlazorCanvas/Pages/Index.razor index 35bb4f4..d1aeb09 100644 --- a/BlazorCanvas/BlazorCanvas/Pages/Index.razor +++ b/BlazorCanvas/BlazorCanvas/Pages/Index.razor @@ -2,12 +2,26 @@ @using Blazor.Extensions @using Blazor.Extensions.Canvas @using Blazor.Extensions.Canvas.Canvas2D +@using Blazor.Extensions.Canvas.WebGL @using Newtonsoft.Json @using Newtonsoft.Json.Linq @inject IJSRuntime jsRuntime +
+ + + @* + + + *@ +
- +

CanvasDrawing

@@ -17,6 +31,8 @@ BECanvasComponent myCanvas; Canvas2DContext currentCanvasContext; + private string currentcolor { get; set; }// = "Black"; + async void OnMouseMove(MouseEventArgs eventArgs) { double mouseX = 0, mouseY = 0; @@ -37,8 +53,8 @@ currentCanvasContext = await myCanvas.CreateCanvas2DAsync(); //await currentCanvasContext.ClearRectAsync(0, 0, 800, 800); - await currentCanvasContext.SetFillStyleAsync("Red"); - await currentCanvasContext.FillRectAsync(mouseX, mouseY, 2, 2); + await currentCanvasContext.SetFillStyleAsync(currentcolor); + await currentCanvasContext.FillRectAsync(mouseX, mouseY, 1, 1); //await currentCanvasContext.StrokeTextAsync("ClientX: " + mouseX + // " Client Y: " + mouseY, 20, 20);