Fix spriting imperfections in the thumbnails in the NanoVG

This commit is contained in:
Patrick Walton 2020-04-09 12:15:39 -07:00
parent 0211296128
commit a196f1eff8
3 changed files with 7 additions and 6 deletions

View File

@ -154,7 +154,7 @@ impl Pattern {
#[inline]
pub fn is_opaque(&self) -> bool {
self.source.is_opaque()
self.source.is_opaque() && self.opacity == !0
}
#[inline]

View File

@ -989,11 +989,12 @@ fn draw_thumbnails(context: &mut CanvasRenderingContext2D,
}
let image_path = create_rounded_rect_path(image_rect, 5.0);
let pattern_transform = Transform2F::from_translation(
image_rect.origin() - vec2i(
(image_index % IMAGES_ACROSS) as i32,
(image_index / IMAGES_ACROSS) as i32).to_f32() * THUMB_HEIGHT) *
Transform2F::from_scale(0.5);
let image_coord = vec2i((image_index % IMAGES_ACROSS) as i32,
(image_index / IMAGES_ACROSS) as i32);
let pattern_transform = Transform2F::from_translation(image_rect.origin()) *
Transform2F::from_scale(0.5) *
Transform2F::from_translation(-image_coord.to_f32() * (THUMB_HEIGHT * 2.0 + 2.0) -
1.0);
let mut pattern = Pattern::from_image((*image).clone());
pattern.apply_transform(pattern_transform);
context.set_fill_style(pattern);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 KiB

After

Width:  |  Height:  |  Size: 389 KiB