
previous

page 12
next
This is what I'm aiming for!

I found this picture on the Internet and took it as a challenge to reproduce it.
Clearly we're going to need some new functions to control colour both of the lines and the background.
So below is bg(colr) to set a background colour by simply drawing a rectangle of that colour which fills the canvas, and pc(colr) to set the pen colour.
add to my.js
I've also included pw(width) to set the pen width.
function bg(colr='white') {
g_ctx.fillStyle=colr;
g_ctx.fillRect(0,0,g_side,g_side);
}
function pc(colr='black') {
g_ctx.strokeStyle=colr;
}
function pw(w=1) {
g_ctx.lineWidth=w;
}
g_ctx.fillStyle=colr;
g_ctx.fillRect(0,0,g_side,g_side);
}
function pc(colr='black') {
g_ctx.strokeStyle=colr;
}
function pw(w=1) {
g_ctx.lineWidth=w;
}
previous
next