I have a requirement to fill a shape with a two colours – like a chess board.
I have seen some gradient effects with css but have not seen any examples like this.
Would this even be possible in Html5 Canvas?
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.
You sure can. In fact you can fill any arbitrary shape with any repeatable thing, even with shapes that you make in the Canvas itself!
Here’s an example of an arbitrary shape getting filled with “pea pods” that were defined on a canvas: http://jsfiddle.net/NdUcv/
Here it is with a simple checkerboard pattern: http://jsfiddle.net/NdUcv/2/
That second one makes a shape fill look like this:
I create that pattern by making a canvas and then drawing whatever I want to repeat on it:
Then on my normal canvas I can do:
and draw fill anything with that pattern.
Of course it doesn’t have to be a canvas path, you could use a checkerboard image (or any kind of image) and fill a shape with it using the canvas patterns.