density_mesh_image/
settings.rs

1use serde::{Deserialize, Serialize};
2
3/// Source image preprocessing mode (at the end you get grayscale image representing density map
4/// or typically a height map).
5#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
6pub enum ImageDensitySource {
7    /// Luminosity.
8    Luma,
9    /// Luminosity * Alpha.
10    LumaAlpha,
11    /// Red channel.
12    Red,
13    /// Green channel.
14    Green,
15    /// Blue channel.
16    Blue,
17    /// Alpha channel.
18    Alpha,
19}
20
21impl Default for ImageDensitySource {
22    fn default() -> Self {
23        Self::LumaAlpha
24    }
25}
26
27/// Settings of density image generation.
28#[derive(Debug, Clone, Serialize, Deserialize)]
29pub struct GenerateDensityImageSettings {
30    /// Image density source.
31    #[serde(default)]
32    pub density_source: ImageDensitySource,
33    /// Scale of the image (image is rescaled to: original size / scale).
34    #[serde(default = "GenerateDensityImageSettings::default_scale")]
35    pub scale: usize,
36}
37
38impl Default for GenerateDensityImageSettings {
39    fn default() -> Self {
40        Self {
41            density_source: ImageDensitySource::default(),
42            scale: GenerateDensityImageSettings::default_scale(),
43        }
44    }
45}
46
47impl GenerateDensityImageSettings {
48    fn default_scale() -> usize {
49        1
50    }
51}