var NumeralFont = require("fontclock.font.js");

const DIM_30x47 = [30,47];
const DIM_49x47 = [49,47];
const DIM_37x47 = [37,47];
class DigitNumeralFont extends NumeralFont{
    constructor(){
        super();
        this.widths = atob("DRYqFR0fHyMnICgnDQ==");
        this.font = atob("[encoded data, 6452 characters]");
        var scale = 1; // size multiplier for this font
        this.size = 50+(scale<<8)+(2<<16);
        this.y_offset = -2;

    }
    getDimensions(hour){
        switch(hour){
            case 3:
                return DIM_30x47;
            case 12:
                return DIM_49x47;
            default:
                return DIM_37x47;
        }
    }
    hour_txt(hour){ return hour.toString(); }
    draw(hour_txt,x,y){
        /* going to leave this in here for future testing.
         uncomment this so that it draws a box behind the string
         so we can guess the digit dimensions
        var dim = [37,47];
        g.setColor(0.5,0,0);
        g.fillPoly([x,y,
                      x+dim[0],y,
                      x+dim[0],y+dim[1],
                      x,y+dim[1]
                     ]);
        g.setColor(1.0,1.0,1.0);*/
        g.setFontAlign(-1.0,-1.0,0);
        g.setFontCustom(this.font, 46, this.widths, this.size);
        g.drawString(hour_txt,x,y+this.y_offset );
    }
    getName(){return "Digit";}
}

module.exports = [DigitNumeralFont];