File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
SceneGraph/RenderWindowViewNode Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -361,6 +361,18 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
361
361
*
362
362
*/
363
363
getVrResolution ( ) : Vector2 ;
364
+
365
+ /**
366
+ * Use to scale the size of a rendered canvas pixel to a browser CSS pixel.
367
+ * `const cssPixelWidth = renderedPixelWidth / apiRenderWindow.getComputedDevicePixelRatio()`
368
+ * 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))`
371
+ *
372
+ * @see getContainerSize()
373
+ * @see getSize()
374
+ */
375
+ getComputedDevicePixelRatio ( ) : number ;
364
376
}
365
377
366
378
/**
Original file line number Diff line number Diff line change @@ -135,14 +135,19 @@ function vtkRenderWindowViewNode(publicAPI, model) {
135
135
return publicAPI . displayToNormalizedDisplay ( x2 , y2 , z ) ;
136
136
} ;
137
137
138
+ publicAPI . getComputedDevicePixelRatio = ( ) =>
139
+ model . size [ 0 ] / publicAPI . getContainerSize ( ) [ 0 ] ;
140
+
141
+ publicAPI . getContainerSize = ( ) => {
142
+ macro . vtkErrorMacro ( 'not implemented' ) ;
143
+ } ;
144
+
138
145
publicAPI . getPixelData = ( x1 , y1 , x2 , y2 ) => {
139
146
macro . vtkErrorMacro ( 'not implemented' ) ;
140
- return undefined ;
141
147
} ;
142
148
143
149
publicAPI . createSelector = ( ) => {
144
150
macro . vtkErrorMacro ( 'not implemented' ) ;
145
- return undefined ;
146
151
} ;
147
152
}
148
153
You can’t perform that action at this time.
0 commit comments