La souris marche.
This commit is contained in:
parent
b983af0c3a
commit
f064b4485e
@ -6,8 +6,8 @@
|
||||
@using Newtonsoft.Json.Linq
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
<div @ref="divCanvas" @onclick="OnClick">
|
||||
<BECanvas @ref="myCanvas" Height="800" Width="800"></BECanvas>
|
||||
<div @ref="divCanvas" @onmousemove="OnMouseMove">
|
||||
<BECanvas @ref="myCanvas" Height="1920" Width="1080"></BECanvas>
|
||||
</div>
|
||||
|
||||
<h3>CanvasDrawing</h3>
|
||||
@ -17,10 +17,12 @@
|
||||
BECanvasComponent myCanvas;
|
||||
Canvas2DContext currentCanvasContext;
|
||||
|
||||
async void OnClick(MouseEventArgs eventArgs)
|
||||
async void OnMouseMove(MouseEventArgs eventArgs)
|
||||
{
|
||||
double mouseX = 0, mouseY = 0;
|
||||
|
||||
if (eventArgs.Buttons == 0)
|
||||
return;
|
||||
if (divCanvas.Id?.Length > 0)
|
||||
{
|
||||
string data = await jsRuntime.InvokeAsync<string>("getDivCanvasOffsets",
|
||||
@ -34,11 +36,11 @@
|
||||
|
||||
currentCanvasContext = await myCanvas.CreateCanvas2DAsync();
|
||||
|
||||
await currentCanvasContext.ClearRectAsync(0, 0, 800, 800);
|
||||
//await currentCanvasContext.ClearRectAsync(0, 0, 800, 800);
|
||||
await currentCanvasContext.SetFillStyleAsync("Red");
|
||||
await currentCanvasContext.FillRectAsync(mouseX, mouseY, 5, 5);
|
||||
await currentCanvasContext.StrokeTextAsync("ClientX: " + mouseX +
|
||||
" Client Y: " + mouseY, 20, 20);
|
||||
await currentCanvasContext.FillRectAsync(mouseX, mouseY, 2, 2);
|
||||
//await currentCanvasContext.StrokeTextAsync("ClientX: " + mouseX +
|
||||
// " Client Y: " + mouseY, 20, 20);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user