pub struct ScalarField {
pub width: u32,
pub height: u32,
pub values: Arc<[f32]>,
pub nodata: Option<f32>,
pub geo_scale: Option<GeoScale>,
}Expand description
Per-pixel f32 scalar grid flowing along ScalarField ports.
The general carrier for single-channel floating-point data —
elevation, signed distance, scalar noise, slope angle, anything
“one number per pixel”. Layout is row-major, one f32 per pixel.
width / height MUST match the canvas’s padded_size() so
consumers can pair samples with the same geometry as their raster
output.
geo_scale is populated when the values represent a quantity
measured per real-world distance (e.g. elevation in metres at a
particular latitude). Gradient-based consumers (hillshade,
slope) read it to compute geographically faithful results.
None means the field is unitless / in pixel space — fine for
color-ramp style mapping but stylization-only
for gradient ops.
Missing samples (e.g. ocean nodata in some DEMs) surface as
nodata; consumers fall back to 0.0 or pass-through.
Fields§
§width: u32§height: u32§values: Arc<[f32]>§nodata: Option<f32>§geo_scale: Option<GeoScale>Implementations§
Source§impl ScalarField
impl ScalarField
pub fn sample(&self, x: u32, y: u32) -> f32
Sourcepub fn metres_per_pixel_x(&self) -> f32
pub fn metres_per_pixel_x(&self) -> f32
Real-world metres per pixel along X, or 1.0 when the field
has no geographic scaling. Lets gradient consumers stay
branch-free; the fallback is a no-op scaling that produces
pixel-space gradients — geographically inaccurate but useful
for stylization over non-DEM inputs.
pub fn metres_per_pixel_y(&self) -> f32
Trait Implementations§
Source§impl Clone for ScalarField
impl Clone for ScalarField
Source§fn clone(&self) -> ScalarField
fn clone(&self) -> ScalarField
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more