(zoom.js) Show border to canvas

Display borders on the canvas so the canvas bounds are more obvious.
This commit is contained in:
Mnem42 2025-12-16 21:19:15 +00:00 committed by GitHub
parent d681c0bf69
commit e601e24d20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 3 deletions

View File

@ -72,8 +72,9 @@ function gen_button(row, col, html, click, nopos, id){
function add_css(){ function add_css(){
const CSS = ` const CSS = `
#zm_data_div { margin-bottom: 10px; } #zm_data_div { margin-bottom: 10px }
#canvasDiv { overflow: hidden } #canvasDiv { overflow: hidden }
#game { border: solid white }
@media(pointer=coarse){ @media(pointer=coarse){
#zm_floater_container#zm_floater_container { #zm_floater_container#zm_floater_container {
@ -199,6 +200,16 @@ function rescale(){
const y = zoom_panning[1] * (pixelSize * scale) const y = zoom_panning[1] * (pixelSize * scale)
gameCanvas.style.transform = `translate(${x}px,${y}px) scale(${scale})` gameCanvas.style.transform = `translate(${x}px,${y}px) scale(${scale})`
const width = 2 / scale
gameCanvas.style.borderTopWidth =
`${zoom_panning[1] > 0 ? width : 0}px`
gameCanvas.style.borderBottomWidth =
`${zoom_panning[1] < 0 ? width : 0}px`
gameCanvas.style.borderLeftWidth =
`${zoom_panning[0] > 0 ? width : 0}px`
gameCanvas.style.borderRightWidth =
`${zoom_panning[0] < 0 ? width : 0}px`
} }
function log_info(){ function log_info(){