### pub fn get(&self, s: BrushSetting) -> &SettingValue Source: https://docs.rs/hokusai/latest/hokusai/brush/struct.Brush.html?search=u32+-%3E+bool Returns a reference to the value of the specified brush setting. ```APIDOC ## pub fn get(&self, s: BrushSetting) -> &SettingValue ### Description Returns a reference to the value of the specified brush setting. ### Method get ### Parameters - **s** (BrushSetting) - The setting to retrieve. ### Returns - **&SettingValue** - A reference to the setting value. ``` -------------------------------- ### BrushInput Enum Source: https://docs.rs/hokusai/latest/hokusai/enum.BrushInput.html?search=std%3A%3Avec The BrushInput enum represents different brush input types. It has 19 variants, each with a numeric value, and provides methods to get the canonical name, find a variant from a name, and get the numeric index. ```APIDOC ## Enum BrushInput ### Description The `BrushInput` enum defines various input types for brush behavior, such as pressure, speed, tilt, and direction. It is used to specify which input drives a brush parameter. ### Variants - `Pressure = 0` - `Speed1 = 1` - `Speed2 = 2` - `Random = 3` - `Stroke = 4` - `Direction = 5` - `Tilt = 6` - `TiltDeclination = 7` - `TiltAscension = 8` - `DirectionAngle = 9` - `AttackAngle = 10` - `GridmapX = 11` - `GridmapY = 12` - `Custom = 13` - `TiltDeclinationX = 14` - `TiltDeclinationY = 15` - `Viewzoom = 16` - `BarrelRotation = 17` - `BrushRadius = 18` ### Implementations #### `pub const ALL: &'static [BrushInput]` A slice containing all variants of `BrushInput`. #### `pub const fn cname(self) -> &'static str` Returns the canonical name of the variant as a string. #### `pub fn from_cname(s: &str) -> Option` Attempts to find a `BrushInput` variant from its canonical name. Returns `Some(variant)` if found, otherwise `None`. #### `pub const fn index(self) -> usize` Returns the numeric index of the variant. ### Trait Implementations The enum implements the following traits: `Clone`, `Copy`, `Debug`, `Default`, `Eq`, `Hash`, `PartialEq`, and `StructuralPartialEq`. ``` -------------------------------- ### Brush::new Source: https://docs.rs/hokusai/latest/hokusai/brush/struct.Brush.html?search=std%3A%3Avec Creates a new Brush instance with default settings. ```APIDOC ## Brush::new ### Description Creates a new Brush instance with default settings. ### Method `pub fn new() -> Brush` ### Parameters None. ### Returns - `Brush` - A new Brush instance. ``` -------------------------------- ### pub const ALL: &'static [BrushSetting] Source: https://docs.rs/hokusai/latest/hokusai/setting/enum.BrushSetting.html?search=std%3A%3Avec A constant array of all BrushSetting variants. ```APIDOC ## pub const ALL: &'static [BrushSetting] ### Description A constant array containing all variants of the BrushSetting enum. ### Type &'static [BrushSetting] ### Usage Access all brush settings as a slice. ### Example ```rust let all_settings = BrushSetting::ALL; ``` ``` -------------------------------- ### Rust Enum BrushInput Source: https://docs.rs/hokusai/latest/hokusai/enum.BrushInput.html?search=u32+-%3E+bool Definition of the BrushInput enum with variants and their discriminant values, plus associated methods for converting to/from names and getting indices. ```APIDOC ## Rust Doc: BrushInput Enum ### Description The `BrushInput` enum represents different types of brush input parameters. Each variant corresponds to a specific input type and has an associated numeric value. ### Variants - `Pressure = 0` - `Speed1 = 1` - `Speed2 = 2` - `Random = 3` - `Stroke = 4` - `Direction = 5` - `Tilt = 6` - `TiltDeclination = 7` - `TiltAscension = 8` - `DirectionAngle = 9` - `AttackAngle = 10` - `GridmapX = 11` - `GridmapY = 12` - `Custom = 13` - `TiltDeclinationX = 14` - `TiltDeclinationY = 15` - `Viewzoom = 16` - `BarrelRotation = 17` - `BrushRadius = 18` ### Implementations #### `pub const ALL: &'static [BrushInput]` A constant slice containing all variants of `BrushInput`. #### `pub const fn cname(self) -> &'static str` Returns the canonical name of the variant as a string literal. #### `pub fn from_cname(s: &str) -> Option` Converts a string name to the corresponding `BrushInput` variant. Returns `None` if the name is not recognized. #### `pub const fn index(self) -> usize` Returns the numeric index/discriminant of the variant. ### Trait Implementations - `Clone`, `Copy`, `Debug`, `Default`, `Eq`, `Hash`, `PartialEq`, `StructuralPartialEq` are implemented. - Also implements auto traits like `Send`, `Sync`, `Unpin`, etc., and blanket implementations from `Any`, `Borrow`, `BorrowMut`, etc. ### Example Usage ```rust use brush::BrushInput; let input = BrushInput::Pressure; let index = input.index(); // returns 0 let name = input.cname(); // returns "Pressure" \nlet from_name = BrushInput::from_cname("Speed1"); // Some(BrushInput::Speed1) ``` ``` -------------------------------- ### pub fn new() -> Brush Source: https://docs.rs/hokusai/latest/hokusai/brush/struct.Brush.html?search=u32+-%3E+bool Creates a new Brush instance with default settings. ```APIDOC ## pub fn new() -> Brush ### Description Creates a new Brush instance with default settings. ### Method new ### Parameters None ### Returns - **Brush** - A new Brush instance. ``` -------------------------------- ### MemSurface::new Source: https://docs.rs/hokusai/latest/hokusai/tile_mem/struct.MemSurface.html?search=std%3A%3Avec Creates a new, empty MemSurface instance. ```APIDOC ## [mem_surface_new] ### Description Creates a new in-memory surface instance. ### Method `pub fn new() -> MemSurface` ### Parameters None. ### Returns - `MemSurface` - A new, empty surface. ``` -------------------------------- ### pub fn from_cname(s: &str) -> Option Source: https://docs.rs/hokusai/latest/hokusai/setting/enum.BrushSetting.html?search=std%3A%3Avec Attempts to convert a canonical string name back into a BrushSetting. ```APIDOC ## pub fn from_cname(s: &str) -> Option ### Description Attempts to convert a canonical string name back into a BrushSetting. ### Parameters - **s** (&str) - The canonical string name. ### Returns - **Option** - The corresponding BrushSetting, or None if not found. ### Example ```rust if let Some(setting) = BrushSetting::from_cname("opacity") { // use setting } ``` ``` -------------------------------- ### tile_request_start Source: https://docs.rs/hokusai/latest/hokusai/surface/trait.TiledSurface.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Requests a mutable reference to a 64x64 tile at the given coordinates, used for tile-based modification. ```APIDOC ## tile_request_start(tx: i32, ty: i32) ### Description Requests a mutable reference to a 64x64 tile at the given coordinates. ### Method Required method of `TiledSurface` trait. ### Parameters - `tx` (i32) - Required - X coordinate of the tile. - `ty` (i32) - Required - Y coordinate of the tile. ### Returns `&mut [[[u16; 4]; 64]; 64]` - Mutable reference to the tile data. ``` -------------------------------- ### BrushSetting::cname Source: https://docs.rs/hokusai/latest/hokusai/enum.BrushSetting.html Returns the libmypaint canonical string name for the brush setting, matching .myb JSON keys. ```APIDOC ## BrushSetting::cname ### Description Returns the libmypaint canonical string name for the brush setting, matching `.myb` JSON keys. ### Method pub const fn cname(self) -> &'static str ### Parameters - **self** (BrushSetting) - The brush setting enum value. ### Returns - **&'static str** - The canonical string name. ### Example ```rust let name = setting.cname(); ``` ``` -------------------------------- ### pub fn settings(&self) -> &[SettingValue] Source: https://docs.rs/hokusai/latest/hokusai/brush/struct.Brush.html?search=u32+-%3E+bool Returns a slice of all setting values in the brush. ```APIDOC ## pub fn settings(&self) -> &[SettingValue] ### Description Returns a slice of all setting values in the brush. ### Method settings ### Parameters None ### Returns - **&[SettingValue]** - A slice of setting values. ``` -------------------------------- ### Flatten a MemSurface to a Pixmap with flatten_over_white Source: https://docs.rs/hokusai-tiny-skia/%5E0.3.0 Creates a MemSurface, renders to it, then flattens over white and saves as PNG. Requires tiny-skia's png-format feature for save_png. ```rust use hokusai_core::TiledSurface; use hokusai_tile_mem::MemSurface; let mut surf = MemSurface::new(); render(&mut surf); let pixmap = hokusai_tiny_skia::flatten_over_white(&surf, 320, 120); pixmap.save_png("out.png").unwrap(); // requires tiny-skia's png-format feature ``` -------------------------------- ### SettingValues::new Source: https://docs.rs/hokusai/latest/hokusai/evaluator/struct.SettingValues.html?search= Creates a new SettingValues instance. ```APIDOC ## SettingValues::new ### Description Creates a new SettingValues instance. ### Method new ### Signature pub fn new() -> SettingValues ### Parameters None ### Returns - **SettingValues** - A new SettingValues instance. ``` -------------------------------- ### BrushSetting::from_cname Source: https://docs.rs/hokusai/latest/hokusai/setting/enum.BrushSetting.html Converts a string name to a BrushSetting, returning None if the name does not match any setting. ```APIDOC ## BrushSetting::from_cname ### Description Converts a string name to a BrushSetting, returning None if the name does not match any setting. ### Signature ```rust pub fn from_cname(s: &str) -> Option ``` ### Parameters - `s` (&str) - The string name to convert. ### Returns - `Option` - The corresponding BrushSetting, or None if not found. ``` -------------------------------- ### InputMapping Source: https://docs.rs/hokusai/latest/hokusai/mapping/struct.InputMapping.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the InputMapping struct, its fields, and its methods. ```APIDOC ## Struct InputMapping ### Description Represents a mapping from brush input to output offsets using piecewise-linear knots. ### Fields - **input** (`BrushInput`) - The brush input type. - **points** (`Vec<(f32, f32)>`) - `(input_value, output_offset)` knots. libmypaint requires `x` strictly ascending. Output is added to `base_value` after summing all inputs. ### Methods #### `new` ##### Signature `pub fn new(input: BrushInput) -> InputMapping` ##### Description Creates a new `InputMapping` with the given brush input. #### `eval` ##### Signature `pub fn eval(&self, x: f32) -> f32` ##### Description Evaluates the piecewise-linear curve at `x`. Mirrors libmypaint’s `mypaint_mapping_calculate` (mypaint-mapping.c): starts with the first two knots, walks forward while `x > x1`, and if the resulting bracket has `x0 == x1` or `y0 == y1` returns `y0` directly to dodge division by zero on duplicate-x knots (Dieterle/Posterizer’s opaque_multiply curve has `[(0,0),(0,1),(1,1)]` exactly). ### Trait Implementations - `Clone` - `Debug` - `Default` - `PartialEq` - `StructuralPartialEq` ``` -------------------------------- ### SettingValues::new Source: https://docs.rs/hokusai/latest/hokusai/evaluator/struct.SettingValues.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new SettingValues instance with default values. ```APIDOC ## SettingValues::new ### Description Creates a new SettingValues instance with default values. ### Method new ### Signature pub fn new() -> SettingValues ### Returns - **SettingValues** - A new SettingValues instance. ``` -------------------------------- ### BrushSetting::ALL Source: https://docs.rs/hokusai/latest/hokusai/enum.BrushSetting.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns a static slice containing all BrushSetting variants. ```APIDOC ## BrushSetting::ALL ### Description Returns a static slice containing all BrushSetting variants. ### Method Associated constant ### Signature `pub const ALL: &'static [BrushSetting]` ### Returns - `&'static [BrushSetting]` - A slice of all BrushSetting variants. ``` -------------------------------- ### InputMapping::new Source: https://docs.rs/hokusai/latest/hokusai/mapping/struct.InputMapping.html?search=u32+-%3E+bool Creates a new InputMapping instance with the specified brush input. This is the constructor for the InputMapping struct. ```APIDOC ## InputMapping::new ### Description Creates a new `InputMapping` instance with the given brush input. ### Method `pub fn new(input: BrushInput) -> InputMapping` ### Parameters - **input** (BrushInput) - Required - The brush input for the mapping. ### Returns - **InputMapping** - The newly created InputMapping struct. ``` -------------------------------- ### InputMapping::new Source: https://docs.rs/hokusai/latest/hokusai/mapping/struct.InputMapping.html?search=std%3A%3Avec Creates a new InputMapping instance for the given brush input. ```APIDOC ## Rust ### Description Creates a new `InputMapping` instance with the provided `BrushInput` and an empty points vector. ### Method `pub fn new(input: BrushInput) -> InputMapping` ### Parameters - `input` (BrushInput) - Required - The brush input associated with this mapping. ### Returns A new `InputMapping` struct. ``` -------------------------------- ### RgbaF32::new Source: https://docs.rs/hokusai/latest/hokusai/color/struct.RgbaF32.html Creates a new RgbaF32 instance with the given red, green, blue, and alpha components. ```APIDOC ## RgbaF32::new ### Description Creates a new RgbaF32 instance with the given red, green, blue, and alpha components. ### Method `pub const fn new(r: f32, g: f32, b: f32, a: f32) -> RgbaF32` ### Parameters - **r** (f32) - Required - Red component. - **g** (f32) - Required - Green component. - **b** (f32) - Required - Blue component. - **a** (f32) - Required - Alpha component. ### Returns - **RgbaF32** - The constructed color. ### Example ```rust let color = RgbaF32::new(1.0, 0.5, 0.0, 1.0); ``` ``` -------------------------------- ### RgbaF32::new Source: https://docs.rs/hokusai/latest/hokusai/color/struct.RgbaF32.html?search=u32+-%3E+bool Creates a new RgbaF32 instance with the given red, green, blue, and alpha components. ```APIDOC ## RgbaF32::new ### Description Creates a new RgbaF32 instance with the given red, green, blue, and alpha components. ### Signature ```rust pub const fn new(r: f32, g: f32, b: f32, a: f32) -> RgbaF32 ``` ### Parameters - **r** (f32) - Required - Red component. - **g** (f32) - Required - Green component. - **b** (f32) - Required - Blue component. - **a** (f32) - Required - Alpha component. ### Returns - **RgbaF32** - The constructed color. ``` -------------------------------- ### RgbaF32::new Source: https://docs.rs/hokusai/latest/hokusai/color/struct.RgbaF32.html?search= Creates a new RgbaF32 instance with the given red, green, blue, and alpha components. ```APIDOC ## RgbaF32::new ### Description Creates a new RgbaF32 instance with the given red, green, blue, and alpha components. ### Method new ### Signature pub const fn new(r: f32, g: f32, b: f32, a: f32) -> RgbaF32 ### Parameters - **r** (f32) - Required - Red component. - **g** (f32) - Required - Green component. - **b** (f32) - Required - Blue component. - **a** (f32) - Required - Alpha component. ### Returns - **RgbaF32** - The constructed color value. ``` -------------------------------- ### pub const fn cname(self) -> &'static str Source: https://docs.rs/hokusai/latest/hokusai/setting/enum.BrushSetting.html?search=std%3A%3Avec Returns the libmypaint canonical string name for the brush setting, matching .myb JSON keys. ```APIDOC ## pub const fn cname(self) -> &'static str ### Description Returns the libmypaint canonical string name for the brush setting, matching `.myb` JSON keys. ### Parameters - **self** (BrushSetting) - The brush setting. ### Returns - **&'static str** - The canonical string name. ### Example ```rust let name = setting.cname(); ``` ``` -------------------------------- ### pub const fn index(self) -> usize Source: https://docs.rs/hokusai/latest/hokusai/setting/enum.BrushSetting.html?search=std%3A%3Avec Returns the index of the brush setting. ```APIDOC ## pub const fn index(self) -> usize ### Description Returns the index of the brush setting. ### Parameters - **self** (BrushSetting) - The brush setting. ### Returns - **usize** - The index. ### Example ```rust let idx = setting.index(); ``` ``` -------------------------------- ### pub fn empty_tile() -> Box<[[[u16; 4]; 64]; 64]> Source: https://docs.rs/hokusai/latest/hokusai/tile/fn.empty_tile.html?search= Creates a new empty tile represented as a boxed 64x64 grid of RGBA color values, each component being a u16. ```APIDOC ## pub fn empty_tile() -> Box<[[[u16; 4]; 64]; 64]> ### Description Creates a new empty tile represented as a boxed 64x64 grid of RGBA color values, each component being a u16. ### Signature ```rust pub fn empty_tile() -> Box<[[[u16; 4]; 64]; 64]> ``` ### Parameters None ### Return Value - **Box<[[[u16; 4]; 64]; 64]>** - A boxed 64x64 tile where each cell is an RGBA color with u16 components. ``` -------------------------------- ### InputMapping::new Source: https://docs.rs/hokusai/latest/hokusai/mapping/struct.InputMapping.html Creates a new InputMapping instance with the given BrushInput. ```APIDOC ## InputMapping::new ### Description Creates a new InputMapping instance with the given BrushInput. ### Method new ### Signature pub fn new(input: BrushInput) -> InputMapping ### Parameters - **input** (BrushInput) - Required - The brush input to associate with this mapping. ### Returns - **InputMapping** - A new InputMapping instance. ``` -------------------------------- ### InputValues::new Source: https://docs.rs/hokusai/latest/hokusai/evaluator/struct.InputValues.html?search=u32+-%3E+bool Creates a new InputValues instance with default values. ```APIDOC ## InputValues::new ### Description Creates a new InputValues instance. ### Method `pub const fn new() -> InputValues` ### Parameters None. ### Returns - **InputValues** - A new InputValues instance. ``` -------------------------------- ### TiledSurface::tile_request_start Source: https://docs.rs/hokusai/latest/hokusai/tile_mem/struct.MemSurface.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Requests a mutable reference to the tile at the given coordinates, creating it if necessary. ```APIDOC ## TiledSurface::tile_request_start ### Description Requests a mutable reference to the tile at the given coordinates, creating it if necessary. ### Method `fn tile_request_start(&mut self, tx: i32, ty: i32) -> &mut [[[u16; 4]; 64]; 64]` ### Parameters - **tx** (i32) - Required - The x-coordinate of the tile. - **ty** (i32) - Required - The y-coordinate of the tile. ### Returns - **&mut [[[u16; 4]; 64]; 64]** - A mutable reference to the tile. ``` -------------------------------- ### TiledSurface::begin_atomic Source: https://docs.rs/hokusai/latest/hokusai/tile_mem/struct.MemSurface.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Begins an atomic operation, tracking tile modifications. ```APIDOC ## TiledSurface::begin_atomic ### Description Begins an atomic operation, tracking tile modifications. ### Method `fn begin_atomic(&mut self)` ### Parameters None. ### Returns None. ``` -------------------------------- ### begin_atomic Source: https://docs.rs/hokusai/latest/hokusai/surface/trait.TiledSurface.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Begins an atomic operation, grouping modifications for batch processing. ```APIDOC ## begin_atomic() ### Description Begins an atomic operation, grouping modifications for batch processing. ### Method Provided method of `TiledSurface` trait. ### Parameters None ### Returns None ``` -------------------------------- ### SettingValues::new() Source: https://docs.rs/hokusai/latest/hokusai/evaluator/struct.SettingValues.html?search=u32+-%3E+bool Creates a new SettingValues instance with default values. ```APIDOC ## SettingValues::new() ### Description Creates a new SettingValues instance. ### Method new ### Signature pub fn new() -> SettingValues ### Parameters None ### Returns - **SettingValues** - A new SettingValues instance. ``` -------------------------------- ### from_str Source: https://docs.rs/hokusai/latest/hokusai/myb/index.html?search=std%3A%3Avec Parses a `.myb` JSON document into a `Brush`. ```APIDOC ## from_str ### Description Parses a `.myb` JSON document into a `Brush`. ### Method N/A (Rust function) ### Endpoint N/A ### Parameters #### Input - **input** (string) - Required - The `.myb` JSON document as a string. ### Request Example ```rust let brush = myb::from_str(json_str)?; ``` ### Response #### Success Response - **brush** (Brush) - The parsed brush object. #### Response Example ```rust let brush: Brush = myb::from_str(json_str)?; ``` ``` -------------------------------- ### BrushState::new Source: https://docs.rs/hokusai/latest/hokusai/struct.BrushState.html?search=u32+-%3E+bool Creates a new BrushState with a given seed for the PRNG. This initializes the stroke state. ```APIDOC ## `pub fn new(seed: u32) -> BrushState` ### Description Constructs a new `BrushState` initialized with the given PRNG seed. ### Parameters - `seed` (u32) - Required - Seed value for the random number generator. ### Returns - `BrushState` - A new `BrushState` instance. ``` -------------------------------- ### mix_colors Source: https://docs.rs/hokusai/latest/hokusai/spectral/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Port of libmypaint's mix_colors (helpers.c). Blends two RGBA straight-alpha colours `a` and `b` (the 'current smudge state' and the 'sampled / brush' colour) with weight `fac` for `a`. When `paint_mode > 0` the colour channels mix in spectral space via WGM; when `paint_mode < 1` a linear mix is layered in proportionally so a fractional setting fades smoothly between the two. ```APIDOC ## mix_colors ### Description Port of libmypaint's `mix_colors` (helpers.c). Blends two RGBA straight-alpha colours `a` and `b` (the 'current smudge state' and the 'sampled / brush' colour) with weight `fac` for `a`. When `paint_mode > 0` the colour channels mix in spectral space via WGM; when `paint_mode < 1` a linear mix is layered in proportionally so a fractional setting fades smoothly between the two. ### Method Function ### Signature `mix_colors(a: RGBA, b: RGBA, fac: f32, paint_mode: f32) -> RGBA` ### Parameters - `a` (RGBA) - Required - The 'current smudge state' colour. - `b` (RGBA) - Required - The 'sampled / brush' colour. - `fac` (f32) - Required - The weight for `a`. - `paint_mode` (f32) - Required - When > 0, mix in spectral space via WGM; when < 1, linear mix is layered in proportionally. ### Returns - (RGBA) - The blended colour. ``` -------------------------------- ### pub fn new(seed: u32) -> BrushState Source: https://docs.rs/hokusai/latest/hokusai/struct.BrushState.html?search= Creates a new BrushState with the given seed for the random number generator. ```APIDOC ## pub fn new(seed: u32) -> BrushState ### Description Creates a new `BrushState` instance, initializing the internal random number generator with the provided `seed`. ### Method `new` ### Parameters - **seed** (u32) - Required - The seed value for the random number generator. ### Returns - **BrushState** - A new `BrushState` instance. ``` -------------------------------- ### rgb_to_hsv Source: https://docs.rs/hokusai/latest/hokusai/color/fn.rgb_to_hsv.html?search=std%3A%3Avec Documentation for the rgb_to_hsv function in the hokusai crate. ```APIDOC ## Function rgb_to_hsv ### Description Converts RGB color components to HSV color space. ### Signature ```rust pub fn rgb_to_hsv(r: f32, g: f32, b: f32) -> Hsv ``` ### Parameters - **r** (f32) - Required - Red component (0.0 to 1.0) - **g** (f32) - Required - Green component (0.0 to 1.0) - **b** (f32) - Required - Blue component (0.0 to 1.0) ### Returns - **Hsv** - The HSV representation of the input color. ``` -------------------------------- ### Brush::settings Source: https://docs.rs/hokusai/latest/hokusai/brush/struct.Brush.html?search=std%3A%3Avec Returns a slice of all setting values in the brush. ```APIDOC ## Brush::settings ### Description Returns a slice of all setting values in the brush. ### Method `pub fn settings(&self) -> &[SettingValue]` ### Parameters None. ### Returns - `&[SettingValue]` - A slice of all setting values. ``` -------------------------------- ### pub const fn constant(v: f32) -> SettingValue Source: https://docs.rs/hokusai/latest/hokusai/struct.SettingValue.html Creates a new SettingValue with a constant base value and no input mappings. ```APIDOC ## pub const fn constant(v: f32) -> SettingValue ### Description Creates a new SettingValue with the given constant base value and no input mappings. ### Method Associated function (constructor) ### Signature ```rust pub const fn constant(v: f32) -> SettingValue ``` ### Parameters - **v** (f32) - The constant base value for the setting. ### Returns - **SettingValue** - A new SettingValue instance with `base_value` set to `v`, `inputs` empty, and `unknown_inputs` empty. ### Example ```rust let value = SettingValue::constant(0.5); ``` ``` -------------------------------- ### InputValues Source: https://docs.rs/hokusai/latest/hokusai/evaluator/struct.InputValues.html?search= Documentation for the InputValues struct, including its fields and methods. ```APIDOC ## Struct InputValues ### Description Normalized input values, indexed by `BrushInput`. The stroke engine fills this each event before calling `evaluate`. ### Fields - **values** (`[f32; 19]`) - The normalized input values. ### Implementations #### `pub const fn new() -> InputValues` Creates a new `InputValues` instance. #### `pub fn get(&self, input: BrushInput) -> f32` Gets the value for the given `BrushInput`. #### `pub fn set(&mut self, input: BrushInput, v: f32)` Sets the value for the given `BrushInput`. ### Trait Implementations - `Clone` - `Copy` - `Debug` - `Default` ``` -------------------------------- ### Brush::get Source: https://docs.rs/hokusai/latest/hokusai/brush/struct.Brush.html?search=std%3A%3Avec Returns a reference to the value of a brush setting. ```APIDOC ## Brush::get ### Description Returns a reference to the value of a brush setting. ### Method `pub fn get(&self, s: BrushSetting) -> &SettingValue` ### Parameters - `s` (BrushSetting) - The brush setting to retrieve. ### Returns - `&SettingValue` - A reference to the setting value. ``` -------------------------------- ### fastpow Source: https://docs.rs/hokusai/latest/hokusai/spectral/index.html?search=u32+-%3E+bool Approximates x.powf(p) matching libmypaint's fastpow. Relative error is about 2% per call, but it uses the same arithmetic as libmypaint's mix_colors and get_color_pixels_accumulate, ensuring bit-identical output. ```APIDOC ## fastpow ### Description Approximates `x.powf(p)` matching libmypaint's `fastpow`. Relative error is about 2% per call, but it uses the same arithmetic as libmypaint's `mix_colors` and `get_color_pixels_accumulate`, ensuring bit-identical output. ### Parameters - **x** (float) - The base value. - **p** (float) - The exponent. ### Returns - **float** - Approximation of `x.powf(p)`. ``` -------------------------------- ### evaluate Source: https://docs.rs/hokusai/latest/hokusai/evaluator/index.html?search= Evaluates every setting on a brush at the given normalized inputs. ```APIDOC ## evaluate ### Description Evaluates every setting on `brush` at the given normalized inputs. ### Function Signature `evaluate(brush: &Brush, inputs: &InputValues) -> SettingValues` ### Parameters - **brush** (`&Brush`) - The brush whose settings are to be evaluated. - **inputs** (`&InputValues`) - Normalized input values indexed by `BrushInput`. ### Returns - **SettingValues** - Evaluated setting values indexed by `crate::BrushSetting`. ### Notes - This function is the pure `(base_value + Σ mapping.eval(input_value))` step. - Input normalization (pressure, speed, tilt, etc.) is handled by the stroke engine before calling this function. ``` -------------------------------- ### pub fn rgb_to_hsv(r: f32, g: f32, b: f32) -> Hsv Source: https://docs.rs/hokusai/latest/hokusai/color/fn.rgb_to_hsv.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Converts RGB color values to HSV color space. Takes red, green, and blue components as f32 values and returns an Hsv struct. ```APIDOC ## pub fn rgb_to_hsv(r: f32, g: f32, b: f32) -> Hsv ### Description Converts RGB color values to HSV color space. Takes red, green, and blue components as f32 values and returns an Hsv struct. ### Function Signature ```rust pub fn rgb_to_hsv(r: f32, g: f32, b: f32) -> Hsv ``` ### Parameters - **r** (f32) - Required - Red component of the color. - **g** (f32) - Required - Green component of the color. - **b** (f32) - Required - Blue component of the color. ### Return Value - **Hsv** - The HSV representation of the input color. ``` -------------------------------- ### world_to_tile Source: https://docs.rs/hokusai/latest/hokusai/tile/fn.world_to_tile.html Documentation for the `world_to_tile` function in the `hokusai::tile` module. ```APIDOC ## world_to_tile ### Description Convert a world pixel coordinate to `(tile_x, tile_y, in_tile_x, in_tile_y)`. ### Function Signature ```rust pub fn world_to_tile(x: i32, y: i32) -> (i32, i32, usize, usize) ``` ### Parameters - **x** (i32) - Required - The world pixel x-coordinate. - **y** (i32) - Required - The world pixel y-coordinate. ### Returns - **(i32, i32, usize, usize)** - A tuple containing the tile coordinates `(tile_x, tile_y)` and the in-tile pixel coordinates `(in_tile_x, in_tile_y)`. ``` -------------------------------- ### spectral_to_rgb Source: https://docs.rs/hokusai/latest/hokusai/spectral/fn.spectral_to_rgb.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the `spectral_to_rgb` function in the `hokusai::spectral` module. ```APIDOC ## Function `spectral_to_rgb` ### Description Downsamples 10 spectral channels back to straight-alpha linear sRGB. Negative `T_MATRIX` rows can push the result below `WGM_EPSILON`; the `(tmp - WGM_EPSILON) / offset` step undoes the upsample epsilon and clamps the result into `[0, 1]`. ### Signature ```rust pub fn spectral_to_rgb(spec: &[f32; 10]) -> (f32, f32, f32) ``` ### Parameters - `spec` (`&[f32; 10]`) - Required - The 10 spectral channel values to convert. ### Returns - `(f32, f32, f32)` - The resulting RGB values in straight-alpha linear sRGB. ``` -------------------------------- ### BrushSetting::index Source: https://docs.rs/hokusai/latest/hokusai/enum.BrushSetting.html Returns the index of the brush setting. ```APIDOC ## BrushSetting::index ### Description Returns the index of the brush setting. ### Method pub const fn index(self) -> usize ### Parameters - **self** (BrushSetting) - The brush setting enum value. ### Returns - **usize** - The index. ### Example ```rust let idx = setting.index(); ``` ``` -------------------------------- ### lib.rs: Re-export backends based on cargo features Source: https://docs.rs/hokusai/latest/src/hokusai/lib.rs.html?search= The lib.rs source for the hokusai crate. It re-exports hokusai_core by default and conditionally exposes modules for the myb, tile_mem, and tiny_skia backends based on the corresponding cargo features. ```rust 1//! Hokusai — pure Rust brush engine inspired by libmypaint. 2//! 3//! Umbrella crate that re-exports the active backends based on cargo features. 4 5pub use hokusai_core::*; 6 7#[cfg(feature = "myb-json")] 8pub mod myb { 9 pub use hokusai_brush::*; 10} 11 12#[cfg(feature = "tile-mem")] 13pub mod tile_mem { 14 pub use hokusai_tile_mem::*; 15} 16 #[cfg(feature = "tiny-skia")] 17pub mod tiny_skia { 18 pub use hokusai_tiny_skia::*; 19} ``` -------------------------------- ### Brush::get Source: https://docs.rs/hokusai/latest/hokusai/brush/struct.Brush.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the value of a specified brush setting. ```APIDOC ## Brush::get ### Description Retrieves the value of a specified brush setting. ### Method get ### Signature pub fn get(&self, s: BrushSetting) -> &SettingValue ### Parameters - **s** (BrushSetting) - Required - The brush setting to retrieve. ### Returns - **&SettingValue** - A reference to the setting value. ``` -------------------------------- ### BrushSetting::from_cname Source: https://docs.rs/hokusai/latest/hokusai/enum.BrushSetting.html Attempts to convert a canonical string name to a BrushSetting enum value. ```APIDOC ## BrushSetting::from_cname ### Description Attempts to convert a canonical string name to a BrushSetting enum value. ### Method pub fn from_cname(s: &str) -> Option ### Parameters - **s** (&str) - The canonical string name. ### Returns - **Option** - The corresponding BrushSetting, or None if not found. ### Example ```rust if let Some(setting) = BrushSetting::from_cname("opaque_multiplier") { ... } ``` ``` -------------------------------- ### from_f32 Source: https://docs.rs/hokusai/latest/hokusai/fix15/fn.from_f32.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Documentation for the from_f32 function in the hokusai::fix15 module. ```APIDOC ## from_f32 ### Description Converts a 32-bit floating-point value to a 16-bit unsigned integer representation used by the fix15 fixed-point format. ### Signature ```rust pub fn from_f32(v: f32) -> u16 ``` ### Parameters - **v** (f32) - The floating-point value to convert. ### Returns - **u16** - The fixed-point representation of the input value. ``` -------------------------------- ### pub fn set(&mut self, s: BrushSetting, v: SettingValue) Source: https://docs.rs/hokusai/latest/hokusai/brush/struct.Brush.html?search=u32+-%3E+bool Sets the value of the specified brush setting. ```APIDOC ## pub fn set(&mut self, s: BrushSetting, v: SettingValue) ### Description Sets the value of the specified brush setting. ### Method set ### Parameters - **s** (BrushSetting) - The setting to set. - **v** (SettingValue) - The value to assign. ### Returns None ``` -------------------------------- ### to_string_pretty Source: https://docs.rs/hokusai/latest/hokusai/myb/fn.to_string_pretty.html?search=u32+-%3E+bool Serializes a Brush to libmypaint-style JSON. This function takes a reference to a Brush and returns a Result containing a String on success or an Error on failure. ```APIDOC ## to_string_pretty ### Description Serializes a `Brush` back to libmypaint-style JSON. ### Function Signature ```rust pub fn to_string_pretty(brush: &Brush) -> Result ``` ### Parameters - **brush** (`&Brush`) - Required - A reference to the Brush to serialize. ### Returns - `Result` - On success, returns a JSON string representation of the Brush. On failure, returns an Error. ``` -------------------------------- ### empty_tile() Source: https://docs.rs/hokusai/latest/hokusai/tile/fn.empty_tile.html?search=std%3A%3Avec Creates and returns an empty tile as a boxed three-dimensional array. The tile has dimensions 64 by 64 cells, and each cell holds an array of four u16 values. ```APIDOC ## empty_tile ### Description Creates and returns an empty tile as a boxed three-dimensional array. The tile has dimensions 64 by 64 cells, and each cell holds an array of four u16 values. ### Function Signature ```rust pub fn empty_tile() -> Box<[[[u16; 4]; 64]; 64]> ``` ### Parameters None ### Return Type - **Box<[[[u16; 4]; 64]; 64]>** - A boxed three-dimensional array representing the tile. ### Example Usage ```rust let tile = hokusai::tile::empty_tile(); ``` ``` -------------------------------- ### pub fn evaluate(brush: &Brush, inputs: &InputValues) -> SettingValues Source: https://docs.rs/hokusai/latest/hokusai/evaluator/fn.evaluate.html?search=std%3A%3Avec Evaluates every setting on the provided brush at the given normalized inputs. For each setting, the value is computed as base_value plus the sum of mapping evaluations. Clamping is intentionally not applied. ```APIDOC ## Function: evaluate ### Description Evaluates every setting on the given brush at the provided normalized inputs. For each setting, the value is computed as `base_value + Σ mapping.eval(inputs[mapping.input])`. Clamping is intentionally not performed. ### Signature ```rust pub fn evaluate(brush: &Brush, inputs: &InputValues) -> SettingValues ``` ### Parameters - **brush** (`&Brush`) - The brush whose settings are to be evaluated. - **inputs** (`&InputValues`) - The normalized input values used for evaluation. ### Return Value - **SettingValues** - The evaluated setting values for the brush. ### Notes - Clamping of certain settings (e.g., `opaque` into `[0, 2]`) is intentionally not done here; the stroke engine applies setting-specific post-processing. ``` -------------------------------- ### pub fn fastpow(x: f32, p: f32) -> f32 Source: https://docs.rs/hokusai/latest/hokusai/spectral/fn.fastpow.html?search= Approximates `x.powf(p)` with a relative error of about 2% per call, but uses the same arithmetic as libmypaint to produce bit-identical output in spectral operations. ```APIDOC ## Function: fastpow ### Description Approximates `x.powf(p)` with a relative error of about 2% per call. It uses the same arithmetic as libmypaint's `fastpow`, ensuring bit-identical output in `mix_colors` and `get_color_pixels_accumulate`. ### Signature ```rust pub fn fastpow(x: f32, p: f32) -> f32 ``` ### Parameters - **x** (f32) - The base value. - **p** (f32) - The exponent. ### Return Value - **f32** - The approximate result of `x.powf(p)`. ### Example ```rust let result = hokusai::spectral::fastpow(2.0, 3.0); ``` ### Notes - Relative error is approximately 2% per call. - Produces bit-identical output to libmypaint's `fastpow`. ```