diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-08-28 17:11:42 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-08-28 17:11:42 +0200 |
commit | 09ce75d5bf2d4966bb8cde492ebfb1da687a0bb2 (patch) | |
tree | 6ca3db3c894004d68ef6de6418565ce83b3e935e /web/pw-visualizer | |
parent | 0dbaf29d2f6d06fe8fb7a4e0a2a2552484137f15 (diff) | |
download | planetwars.dev-09ce75d5bf2d4966bb8cde492ebfb1da687a0bb2.tar.xz planetwars.dev-09ce75d5bf2d4966bb8cde492ebfb1da687a0bb2.zip |
hotfix: make sure turn slider does not obstruct view
Diffstat (limited to 'web/pw-visualizer')
-rw-r--r-- | web/pw-visualizer/src/webgl/util.ts | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/web/pw-visualizer/src/webgl/util.ts b/web/pw-visualizer/src/webgl/util.ts index 0a93d67..7b55d19 100644 --- a/web/pw-visualizer/src/webgl/util.ts +++ b/web/pw-visualizer/src/webgl/util.ts @@ -87,24 +87,34 @@ export class Resizer { this.viewbox = [...viewbox]; this.el_box = [el.width, el.height]; + // QUICK FIX: + // when filling the full display canvas, the turn bar will obstruct the bottom planets. + // to resolve this, we shift the viewbox up by 50px. + // This should be implemented in a cleaner way, though :( + let dy = 50 * viewbox[3] / el.height; + this.viewbox[1] -= dy; + this.viewbox[3] += dy; + if (keep_aspect_ratio) { const or_width = this.viewbox[2]; const or_height = this.viewbox[3]; - const width_percentage = this.viewbox[2] / el.width; - const height_percentage = this.viewbox[3] / el.height; + const width_percentage = this.viewbox[2] / this.el_box[0]; + const height_percentage = this.viewbox[3] / this.el_box[1]; + if (width_percentage < height_percentage) { // width should be larger - this.viewbox[2] = height_percentage * el.width; + this.viewbox[2] = height_percentage * this.el_box[0]; } else { // height should be larger - this.viewbox[3] = width_percentage * el.height; + this.viewbox[3] = width_percentage * this.el_box[1]; } this.viewbox[0] -= (this.viewbox[2] - or_width) / 2; this.viewbox[1] -= (this.viewbox[3] - or_height) / 2; + this.scaleX = this.viewbox[2] / this.viewbox[3]; } |