ui.image now takes impl Into<Vec2> as a size argument

This commit is contained in:
Emil Ernerfeldt 2020-12-15 14:25:26 +01:00
parent 09aa905f7c
commit 7710308e09
3 changed files with 8 additions and 3 deletions

View file

@ -8,6 +8,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased
### Changed 🔧
* `ui.image` now takes `impl Into<Vec2>` as a `size` argument
## 0.5.0 - 2020-12-13
### Added ⭐

View file

@ -689,7 +689,7 @@ impl Ui {
}
/// Show an image here with the given size
pub fn image(&mut self, texture_id: TextureId, desired_size: Vec2) -> Response {
pub fn image(&mut self, texture_id: TextureId, desired_size: impl Into<Vec2>) -> Response {
self.add(Image::new(texture_id, desired_size))
}
}

View file

@ -10,11 +10,11 @@ pub struct Image {
}
impl Image {
pub fn new(texture_id: TextureId, desired_size: Vec2) -> Self {
pub fn new(texture_id: TextureId, desired_size: impl Into<Vec2>) -> Self {
Self {
texture_id,
uv: Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)),
desired_size,
desired_size: desired_size.into(),
bg_fill: Default::default(),
tint: color::WHITE,
}