Skip to content

Commit

Permalink
Manual: Refactor canvas width and height computation. (#27606)
Browse files Browse the repository at this point in the history
* times one

* add to other languages

* add | 1 to example

* replace | 0 with Math.floor
  • Loading branch information
herobank110 committed Jan 23, 2024
1 parent 1c32bbd commit 6d5140a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions manual/en/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ <h2 id="handling-hd-dpi-displays">Handling HD-DPI displays</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/examples/responsive-hd-dpi.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@

const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if ( needResize ) {

Expand Down
4 changes: 2 additions & 2 deletions manual/fr/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ <h2 id="g-rer-les-affichages-hd-dpi">Gérer les affichages HD-DPI</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/ja/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ <h2 id="hd-dpi-">HD-DPIディスプレイの取り扱い</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/ko/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ <h2 id="hd-dpi-">HD-DPI 디스플레이 다루기</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/ru/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ <h2 id="-hd-dpi">Обработка дисплеев HD-DPI</h2>
<pre class="prettyprint showlinemods notranslate notranslate" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down
4 changes: 2 additions & 2 deletions manual/zh/responsive.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ <h2 id="-hd-dpi-">应对HD-DPI显示器</h2>
<pre class="prettyprint showlinemods notranslate lang-js" translate="no"> function resizeRendererToDisplaySize(renderer) {
const canvas = renderer.domElement;
const pixelRatio = window.devicePixelRatio;
const width = canvas.clientWidth * pixelRatio | 0;
const height = canvas.clientHeight * pixelRatio | 0;
const width = Math.floor(canvas.clientWidth * pixelRatio);
const height = Math.floor(canvas.clientHeight * pixelRatio);
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
renderer.setSize(width, height, false);
Expand Down

0 comments on commit 6d5140a

Please sign in to comment.