Skip to content

Commit

Permalink
PxTiles is no longer a component, commented out unused dither types…
Browse files Browse the repository at this point in the history
…, privated `PxScreenAlign`
  • Loading branch information
Seldom-SE committed Jan 2, 2025
1 parent 91d5a36 commit 83816b1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<Entity>>,
width: usize,
Expand Down
3 changes: 2 additions & 1 deletion src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
70 changes: 35 additions & 35 deletions src/sprite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 83816b1

Please sign in to comment.