This is probably simple, but I'm not getting it. I'm declaring a function to draw a shape on an html canvas like so:
function res08(ctx, color){
this.color = color;
ctx.save();
ctx.fillStyle = color;
ctx.beginPath();
ctx.moveTo(649, 143);
ctx.lineTo(649, 158);
ctx.lineTo(661, 158);
ctx.lineTo(664, 154);
ctx.bezierCurveTo(665, 155, 666, 157, 666, 158);
ctx.lineTo(683, 158);
ctx.lineTo(683, 144);
ctx.lineTo(674, 144);
ctx.lineTo(674, 137);
ctx.lineTo(678, 137);
ctx.lineTo(678, 111);
ctx.lineTo(648, 111);
ctx.lineTo(648, 143);
ctx.lineTo(649, 143);
ctx.closePath();
ctx.fill();
}
I thought because the function is an object that after it was called I would be able to access the color property like so:
var ctx = document.getElementById('theCanvas').getContext('2d');
var blue = '#9ec3de';
res08(ctx, blue);
console.log( res08.color );
But that's returning undefined. I also tried declaring the function as a variable:
var res08 = function(ctx, color){
What am I missing? Thanks!