I've declared a class gly that accesses a canvas made with node-canvas.
const width = 250;
const height = 250;
const canvas = createCanvas(height, width);
const gly = canvas.getContext("2d");
A separate function (outside that class) takes multiple arrays of [x,y] coordinates and should draw them onto the canvas. That function is initialized as
function drawShape(shapeClass, color, ...shapes) {
whereas shapeclass is gly.
I've already done this successfully without that function, but as I'm drawing so many shapes onto a canvas, I want to clean up the code by making that function draw the shapes whenever needed. The issue is that whenever gly's class functions are called from within function drawShape, nothing happens. There aren't any errors, and color and ...shapes pass perfectly fine into the function, but the function itself does nothing, leaving an empty space on the canvas.
Am I passing gly correctly into drawShape?
I figured it out - it had nothing to do with how I was using either the functions or the classes. Junk data found itself into an array and threw everything off.