//[Inject] //protected HttpClient Http { get; set; } protected override void OnAfterRender() { _ctx = _canvas.CreateCanvas2d(); Console.WriteLine("Canvas happening"); _ctx.FillStyle = "green"; _ctx.FillRect(10, 10, 50, 50); }
public void DrawPlan() { // draw background _canvasContext.FillStyle = "lightblue"; _canvasContext.FillRect(0, 0, _width, _height); // write header _canvasContext.Font = "12px"; _canvasContext.StrokeText("Date/Time/Shift", Ch, Ch); // draw the grid _canvasContext.LineWidth = 1f; //_canvasContext.StrokeStyle = "stroke-width: 0.5;"; for (int i = 0; i < _height / Ch; i++) { _canvasContext.StrokeRect(0, i * Ch, _width, Ch); } for (int i = 0; i < _width / Cw; i++) { _canvasContext.StrokeRect(i * Cw, 0, Cw, _height); } // draw some crosses when staff is assigned to a shift Random rng = new Random(); for (int i = 0; i < 1000; i++) { _canvasContext.StrokeText("X", rng.Next(_width / Cw) * Cw + 8, rng.Next(_height / Ch) * Ch); } }
public void Frame() { _ctx = _canvas.CreateCanvas2d(); Console.WriteLine("Canvas happening"); if (first) { scene = new Scene(0, 500, 0, 500, new V(250, 250), new V(250, 0), 1, new Random()); Console.WriteLine("Made the scene"); charges = new ChargeSet(); charges.AdjustCount(10, scene); charges.Mutate(1000000, 0, 0, scene); Console.WriteLine("Adjusted Count"); particle = new Particle(scene.start); first = false; } particle.PassTime(.1, charges); _ctx.FillStyle = "red"; _ctx.FillRect(particle.location.x, particle.location.y, 5, 5); Console.WriteLine("Location: " + particle.location.x + " " + particle.location.y); foreach (Charge charge in charges.set) { Console.WriteLine("Draw Charge"); _ctx.FillStyle = "gray"; _ctx.FillRect(charge.location.x, charge.location.y, 5, 5); } if (scene.InBounds(particle.location)) { Console.WriteLine("ping"); Frame(); } }