Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mizrael committed Jun 13, 2023
1 parent 414bf85 commit 07857db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
22 changes: 9 additions & 13 deletions src/Blazorex.Web/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@
if (!firstRender)
return;

_canvasManager.CreateCanvas("main", new CanvasCreationOptions()
{
Hidden = false,
Width = _width,
Height = _height,
OnCanvasReady = this.OnMainCanvasReady,
OnFrameReady = this.OnMainFrameReady,
});
_canvasManager.CreateCanvas("fire", new CanvasCreationOptions()
{
Hidden = false,
Expand All @@ -54,7 +46,14 @@
OnCanvasReady = this.OnFireCanvasReady,
OnFrameReady = this.OnFireCanvasFrameReady,
});

_canvasManager.CreateCanvas("main", new CanvasCreationOptions()
{
Hidden = false,
Width = _width,
Height = _height,
OnCanvasReady = this.OnMainCanvasReady,
OnFrameReady = this.OnMainFrameReady,
});
}

private void OnFireCanvasReady(CanvasBase canvas)
Expand Down Expand Up @@ -100,10 +99,7 @@
{
_context.ClearRect(0, 0, _width, _height);

//_context.DrawImage(_fireCanvas.ElementReference, 0,0, _fireWidth, _fireHeight);
_context.FillStyle = "green";
_context.FillRect(0, 0, _width, _height);
_context.DrawImage(_fireCanvas.ElementReference, 0, 0, _width, _height);

_context.StrokeStyle = "rgb(255, 255,0)";
_context.LineWidth = 3;
Expand Down
8 changes: 3 additions & 5 deletions src/Blazorex.Web/Services/FireRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Components;

namespace Blazorex.Web.Services
namespace Blazorex.Web.Services
{
public class FireRenderer
{
Expand Down Expand Up @@ -47,7 +45,7 @@ public void Update()

public void Render()
{
_context.PutImageData(_renderTarget, fireColorData, 10, 50);
_context.PutImageData(_renderTarget, fireColorData, 0, 0);
}

private void UpdateFireIntensityPerPixel(int currentPixelIndex)
Expand All @@ -66,7 +64,7 @@ private void UpdateFireIntensityPerPixel(int currentPixelIndex)
fireData[fireDataIndex] = newFireIntensity;

int colorIndex = fireDataIndex * 4;
var color = Color.White;// (newFireIntensity >= palette.Length) ? Color.White : palette[newFireIntensity];
var color = (newFireIntensity >= palette.Length) ? Color.White : palette[newFireIntensity];
fireColorData[colorIndex] = color.R;
fireColorData[colorIndex + 1] = color.G;
fireColorData[colorIndex + 2] = color.B;
Expand Down

0 comments on commit 07857db

Please sign in to comment.