-
Notifications
You must be signed in to change notification settings - Fork 0
fix: Resize SVG to get best quality #43
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
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements dynamic SVG texture quality enhancement by resizing SVG textures based on their rendered size and zoom level to maintain optimal visual quality.
- Adds SVG texture detection and tracking system with automatic quality adjustment
- Implements texture resizing to next power of two when assets are scaled or zoomed
- Fixes rendering scale calculations in transform UI for consistent sizing
Reviewed Changes
Copilot reviewed 7 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/textures.ts | Adds SVG detection, stores original SVG images, and implements texture resizing callback |
| src/logic/svg_textures.zig | New module for managing SVG texture quality with resizing logic and comprehensive tests |
| src/logic/utils.zig | Adds utility functions for power-of-two calculations and float comparisons |
| src/logic/transform_ui.zig | Fixes render scale multiplication order in transform line calculations |
| src/logic/index.zig | Integrates SVG texture system with asset management and adds memory cleanup |
| integration-tests/tests/update-svg-texture.spec.ts | New integration tests for SVG texture quality scenarios |
| integration-tests/init.ts | Updates upload helper to accept custom file paths |
Comments suppressed due to low confidence (1)
src/logic/index.zig:108
- [nitpick] Using 'orelse unreachable' after a successful put operation is correct, but the unreachable could be replaced with a more descriptive panic message for debugging.
const asset_ptr = state.assets.getPtr(id) orelse unreachable;
| new Promise<HTMLImageElement>((resolve) => { | ||
| const img = new Image() | ||
| img.src = url | ||
| img.onload = () => resolve(img) |
Copilot
AI
Jul 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for image loading. The promise will never resolve if the image fails to load, causing potential hangs.
| new Promise<HTMLImageElement>((resolve) => { | |
| const img = new Image() | |
| img.src = url | |
| img.onload = () => resolve(img) | |
| new Promise<HTMLImageElement>((resolve, reject) => { | |
| const img = new Image() | |
| img.src = url | |
| img.onload = () => resolve(img) | |
| img.onerror = () => reject(new Error(`Failed to load image from URL: ${url}`)) |
| }), | ||
| new Promise<{ isSvg: boolean }>((resolve) => { | ||
| fetch(url) | ||
| .then((response) => response.blob()) |
Copilot
AI
Jul 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling for fetch operations. Network failures or non-200 responses will cause unhandled promise rejections.
No description provided.