Revert "Merge pull request #2962 from iced-rs/fix/blurry-quads"
This reverts commit03326b955b, reversing changes made to7c5a4bc465.
This commit is contained in:
parent
6c0962c5c3
commit
9d4e849a0e
31 changed files with 78 additions and 59 deletions
|
|
@ -23,6 +23,12 @@ pub struct Image<H = Handle> {
|
|||
///
|
||||
/// 0 means transparent. 1 means opaque.
|
||||
pub opacity: f32,
|
||||
|
||||
/// If set to `true`, the image will be snapped to the pixel grid.
|
||||
///
|
||||
/// This can avoid graphical glitches, specially when using
|
||||
/// [`FilterMethod::Nearest`].
|
||||
pub snap: bool,
|
||||
}
|
||||
|
||||
impl Image<Handle> {
|
||||
|
|
@ -33,6 +39,7 @@ impl Image<Handle> {
|
|||
filter_method: FilterMethod::default(),
|
||||
rotation: Radians(0.0),
|
||||
opacity: 1.0,
|
||||
snap: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +60,12 @@ impl Image<Handle> {
|
|||
self.opacity = opacity.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets whether the [`Image`] should be snapped to the pixel grid.
|
||||
pub fn snap(mut self, snap: bool) -> Self {
|
||||
self.snap = snap;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Handle> for Image {
|
||||
|
|
|
|||
|
|
@ -250,14 +250,11 @@ impl Rectangle<f32> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let x = (self.x + 0.01).round();
|
||||
let y = (self.y + 0.01).round();
|
||||
|
||||
Some(Rectangle {
|
||||
x: x as u32,
|
||||
y: y as u32,
|
||||
width: ((self.x + self.width + 0.01).round() - x) as u32,
|
||||
height: ((self.y + self.height + 0.01).round() - y) as u32,
|
||||
x: self.x as u32,
|
||||
y: self.y as u32,
|
||||
width,
|
||||
height,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue