mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
Serials::mint: the method is not an iterator's next
This commit is contained in:
@@ -148,7 +148,7 @@ impl PreviewTextures {
|
||||
}
|
||||
|
||||
fn over(serials: &mut Serials, name: impl Into<String>, levels: Vec<Arc<ColorImage>>, base_uv: [f32; 2]) -> Self {
|
||||
let serial = serials.next();
|
||||
let serial = serials.mint();
|
||||
Self { name: Arc::from(name.into()), serial, images: Arc::new(Mutex::new(levels)), base_uv }
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ impl CoverageMask {
|
||||
let extent = |side: f64| (side / scale).ceil().max(1.0) as u32;
|
||||
let size = (extent(bounds.width()), extent(bounds.height()));
|
||||
let len = size.0 as usize * size.1 as usize;
|
||||
CoverageMask { bounds, scale, size, texels: vec![0; len], base: vec![0; len], dirty: None, revision: 0, id: serials.next() }
|
||||
CoverageMask { bounds, scale, size, texels: vec![0; len], base: vec![0; len], dirty: None, revision: 0, id: serials.mint() }
|
||||
}
|
||||
|
||||
/// Stamps the capsule from `from` to `to` (document units) of radius `radius`, keeping the larger coverage.
|
||||
|
||||
@@ -36,7 +36,7 @@ impl HoverMask {
|
||||
/// [`MAX_TEXELS`](Self::MAX_TEXELS), then `ceil(long side / 768)` units per texel. Coverage outside 0..=1 is
|
||||
/// clamped; one that is not finite reads as 0. Empty or non-finite `bounds` give a 1 × 1 mask with no coverage.
|
||||
pub fn sampled(serials: &mut Serials, bounds: Rect, coverage: impl Fn(f64, f64) -> f32) -> HoverMask {
|
||||
let generation = serials.next();
|
||||
let generation = serials.mint();
|
||||
let finite = bounds.x0.is_finite() && bounds.y0.is_finite() && bounds.x1.is_finite() && bounds.y1.is_finite();
|
||||
if !finite || bounds.width() <= 0.0 || bounds.height() <= 0.0 {
|
||||
return HoverMask { bounds, size: [1, 1], coverage: Arc::from(vec![0u8]), generation };
|
||||
|
||||
@@ -380,8 +380,8 @@ impl<K> Default for Stores<K> {
|
||||
pub struct Serials(u64);
|
||||
|
||||
impl Serials {
|
||||
/// The next number: never one this `Serials` gave before.
|
||||
pub fn next(&mut self) -> u64 {
|
||||
/// A new number: never one this `Serials` gave before.
|
||||
pub fn mint(&mut self) -> u64 {
|
||||
self.0 += 1;
|
||||
self.0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user