function draw(g, state, drawInfo) {
    var x = drawInfo.texArea[0];
    var y = drawInfo.texArea[1];
    var w = drawInfo.texArea[2] - drawInfo.texArea[0];
    var h = drawInfo.texArea[3] - drawInfo.texArea[1];

    g.setColor(Color.WHITE);
    g.fillRect(drawInfo.texArea[0], drawInfo.texArea[1], drawInfo.texArea[2], drawInfo.texArea[3]);

    var routeInfo = drawInfo.routeInfo;
    // setDebugInfo(`Drawing! routeinfo: ${JSON.stringify(routeInfo)}`);
    if (routeInfo != null && routeInfo != undefined) {
        var CircularState = {
            NONE: "NONE",
            CLOCKWISE: "CLOCKWISE",
            ANTICLOCKWISE: "ANTICLOCKWISE"
        };
        var routeColor = routeInfo.routeColor;
        // setDebugInfo(`drawing! drawinfo: ${JSON.stringify(drawInfo, replacer)}`);
        var font = loadResource("font", "mtrsteamloco:fonts/source-han-sans.otf");
        var fontBold = loadResource("font", "mtrsteamloco:fonts/source-han-sans-bold.otf");

        var circularState = routeInfo.circularState;

        g.setColor(routeColor);
        g.fillRect(x, heightPercent(0.55), w, h * 0.05);

        g.setColor(Color.BLACK);

        drawStrDL(g, fontBold, fontBold, routeInfo.drawStations[drawInfo.index].stationName, widthPercent(0.5), heightPercent(0.15), h * 0.325, 1, 1);

        if (drawInfo.index == routeInfo.drawStations.length - 1 && circularState == CircularState.NONE) {
            drawStrDL(g, fontBold, fontBold, "终点站|Terminals", widthPercent(0.5), heightPercent(0.7), h * 0.2, 1, 1);
        } else {
            drawStrDL(g, font, font, "下一站|Next Station", widthPercent(0.1), heightPercent(0.75), h * 0.15, 0, 0);
            drawStrDL(
                g,
                fontBold,
                fontBold,
                routeInfo.drawStations[drawInfo.index + 1 == routeInfo.drawStations.length ? 0 : drawInfo.index + 1].stationName,
                widthPercent(0.9),
                heightPercent(0.7),
                h * 0.2,
                2,
                1
            );
        }
    }
    function widthPercent(p) {
        return x + w * p;
    }
    function heightPercent(p) {
        return y + h * p;
    }
}
