Conversation
Owner
Author
|
@copilot |
Agent-Logs-Url: https://github.com/echosoar/canvas-rs/sessions/872c790f-1c54-4484-bcc8-0facd661cd5b Co-authored-by: echosoar <14832743+echosoar@users.noreply.github.com>
Done in cf5455e. The repo is now a Cargo workspace with two crates:
Integration tests have been moved to |
Copilot
AI
changed the title
fix: y
refactor: split canvas-rs into canvas and images workspace crates
Mar 30, 2026
Owner
Author
|
我无法使用任何外部依赖,所以 images 里面无法依赖png库,png的encode 和decode 都需要源码重新实现 |
Copilot
AI
changed the title
refactor: split canvas-rs into canvas and images workspace crates
refactor: split canvas-rs into canvas and images workspace crates (zero external dependencies)
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reorganises the project as a Cargo workspace with two separate crates, both with zero external dependencies:
Changes Made
canvascrate — core 2D drawing library that operates entirely on an in-memory RGBA pixel buffer. No external dependencies.to_data_urlandto_blobhave been removed fromCanvas.imagescrate — PNG encoding and decoding implemented entirely in pure Rust with no external dependencies. Exposes:images::to_data_url(canvas: &Canvas) -> String— encodes a canvas as adata:image/png;base64,…URLimages::to_blob(canvas: &Canvas) -> Vec<u8>— returns raw PNG bytes for a canvasimages::from_png(bytes: &[u8]) -> Result<ImageData, String>— decodes a PNG byte slice into RGBAImageDatausing a pure-Rust DEFLATE/zlib decoderBoth PNG encoding (zlib stored-block DEFLATE) and PNG decoding (zlib inflate + PNG filter reconstruction) are implemented from scratch with no third-party crates.
Testing
images/tests/and updated to use the newimages::to_data_url,images::to_blob, andimages::from_pngAPI💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.