De la couleur!
This commit is contained in:
parent
f064b4485e
commit
ef98f9b494
@ -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
|
||||
|
||||
<header>
|
||||
<label>Color: </label>
|
||||
<select @bind="@currentcolor">
|
||||
<option value="Black" selected>Black</option>
|
||||
<option value="Red">Red</option>
|
||||
<option value="Blue">Blue</option>
|
||||
<option value="Gray">Gray</option>
|
||||
</select>
|
||||
@* <input type="radio" name="color" checked="@(this.currentcolor == "Black")" onchange="@(() => this.currentcolor = "Black")" /><label>Black</label>
|
||||
<input type="radio" name="color" checked="@(this.currentcolor == "Red")" onchange="@(() => this.currentcolor = "Red")"/><label>Red</label>
|
||||
<input type="radio" name="color" checked="@(this.currentcolor == "Green")" onchange="@(() => this.currentcolor = "Green")" /><label>Green</label>
|
||||
<input type="radio" name="color" checked="@(this.currentcolor == "Gray")" onchange="@(() => this.currentcolor = "Gray")" /><label>Gray</label> *@
|
||||
</header>
|
||||
<div @ref="divCanvas" @onmousemove="OnMouseMove">
|
||||
<BECanvas @ref="myCanvas" Height="1920" Width="1080"></BECanvas>
|
||||
<BECanvas @ref="myCanvas" Height="1080" Width="1920"></BECanvas>
|
||||
</div>
|
||||
|
||||
<h3>CanvasDrawing</h3>
|
||||
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user