-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
Use Rectangle for Dimensions trait #312
Conversation
} | ||
for p in item.primitive.bounding_box().points() { | ||
if let Some(pixel) = self.get_pixel_mut(p) { | ||
pixel.copy_from_slice(color); |
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.
😚👌
That's delightful :)
|
||
fn size(&self) -> Size { | ||
self.primitive.size() | ||
//FIXME: The bounding box for a styled primitive should use the stroke width and alignment. |
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.
If you're not going to fix this soon, can you create an issue so it doesn't get forgotten about please?
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.
These should be fixed soon, but I've started a tracking issue for these changes.
//FIXME: This temporary method replicates the old broken conversion from diameter to size and | ||
//should be removed. |
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.
As with the other comment, please open an issue if this won't be fixed in the immediate future.
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.
Aside from a couple of comments this looks good.
Hi! Thank you for helping out with Embedded Graphics development! Please:
CHANGELOG.md
entry in the Unreleased section under the appropriate heading (Added, Fixed, etc) and appropriate crate (embedded-graphics
,simulator
,tinytga
,tinybmp
) if your changes affect the public APIrustfmt
on the project./build.sh
(Linux/macOS only) and make sure it passes. If you use Windows, check that CI passes once you've opened the PR.PR description
This PR changes the
Dimensions
trait to return aRectangle
instead of providing separate methods for getting the corners and size. This reduces code duplication and makes it easier to get consistent behavior that should match #182.One example of how this PR can simplify code is the change in
simulator/src/framebuffer.rs
. It uses the newPoints
iterator to iterate over all pixels inside the bounding box.The
Dimension
implementation forCircle
was broken before this PR and wasn't fixed in the PR to keep the scope of this PR smaller. I'll open another PR after this one is merged.