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

Add convenient methods for Image #10221

Merged
merged 4 commits into from Oct 22, 2023
Merged

Conversation

st0rmbtw
Copy link
Contributor

@st0rmbtw st0rmbtw commented Oct 21, 2023

Objective

To get the width or height of an image you do:

self.texture_descriptor.size.{width, height}

that is quite verbose.
This PR adds some convenient methods for Image to reduce verbosity.

Changelog

  • Add a width() method for getting the width of an image.
  • Add a height() method for getting the height of an image.
  • Rename the size() method to size_f32().
  • Add a size() method for getting the size of an image as u32.
  • Renamed the aspect_2d() method to aspect_ratio().

Migration Guide

Replace calls to the Image::size() method with size_f32().
Replace calls to the Image::aspect_2d() method with aspect_ratio().

crates/bevy_render/src/texture/image.rs Outdated Show resolved Hide resolved
crates/bevy_render/src/texture/image.rs Outdated Show resolved Hide resolved
@IceSentry IceSentry added A-Rendering Drawing game state to the screen C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide C-Usability A simple quality-of-life change that makes Bevy easier to use labels Oct 21, 2023
@alice-i-cecile
Copy link
Member

Cleaned up your migration guide a bit for you :)

@st0rmbtw
Copy link
Contributor Author

st0rmbtw commented Oct 21, 2023

@alice-i-cecile I was editing the description at the same time with you and have accidentally overwritten your changes ☹️
UPD: grammar

Copy link
Contributor

@rparrett rparrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes.

Some really good opportunities to utilize these throughout the engine for a motivated person in a follow-up PR.

@st0rmbtw
Copy link
Contributor Author

st0rmbtw commented Oct 21, 2023

Those methods are very simple so maybe I should annotate them with inline?

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Oct 22, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 22, 2023
Merged via the queue into bevyengine:main with commit 8efcbf3 Oct 22, 2023
22 checks passed
robtfm pushed a commit to robtfm/bevy that referenced this pull request Oct 23, 2023
# Objective
To get the width or height of an image you do:
```rust
self.texture_descriptor.size.{width, height}
```
that is quite verbose.
This PR adds some convenient methods for Image to reduce verbosity.

## Changelog
* Add a `width()` method for getting the width of an image.
* Add a `height()` method for getting the height of an image.
* Rename the `size()` method to `size_f32()`.
* Add a `size()` method for getting the size of an image as u32.
* Renamed the `aspect_2d()` method to `aspect_ratio()`.

## Migration Guide
Replace calls to the `Image::size()` method with `size_f32()`.
Replace calls to the `Image::aspect_2d()` method with `aspect_ratio()`.
github-merge-queue bot pushed a commit that referenced this pull request Oct 23, 2023
#10227)

# Objective

A follow-up PR for #10221

## Changelog

Replaced usages of texture_descriptor.size with the helper methods of
`Image` through the entire engine codebase
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
# Objective
To get the width or height of an image you do:
```rust
self.texture_descriptor.size.{width, height}
```
that is quite verbose.
This PR adds some convenient methods for Image to reduce verbosity.

## Changelog
* Add a `width()` method for getting the width of an image.
* Add a `height()` method for getting the height of an image.
* Rename the `size()` method to `size_f32()`.
* Add a `size()` method for getting the size of an image as u32.
* Renamed the `aspect_2d()` method to `aspect_ratio()`.

## Migration Guide
Replace calls to the `Image::size()` method with `size_f32()`.
Replace calls to the `Image::aspect_2d()` method with `aspect_ratio()`.
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
bevyengine#10227)

# Objective

A follow-up PR for bevyengine#10221

## Changelog

Replaced usages of texture_descriptor.size with the helper methods of
`Image` through the entire engine codebase
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective
To get the width or height of an image you do:
```rust
self.texture_descriptor.size.{width, height}
```
that is quite verbose.
This PR adds some convenient methods for Image to reduce verbosity.

## Changelog
* Add a `width()` method for getting the width of an image.
* Add a `height()` method for getting the height of an image.
* Rename the `size()` method to `size_f32()`.
* Add a `size()` method for getting the size of an image as u32.
* Renamed the `aspect_2d()` method to `aspect_ratio()`.

## Migration Guide
Replace calls to the `Image::size()` method with `size_f32()`.
Replace calls to the `Image::aspect_2d()` method with `aspect_ratio()`.
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
bevyengine#10227)

# Objective

A follow-up PR for bevyengine#10221

## Changelog

Replaced usages of texture_descriptor.size with the helper methods of
`Image` through the entire engine codebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants