Now let's add some
colour controls. We
define a function that lets the colour be altered:
function SetColor(c) {
ctx.strokeStyle= c;
}
And we create a
button to call the function
<button class=MySideButton style="background-color:red" onclick="SetColour('red')"> Red </button>
There's a few things to notice:
- We're using an inline style for the button colour. Not the best way to do CSS, but makes the example more concise
- We need to pass the colour name as a string inside the call to SetColour, but that call is already inside quotes. The easiest way to quote something that's already inside quotes is just to use the alternative quoting style - double versus single.