vtk_rs/
vtkCommonColor.rs

1/// stores a list of colors.
2///
3///
4///
5/// The vtkColorSeries stores palettes of colors. There are several default
6/// palettes (or schemes) available and functions to control several aspects
7/// of what colors are returned. In essence a color scheme is set and then
8/// the number of colors and individual color values may be requested.
9///
10/// For a web page showcasing the default palettes, see:
11/// <a
12/// href="https://htmlpreview.github.io/?https://github.com/Kitware/vtk-examples/blob/gh-pages/VTKColorSeriesPatches.html">VTKColorSeriesPatches</a>;
13/// <a
14/// href="https://kitware.github.io/vtk-examples/site/Python/Visualization/ColorSeriesPatches/">ColorSeriesPatches</a>
15/// was used to generate this table.
16///
17/// It is also possible to add schemes beyond the default palettes.
18/// Whenever \a SetColorScheme is called with a string for which no palette
19/// already exists, a new, empty palette is created.
20/// You may then use \a SetNumberOfColors and \a SetColor to populate the
21/// palette.
22/// You may not extend default palettes by calling functions that alter
23/// a scheme; if called while a predefined palette is in use, they
24/// will create a new non-default scheme and populate it with the current
25/// palette before continuing.
26///
27/// The "Brewer" palettes are courtesy of
28/// Cynthia A. Brewer (Dept. of Geography, Pennsylvania State University)
29/// and under the Apache License. See the source code for details.
30#[allow(non_camel_case_types)]
31pub struct vtkColorSeries(*mut core::ffi::c_void);
32impl vtkColorSeries {
33    /// Creates a new [vtkColorSeries] wrapped inside `vtkNew`
34    #[doc(alias = "vtkColorSeries")]
35    pub fn new() -> Self {
36        unsafe extern "C" {
37            fn vtkColorSeries_new() -> *mut core::ffi::c_void;
38        }
39        Self(unsafe { &mut *vtkColorSeries_new() })
40    }
41    #[cfg(test)]
42    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
43        unsafe extern "C" {
44            fn vtkColorSeries_get_ptr(
45                sself: *mut core::ffi::c_void,
46            ) -> *mut core::ffi::c_void;
47        }
48        unsafe { vtkColorSeries_get_ptr(self.0) }
49    }
50}
51impl std::default::Default for vtkColorSeries {
52    fn default() -> Self {
53        Self::new()
54    }
55}
56impl Drop for vtkColorSeries {
57    fn drop(&mut self) {
58        unsafe extern "C" {
59            fn vtkColorSeries_destructor(sself: *mut core::ffi::c_void);
60        }
61        unsafe { vtkColorSeries_destructor(self.0) }
62        self.0 = core::ptr::null_mut();
63    }
64}
65#[test]
66fn test_vtkColorSeries_create_drop() {
67    let obj = vtkColorSeries::new();
68    let ptr = obj.0;
69    assert!(!ptr.is_null());
70    assert!(unsafe { !obj._get_ptr().is_null() });
71    drop(obj);
72    let new_obj = vtkColorSeries(ptr);
73    assert!(unsafe { new_obj._get_ptr().is_null() });
74}
75/// A class holding colors and their names.
76///
77///
78/// For a web page showcasing VTK Named Colors and their RGB values, see:
79/// <a
80/// href="https://htmlpreview.github.io/?https://github.com/Kitware/vtk-examples/blob/gh-pages/VTKNamedColorPatches.html">VTKNamedColorPatches</a>;
81/// <a
82/// href="https://kitware.github.io/vtk-examples/site/Python/Visualization/NamedColorPatches/">NamedColorPatches</a>
83/// was used to generate this table.
84///
85/// Color names are case insensitive and are stored as lower-case names
86/// along with a 4-element array whose elements are red, green, blue and alpha,
87/// in that order, corresponding to the RGBA value of the color.
88///
89/// It is assumed that if the RGBA values are unsigned char then each element
90/// lies in the range 0...255 and if the RGBA values are double then each
91/// element lies in the range 0...1.
92///
93/// The colors and names are those in <a href="https://en.wikipedia.org/wiki/Web_colors">Web
94/// colors</a> that are derived from the CSS3 specification: <a
95/// href="https://www.w3.org/TR/css-color-3/">CSS Color Module Level 3</a> In this table
96/// common synonyms such as cyan/aqua and magenta/fuchsia are also included.
97///
98/// Also included in this class are names and colors taken from
99/// <em>Wrapping/Python/vtkmodules/util/colors.py</em> that were originally taken from
100/// <em>Wrapping/Tcl/vtktesting/colors.tcl</em> (no longer in the VTK source files - deleted
101/// 06-Dec-2017).
102///
103/// Web colors and names in <a href="https://en.wikipedia.org/wiki/Web_colors">Web colors</a> take
104/// precedence over those in <em>colors.py</em>. One consequence of this
105/// is that while <em>colors.py</em> specifies green as equivalent to
106/// (0,255,0), the web color standard defines it as (0,128,0).
107///
108/// The \a SetColor methods will overwrite existing colors if the name of the
109/// color being set matches an existing color. Note that ColorExists() can be
110/// used to test for existence of the color being set.
111///
112/// In the case of the \a GetColor methods returning doubles, alternative versions,
113/// identified by the letters RGB in the names, are provided.
114/// These get functions return just the red, green and blue components of
115/// a color.
116///
117/// The class also provides methods for defining a color through an HTML color
118/// string. The following formats are supported:
119///
120/// - \#RGB                 (3-digit hexadecimal number, where #4F2 is a shortcut for #44FF22)
121/// - \#RRGGBB              (6-digit hexadecimal number)
122/// - rgb(r, g, b)          (where r, g, b are in 0..255 or percentage values)
123/// - rgba(r, g, b, a)      (where r, g, b, are in 0..255 or percentage values, a is in 0.0..1.0)
124/// - a CSS3 color name     (e.g. "steelblue")
125#[allow(non_camel_case_types)]
126pub struct vtkNamedColors(*mut core::ffi::c_void);
127impl vtkNamedColors {
128    /// Creates a new [vtkNamedColors] wrapped inside `vtkNew`
129    #[doc(alias = "vtkNamedColors")]
130    pub fn new() -> Self {
131        unsafe extern "C" {
132            fn vtkNamedColors_new() -> *mut core::ffi::c_void;
133        }
134        Self(unsafe { &mut *vtkNamedColors_new() })
135    }
136    #[cfg(test)]
137    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
138        unsafe extern "C" {
139            fn vtkNamedColors_get_ptr(
140                sself: *mut core::ffi::c_void,
141            ) -> *mut core::ffi::c_void;
142        }
143        unsafe { vtkNamedColors_get_ptr(self.0) }
144    }
145}
146impl std::default::Default for vtkNamedColors {
147    fn default() -> Self {
148        Self::new()
149    }
150}
151impl Drop for vtkNamedColors {
152    fn drop(&mut self) {
153        unsafe extern "C" {
154            fn vtkNamedColors_destructor(sself: *mut core::ffi::c_void);
155        }
156        unsafe { vtkNamedColors_destructor(self.0) }
157        self.0 = core::ptr::null_mut();
158    }
159}
160#[test]
161fn test_vtkNamedColors_create_drop() {
162    let obj = vtkNamedColors::new();
163    let ptr = obj.0;
164    assert!(!ptr.is_null());
165    assert!(unsafe { !obj._get_ptr().is_null() });
166    drop(obj);
167    let new_obj = vtkNamedColors(ptr);
168    assert!(unsafe { new_obj._get_ptr().is_null() });
169}