I would like to draw a rectangular grid on the background using HTML5 Canvas API. Please, what is the easiest way how to do that? (opacity should be 0.5)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As My Head Hurts has pointed out, this has been asked before.
Here is the: code/demo.
You also asked for the opacity to be 0.5. You can do this with
fillstyle:You can add that before the draw call. But don’t forget to set it back to 1 after the call.
Also, make sure
ctxis changed to the name of your context var.Note: You’ll probably get a better reception next time if you show that you’ve put some effort into finding the solution yourself, either by adding what you’ve tried or making sure there aren’t any exact duplicate posts. 🙂