• 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:

    • I think you could just do two small fillRects for the two sides of the corner, rather than filling and then clearing? It should be a bit quicker and less flickery
    • Or if you did have to clear, you can use fillRect (fg color) and then clearRect (bg color) to avoid you having to reset the color all the time.
  • 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

About

Avatar for Gordon @Gordon started