This commit is contained in:
Nathan Sobo
2021-04-27 18:35:24 -06:00
parent 58e336354e
commit 69cc2b0483
7 changed files with 70 additions and 19 deletions
+15
View File
@@ -140,8 +140,23 @@ impl SpriteCache {
size: Vector2F,
path: Cow<'static, str>,
svg: usvg::Tree,
target_position: Vector2F,
scale_factor: f32,
) -> IconSprite {
const SUBPIXEL_VARIANTS: u8 = 4;
let target_position = target_position * scale_factor;
let subpixel_variant = (
(target_position.x().fract() * SUBPIXEL_VARIANTS as f32).round() as u8
% SUBPIXEL_VARIANTS,
(target_position.y().fract() * SUBPIXEL_VARIANTS as f32).round() as u8
% SUBPIXEL_VARIANTS,
);
let subpixel_shift = vec2f(
subpixel_variant.0 as f32 / SUBPIXEL_VARIANTS as f32,
subpixel_variant.1 as f32 / SUBPIXEL_VARIANTS as f32,
);
let atlases = &mut self.atlases;
let atlas_size = self.atlas_size;
let device = &self.device;