Skip to content

Commit 059a5d8

Browse files
committed
docs(OpenGLRenderWindow): add setSize description
Edited getComputedDevicePixelRatio
1 parent a9aca35 commit 059a5d8

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Sources/Rendering/OpenGL/RenderWindow/index.d.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,18 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
327327
setViewStream(stream: vtkViewStream): boolean;
328328

329329
/**
330-
*
330+
* Sets the pixel width and height of the rendered image.
331+
*
332+
* WebGL and WebGPU render windows apply these values to
333+
* the width and height attribute of the canvas element.
334+
*
335+
* To match the device resolution in browser environments,
336+
* multiply the container size by `window.devicePixelRatio`
337+
* `apiSpecificRenderWindow.setSize(Math.floor(containerWidth * devicePixelRatio), Math.floor(containerHeight * devicePixelRatio));
338+
* See the VTK.js FullscreenRenderWindow class for an example.
339+
*
340+
* @see getComputedDevicePixelRatio()
341+
*
331342
* @param {Vector2} size
332343
*/
333344
setSize(size: Vector2): void;
@@ -363,14 +374,15 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
363374
getVrResolution(): Vector2;
364375

365376
/**
366-
* Use to scale the size of a rendered canvas pixel to a browser CSS pixel.
367-
* `const cssPixelWidth = renderedPixelWidth / apiRenderWindow.getComputedDevicePixelRatio()`
377+
* Scales the size of a browser CSS pixel to a rendered canvas pixel.
378+
* `const renderedPixelWidth = cssPixelWidth * apiRenderWindow.getComputedDevicePixelRatio()`
379+
* Use to scale rendered objects to a consistent perceived size or DOM pixel position.
380+
*
368381
* Rather than using window.devicePixelRatio directly, the device pixel ratio is inferred
369-
* from the container CSS pixel size and rendered image pixel size. The user can reduce the rendered size.
370-
* `apiSpecificRenderWindow.setSize(Math.floor(container.width * window.devicePixelRatio / 2), Math.floor(container.height * window.devicePixelRatio / 2))`
382+
* from the container CSS pixel size and rendered image pixel size. The user directly sets the rendered pixel size.
371383
*
384+
* @see setSize()
372385
* @see getContainerSize()
373-
* @see getSize()
374386
*/
375387
getComputedDevicePixelRatio(): number;
376388
}

0 commit comments

Comments
 (0)