Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to draw gridlines #19

Open
richardumesh opened this issue Jun 22, 2020 · 0 comments
Open

How to draw gridlines #19

richardumesh opened this issue Jun 22, 2020 · 0 comments

Comments

@richardumesh
Copy link

Hi, Iam looking to show some gridlines when i load the sketchpad. something like this
image

I used the below function to draw the grid. but the lines disapper as soon i start writing on the sketchpad
drawGrid(ctx, w, h, step) {
// ctx.beginPath();
ctx.beginPath();
for (var y = 0; y <= h; y += step) {
ctx.moveTo(0, y);
ctx.lineTo(w, y);
}
// set the color of the line
ctx.strokeStyle = 'rgb(20,20,20)';
// just for fun
ctx.lineWidth = 1;
// for your original question - you need to stroke only once
ctx.stroke();

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant