有没有办法找到浏览器的中心?

Is there a way to find the center of a browser?

我希望我的文本位于浏览器的中间 window,有什么方法可以找到(以像素为单位)浏览器的中间?这不仅仅是 HTML 文本,所以我不能使用 CSS 或任何东西。这是我的部分代码,以防您不理解我令人困惑的解释:

<canvas id = "my-canvas" width = "screen.width" height = "screen.height"></canvas>
        

        <script src = "https://cdn.jsdelivr.net/processing.js/1.4.8/processing.min.js"></script>
        <script type = "application/javascript">
            // program code {
                var sketchProc = function(processingInstance) {
                    with (processingInstance) {
                        background(255);
                        fill(0);
                        text("Hi", 300, 300);
                    } 
                };
            // }
            // store canvas {
                var canvas = document.getElementById("my-canvas");
            // }
            // run Processing.js {
                var processingInstance = new Processing(canvas, sketchProc);
            // }
        </script>

这可能对你有用

const width = window.innerWidth / 2;
const height = window.innerHeight / 2;
text("Hi", width, height);