Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[g] dpr 支持运行时修改 #1143

Closed
xiaoiver opened this issue Sep 1, 2022 · 0 comments
Closed

[g] dpr 支持运行时修改 #1143

xiaoiver opened this issue Sep 1, 2022 · 0 comments
Assignees
Labels

Comments

@xiaoiver
Copy link
Contributor

xiaoiver commented Sep 1, 2022

在运行时需要支持重新设置 DPR:

https://github.com/antvis/S2/blob/master/packages/s2-core/src/ui/hd-adapter/index.ts#L101-L102

canvas.set('pixelRatio', dpr);
canvas.changeSize(width, height);

API

新版使用方式如下,修改画布配置后,调用 resize()

canvas.getConfig().devicePixelRatio = dpr;
canvas.resize(width, height);

因此在 resize 中始终需要获取最新 dpr。

实现细节

不同渲染器实现不同。g-svg 可以完全忽略 DPR。

下图为 g-webgl 效果,两个画布使用不同的 DPR 对比,左侧边缘明显会模糊很多:

截屏2022-09-28 下午5 03 09

@xiaoiver xiaoiver self-assigned this Sep 1, 2022
xiaoiver added a commit that referenced this issue Sep 29, 2022
* feat: support advanced features in radial-gradient #1165

* feat: allow changing DPR at runtime #1143

* feat: support applying CSS Transfrom on container #1161

* Publish

 - @antv/g-camera-api@1.0.7
 - @antv/g-canvas@1.9.6
 - @antv/g-canvaskit@0.8.6
 - @antv/g-compat@1.0.7
 - @antv/g-components@1.7.18
 - @antv/g-css-layout-api@1.0.7
 - @antv/g-css-typed-om-api@1.0.7
 - @antv/g-devtool@0.10.18
 - @antv/g-dom-mutation-observer-api@1.0.7
 - @antv/g-gesture@0.0.41
 - @antv/g-image-exporter@0.5.18
 - @antv/g-layout-blocklike@1.7.18
 - @antv/g-lite@1.0.7
 - @antv/g-lottie-player@0.0.4
 - @antv/g-math@1.7.18
 - @antv/g-mobile-canvas-element@0.6.18
 - @antv/g-mobile-canvas@0.8.15
 - @antv/g-mobile-svg@0.8.15
 - @antv/g-mobile-webgl@0.7.21
 - @antv/g-plugin-3d@1.7.18
 - @antv/g-plugin-a11y@0.4.18
 - @antv/g-plugin-annotation@0.2.15
 - @antv/g-plugin-box2d@1.7.18
 - @antv/g-plugin-canvas-path-generator@1.1.18
 - @antv/g-plugin-canvas-picker@1.8.15
 - @antv/g-plugin-canvas-renderer@1.7.21
 - @antv/g-plugin-canvaskit-renderer@1.1.19
 - @antv/g-plugin-control@1.7.18
 - @antv/g-plugin-css-select@1.7.18
 - @antv/g-plugin-device-renderer@1.7.21
 - @antv/g-plugin-dom-interaction@1.7.18
 - @antv/g-plugin-dragndrop@1.6.18
 - @antv/g-plugin-gpgpu@1.7.18
 - @antv/g-plugin-html-renderer@1.7.18
 - @antv/g-plugin-image-loader@1.1.19
 - @antv/g-plugin-matterjs@1.7.18
 - @antv/g-plugin-mobile-interaction@0.7.18
 - @antv/g-plugin-physx@1.7.18
 - @antv/g-plugin-rough-canvas-renderer@1.7.18
 - @antv/g-plugin-rough-svg-renderer@1.7.18
 - @antv/g-plugin-svg-picker@1.7.18
 - @antv/g-plugin-svg-renderer@1.8.15
 - @antv/g-plugin-webgl-device@1.7.18
 - @antv/g-plugin-webgpu-device@1.7.18
 - @antv/g-plugin-yoga@1.7.18
 - @antv/g-shader-components@1.7.18
 - @antv/g-svg@1.8.15
 - @antv/g-web-animations-api@1.0.7
 - @antv/g-web-components@1.7.18
 - @antv/g-webgl@1.7.21
 - @antv/g-webgpu@1.7.21
 - @antv/g@5.10.0
 - @antv/react-g@1.8.15
 - @antv/g-site@1.8.15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant