You are reading a single comment by @OmegaRogue and its replies.
Click here to read the full conversation.
-
I can just do two small fillRects for it, and I can bring them into one function:
function drawCorner(obj, x, y, n) { g.setColor(obj.C.color.primary.base)); let x1; let y1; switch(n) { case 0: // Top Left x1 = x - obj.cornerOffset; y1 = y - obj.cornerOffset; g.fillRect(x1, y1, x, y + obj.cornerSize - obj.cornerOffset); g.fillRect(x1, y1, x + obj.cornerSize - obj.cornerOffset, y); break; case 1: // Top Right x1 = x + obj.cornerOffset; y1 = y - obj.cornerOffset; g.fillRect(x1, y1, x, y + obj.cornerSize - obj.cornerOffset); g.fillRect(x1, y1, x - obj.cornerSize + obj.cornerOffset, y); break; case 2: // Bottom Left x1 = x - obj.cornerOffset; y1 = y + obj.cornerOffset; g.fillRect(x1, y1, x, y - obj.cornerSize + obj.cornerOffset); g.fillRect(x1, y1, x + obj.cornerSize - obj.cornerOffset, y); break; case 3: // Bottom Right x1 = x + obj.cornerOffset; y1 = y + obj.cornerOffset; g.fillRect(x1, y1, x, y - obj.cornerSize + obj.cornerOffset); g.fillRect(x1, y1, x - obj.cornerSize + obj.cornerOffset, y); break; } }
but that seems a bit redundant, because depending on the corner position the operations are different
Keeping them private would allow minification, which would be a big bonus.
Do you need separate functions for each corner? being able to bring them into one function would probably increase the execution speed a lot.
Also, not sure if this helps but: