From 83816b138e917400641dd158981e32c18d772506 Mon Sep 17 00:00:00 2001 From: Seldom <38388947+Seldom-SE@users.noreply.github.com> Date: Thu, 2 Jan 2025 00:03:48 -0700 Subject: [PATCH] `PxTiles` is no longer a component, commented out unused dither types, privated `PxScreenAlign` --- src/map.rs | 4 +-- src/position.rs | 3 ++- src/prelude.rs | 2 +- src/sprite.rs | 70 ++++++++++++++++++++++++------------------------- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/map.rs b/src/map.rs index 84e72a9..914a3c8 100644 --- a/src/map.rs +++ b/src/map.rs @@ -160,8 +160,8 @@ impl PxTileset { } } -/// A tilemap -#[derive(Component, Clone, Default, Debug)] +/// The tiles in a tilemap +#[derive(Clone, Default, Debug)] pub struct PxTiles { tiles: Vec>, width: usize, diff --git a/src/position.rs b/src/position.rs index 8ecbc54..b4acf1b 100644 --- a/src/position.rs +++ b/src/position.rs @@ -181,8 +181,9 @@ impl PxAnchor { } /// Aligns a spatial entity to a corner of the screen +// TODO This is private because it's not done yet #[derive(Component)] -pub struct PxScreenAlign(pub Diagonal); +struct PxScreenAlign(pub Diagonal); /// Float-based position. Add to entities that have [`PxPosition`], but also need /// a sub-pixel position. Use [`PxPosition`] unless a sub-pixel position is necessary. diff --git a/src/prelude.rs b/src/prelude.rs index 2f7c31d..e384062 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -23,7 +23,7 @@ pub use crate::{ filter::{PxFilter, PxFilterAsset, PxFilterLayers}, map::{PxMap, PxTile, PxTiles, PxTileset}, math::{Diagonal, Orthogonal}, - position::{PxAnchor, PxLayer, PxPosition, PxScreenAlign, PxSubPosition, PxVelocity}, + position::{PxAnchor, PxLayer, PxPosition, PxSubPosition, PxVelocity}, screen::ScreenSize, sprite::{PxSprite, PxSpriteAsset}, text::{PxText, PxTypeface}, diff --git a/src/sprite.rs b/src/sprite.rs index 6c1c396..229ee83 100644 --- a/src/sprite.rs +++ b/src/sprite.rs @@ -171,41 +171,41 @@ impl AnimatedAssetComponent for PxSprite { } } -/// Size of threshold map to use for dithering. The image is tiled with dithering according to this -/// map, so smaller sizes will have more visible repetition and worse color approximation, but -/// larger sizes are much, much slower with pattern dithering. -#[derive(Clone, Copy, Debug)] -pub enum ThresholdMap { - /// 2x2 - X2_2, - /// 4x4 - X4_4, - /// 8x8 - X8_8, -} - -/// Dithering algorithm. Perf measurements are for 10,000 pixels with a 4x4 threshold map on a -/// pretty old machine. -#[derive(Clone, Copy, Debug)] -pub enum DitherAlgorithm { - /// Almost as fast as undithered. 16.0 ms in debug mode and 1.23 ms in release mode. Doesn't - /// make very good use of the color palette. - Ordered, - /// Slow, but mixes colors very well. 219 ms in debug mode and 6.81 ms in release mode. Consider - /// only using this algorithm with some optimizations enabled. - Pattern, -} - -/// Info needed to dither an image -#[derive(Clone, Debug)] -pub struct Dither { - /// Dithering algorithm - pub algorithm: DitherAlgorithm, - /// How much to dither. Lower values leave solid color areas. Should range from 0 to 1. - pub threshold: f32, - /// Threshold map size - pub threshold_map: ThresholdMap, -} +// /// Size of threshold map to use for dithering. The image is tiled with dithering according to this +// /// map, so smaller sizes will have more visible repetition and worse color approximation, but +// /// larger sizes are much, much slower with pattern dithering. +// #[derive(Clone, Copy, Debug)] +// pub enum ThresholdMap { +// /// 2x2 +// X2_2, +// /// 4x4 +// X4_4, +// /// 8x8 +// X8_8, +// } +// +// /// Dithering algorithm. Perf measurements are for 10,000 pixels with a 4x4 threshold map on a +// /// pretty old machine. +// #[derive(Clone, Copy, Debug)] +// pub enum DitherAlgorithm { +// /// Almost as fast as undithered. 16.0 ms in debug mode and 1.23 ms in release mode. Doesn't +// /// make very good use of the color palette. +// Ordered, +// /// Slow, but mixes colors very well. 219 ms in debug mode and 6.81 ms in release mode. Consider +// /// only using this algorithm with some optimizations enabled. +// Pattern, +// } +// +// /// Info needed to dither an image +// #[derive(Clone, Debug)] +// pub struct Dither { +// /// Dithering algorithm +// pub algorithm: DitherAlgorithm, +// /// How much to dither. Lower values leave solid color areas. Should range from 0 to 1. +// pub threshold: f32, +// /// Threshold map size +// pub threshold_map: ThresholdMap, +// } // // TODO Example // /// Renders the contents of an image to a sprite every tick. The image is interpreted as