Struct glm_color::hsv::Hsv [] [src]

pub struct Hsv { /* fields omitted */ }

Methods

impl Hsv
[src]

Constructs an Hsv value from given hue, saturation and brightness values.

Parameter hue is clampped to the interval [0, 2π), and saturation and brightness are clampped to interval [0, 1].

Example

use glm_color::*;

let red = Hsv::new(7., 2., 1.);
assert_eq!(red.hue(), 0.);
assert_eq!(red.saturation(), 1.);

Constructs an Hsv value by randomly choosing values for each of the three HSV channels using the thread local RNG.

Note

As the Rgb::rand() function, this function is not good for generating the whole color palette.

Constructs an Hsv from hue value degree, which is the angle on the color wheel.

Both saturation and brightness of the returned value are set to 1.0.

Example

use glm::*;
use glm_color::*;

let y = Hsv::from_hue(radians(60.));
assert_eq!(y.hue(), glm::radians(60.));
assert_eq!(y.saturation(), 1.);
assert_eq!(y.brightness(), 1.);

Returns the hue of self.

Returns the saturation of self.

Returns the brightness of self.

Changes self's hue value to h.

The parameter h is clampped to the range [0, 2π).

Returns a new Hsv value with given hue value h, and saturation and brightness values from self.

Changes self's saturation value to s.

The parameter 's' is clampped to the rnage [0, 1];

Returns a new Hsv value with given saturation value s, and hue and brightness values from self.

Changes self's brightness value to b.

The parameter 'b' will be clampped to the rnage [0, 1];

Returns a new Hsv value with given brightness value b, and hue and saturation values from self.

Re-interpret the reference of Hsv to Vec3.

Returns the complementary color of self.

Example

use glm::*;
use glm::ext::pi;
use glm_color::*;

let red = Hsv::from_hue(0.);
let green = Hsv::from_hue(pi());
assert_eq!(red.complement(), green);

Returns a pair of colors that are splited from the complementary color of self,

The 2 colors have same distances to the complementary color on the color wheel. In our implementation, this distance is fixed to 30 degrees.

Returns 2 pairs of complementary colors. The first colors of both pairs are the result of split_complement of self.

Returns other 2 colors of triad colors that includes self.

Example

use glm::*;
use glm_color::*;

let red = Hsv::from_rgb(RED);
let (green, blue) = red.triad();

assert!(is_close_to(&green.hue(), &radians(120.), 0.000001));
assert!(is_close_to(&blue.hue(), &radians(240.), 0.000001));

Returns n colors that are analogous to the receiver.

Returns n colors distributed on the color wheel evenly.

The returned colors have full saturation and lightness. Red is the first color in the vector.

If n is 0, an empty vector is returned.

Example

use glm_color::*;

let cs0 = Hsv::color_wheel(0);
assert_eq!(cs0.len(), 0);
let cs1 = Hsv::color_wheel(1);
assert_eq!(cs1[0], Hsv::from_hue(0.));
let csn = Hsv::color_wheel(3);
assert_eq!(csn.len(), 3);

Produces a color by adding white to the receiver.

For Hsv color model, adding white means increasing the lightness.

Parameter amt specifies absolute lightness to be added.

Example

use glm_color::*;

let red = Hsv::new(1., 0.5, 0.2);
assert_eq!(red.tint(1.), Hsv::new(1., 0.5, 1.));

Produces a vector of n colors whose brightness increase monotonically and evenly.

If n is 0, returns an empty vector.

Other wise, the receiver is the first element of the vector and a color with full brightness is the last.

Example

use glm_color::*;

let red: Hsv = from_rgb(RED);
let clrs = red.tints(3);

Produces a color by adding black to the receiver.

Producesn colors whose brightness decrease monotonically and evenly.

Produces a color by adding gray to the receiver.

Produces n colors whose saturation decrease monotonically and evenly.

Trait Implementations

impl Copy for Hsv
[src]

impl Clone for Hsv
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Hsv
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Debug for Hsv
[src]

Formats the value using the given formatter.

impl Rand for Hsv
[src]

Generates a random instance of this type using the specified source of randomness. Read more

impl Eq for Hsv
[src]

impl ApproxEq for Hsv
[src]

Returns true if the difference between x and y is less than max_diff. Read more

Returns true if the difference between x and y is less than machine epsilon. Read more

impl ColorSpace for Hsv
[src]

Constructs from color value rgb in RGB color space.

Converts self to a color value in RGB color space.