Skip to main content

ImagePatternSource

Trait ImagePatternSource 

Source
pub trait ImagePatternSource {
    // Required methods
    fn width(&self) -> f64;
    fn height(&self) -> f64;
    fn pixel(&self, x: i32, y: i32) -> Rgba8;

    // Provided method
    fn pixel_rgba(&self, x: i32, y: i32) -> Rgba { ... }
}
Expand description

Trait for image pattern sources.

Any type implementing this can be used as input to LineImagePattern::create(). The C++ equivalent uses a template parameter with width(), height(), pixel().

Required Methods§

Source

fn width(&self) -> f64

Source

fn height(&self) -> f64

Source

fn pixel(&self, x: i32, y: i32) -> Rgba8

Provided Methods§

Source

fn pixel_rgba(&self, x: i32, y: i32) -> Rgba

Full-precision (floating-point) color used by scaling filters such as LineImageScale.

The default widens the 8-bit pixel result to float. Sources that internally carry more precision — for example an sRGB-decoded, premultiplied pixmap whose C++ color_type is rgba rather than rgba8 — should override this to avoid quantizing at the leaf before the filter runs. That early rounding otherwise costs up to one least-significant bit per channel versus the C++ result, which keeps the source color in floating point all the way through line_image_scale and only converts to rgba8 when the pattern is finally stored.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§