bokeh_creator/
settings.rs

1/// Enum that contains the type of filter used for the bokeh.
2#[derive(PartialEq, Eq, Clone, Copy, Debug)]
3#[repr(C)]
4pub enum FilterType {
5    /// Circular bokeh (basically same as curvature set to 1.0)
6    DISC,
7    /// Blade-based bokeh (for replicating camera blades)
8    BLADE,
9}
10
11#[repr(C)]
12#[derive(Clone, Copy, Debug)]
13/// Noise specific settings.
14///
15/// These settings can help to add some artifacts to the kernel,
16/// to replicate more natural-like bokeh's.
17pub struct Noise {
18    /// Size of the noise pattern
19    pub size: f32,
20    /// Intensity of the noise
21    pub intensity: f32,
22    /// Number of octaves for noise generation
23    pub octaves: i32,
24    /// Random seed for noise generation
25    pub seed: i32,
26}
27
28impl Default for Noise {
29    fn default() -> Noise {
30        Noise {
31            size: 0.1,
32            intensity: 0.25,
33            octaves: 7,
34            seed: 0,
35        }
36    }
37}
38
39/// Data object that contains all bokeh settings.
40///
41/// This object is used to specify the settings when rendering.
42#[repr(C)]
43#[derive(Clone, Copy, Debug)]
44pub struct Settings {
45    /// Type of filter to use for the bokeh effect
46    pub filter_type: FilterType,
47    /// Radius of the bokeh effect
48    pub radius: f32,
49    /// Color of the ring in the bokeh effect
50    pub ring_color: f32,
51    /// Color of the inner part of the bokeh effect
52    pub inner_color: f32,
53    /// Size of the ring in the bokeh effect
54    pub ring_size: f32,
55    /// Amount of blur applied to the outer part of the bokeh
56    pub outer_blur: f32,
57    /// Amount of blur applied to the inner part of the bokeh
58    pub inner_blur: f32,
59    /// Number of blades for blade-based bokeh filters
60    pub blades: i32,
61    /// Angle of the bokeh effect
62    pub angle: f32,
63    /// Curvature of the bokeh effect
64    pub curvature: f32,
65    /// Noise settings for the bokeh effect
66    pub noise: Noise,
67    /// Aspect ratio for the bokeh effect
68    pub aspect_ratio: f32,
69}
70
71impl Default for Settings {
72    fn default() -> Settings {
73        Settings {
74            // default is just a natural looking bokeh
75            filter_type: FilterType::DISC,
76            radius: 1.0,
77            ring_color: 1.0,
78            inner_color: 0.4,
79            ring_size: 0.1,
80            outer_blur: 0.1,
81            inner_blur: 0.05,
82            blades: 5,
83            angle: 0.0,
84            curvature: 0.5,
85            noise: Noise::default(),
86            aspect_ratio: 1.0,
87        }
88    }
89}