C
C#7mo ago
Bớp

draw board caro

Hi! I want when the user drags up, down, left or right, it will draw more! I am new to C# (MAUI). Below is the code for drawing the mechanical table
namespace CaroGame.Source;

internal class Board : IDrawable {
private readonly float cellSize = 100f;

public void Draw(ICanvas canvas, RectF rect) {
canvas.StrokeColor = Colors.Black;
canvas.StrokeSize = 1;

int numberOfLinesHorizontal = (int)Math.Ceiling(rect.Height / cellSize);
int numberOfLinesVertical = (int)Math.Ceiling(rect.Width / cellSize);

for (int i = 0; i <= numberOfLinesHorizontal; i++) {
float y = i * cellSize;
canvas.DrawLine(rect.Left, y, rect.Right, y);
}

for (int j = 0; j <= numberOfLinesVertical; j++) {
float x = j * cellSize;
canvas.DrawLine(x, rect.Top, x, rect.Bottom);
}
}
}
namespace CaroGame.Source;

internal class Board : IDrawable {
private readonly float cellSize = 100f;

public void Draw(ICanvas canvas, RectF rect) {
canvas.StrokeColor = Colors.Black;
canvas.StrokeSize = 1;

int numberOfLinesHorizontal = (int)Math.Ceiling(rect.Height / cellSize);
int numberOfLinesVertical = (int)Math.Ceiling(rect.Width / cellSize);

for (int i = 0; i <= numberOfLinesHorizontal; i++) {
float y = i * cellSize;
canvas.DrawLine(rect.Left, y, rect.Right, y);
}

for (int j = 0; j <= numberOfLinesVertical; j++) {
float x = j * cellSize;
canvas.DrawLine(x, rect.Top, x, rect.Bottom);
}
}
}
Thanks!
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server