Struct Color

Source
#[repr(C)]
pub struct Color { pub r: f32, pub g: f32, pub b: f32, pub a: f32, }

Fields§

§r: f32§g: f32§b: f32§a: f32

Implementations§

Source§

impl Color

Source

pub const ALICEBLUE: Color

Source

pub const ANTIQUEWHITE: Color

Source

pub const AQUA: Color

Source

pub const AQUAMARINE: Color

Source

pub const AZURE: Color

Source

pub const BEIGE: Color

Source

pub const BISQUE: Color

Source

pub const BLACK: Color

Source

pub const BLANCHEDALMOND: Color

Source

pub const BLUE: Color

Source

pub const BLUEVIOLET: Color

Source

pub const BROWN: Color

Source

pub const BURLYWOOD: Color

Source

pub const CADETBLUE: Color

Source

pub const CHARTREUSE: Color

Source

pub const CHOCOLATE: Color

Source

pub const CORAL: Color

Source

pub const CORNFLOWERBLUE: Color

Source

pub const CORNSILK: Color

Source

pub const CRIMSON: Color

Source

pub const CYAN: Color

Source

pub const DARKBLUE: Color

Source

pub const DARKCYAN: Color

Source

pub const DARKGOLDENROD: Color

Source

pub const DARKGRAY: Color

Source

pub const DARKGREEN: Color

Source

pub const DARKKHAKI: Color

Source

pub const DARKMAGENTA: Color

Source

pub const DARKOLIVEGREEN: Color

Source

pub const DARKORANGE: Color

Source

pub const DARKORCHID: Color

Source

pub const DARKRED: Color

Source

pub const DARKSALMON: Color

Source

pub const DARKSEAGREEN: Color

Source

pub const DARKSLATEBLUE: Color

Source

pub const DARKSLATEGRAY: Color

Source

pub const DARKTURQUOISE: Color

Source

pub const DARKVIOLET: Color

Source

pub const DEEPPINK: Color

Source

pub const DEEPSKYBLUE: Color

Source

pub const DIMGRAY: Color

Source

pub const DODGERBLUE: Color

Source

pub const FIREBRICK: Color

Source

pub const FLORALWHITE: Color

Source

pub const FORESTGREEN: Color

Source

pub const FUCHSIA: Color

Source

pub const GAINSBORO: Color

Source

pub const GHOSTWHITE: Color

Source

pub const GOLD: Color

Source

pub const GOLDENROD: Color

Source

pub const GRAY: Color

Source

pub const GREEN: Color

Source

pub const GREENYELLOW: Color

Source

pub const HONEYDEW: Color

Source

pub const HOTPINK: Color

Source

pub const INDIANRED: Color

Source

pub const INDIGO: Color

Source

pub const IVORY: Color

Source

pub const KHAKI: Color

Source

pub const LAVENDER: Color

Source

pub const LAVENDERBLUSH: Color

Source

pub const LAWNGREEN: Color

Source

pub const LEMONCHIFFON: Color

Source

pub const LIGHTBLUE: Color

Source

pub const LIGHTCORAL: Color

Source

pub const LIGHTCYAN: Color

Source

pub const LIGHTGOLDENRODYELLOW: Color

Source

pub const LIGHTGRAY: Color

Source

pub const LIGHTGREEN: Color

Source

pub const LIGHTPINK: Color

Source

pub const LIGHTSALMON: Color

Source

pub const LIGHTSEAGREEN: Color

Source

pub const LIGHTSKYBLUE: Color

Source

pub const LIGHTSLATEGRAY: Color

Source

pub const LIGHTSTEELBLUE: Color

Source

pub const LIGHTYELLOW: Color

Source

pub const LIME: Color

Source

pub const LIMEGREEN: Color

Source

pub const LINEN: Color

Source

pub const MAGENTA: Color

Source

pub const MAROON: Color

Source

pub const MEDIUMAQUAMARINE: Color

Source

pub const MEDIUMBLUE: Color

Source

pub const MEDIUMORCHID: Color

Source

pub const MEDIUMPURPLE: Color

Source

pub const MEDIUMSEAGREEN: Color

Source

pub const MEDIUMSLATEBLUE: Color

Source

pub const MEDIUMSPRINGGREEN: Color

Source

pub const MEDIUMTURQUOISE: Color

Source

pub const MEDIUMVIOLETRED: Color

Source

pub const MIDNIGHTBLUE: Color

Source

pub const MINTCREAM: Color

Source

pub const MISTYROSE: Color

Source

pub const MOCCASIN: Color

Source

pub const NAVAJOWHITE: Color

Source

pub const NAVY: Color

Source

pub const OLDLACE: Color

Source

pub const OLIVE: Color

Source

pub const OLIVEDRAB: Color

Source

pub const ORANGE: Color

Source

pub const ORANGERED: Color

Source

pub const ORCHID: Color

Source

pub const PALEGOLDENROD: Color

Source

pub const PALEGREEN: Color

Source

pub const PALETURQUOISE: Color

Source

pub const PALEVIOLETRED: Color

Source

pub const PAPAYAWHIP: Color

Source

pub const PEACHPUFF: Color

Source

pub const PERU: Color

Source

pub const PINK: Color

Source

pub const PLUM: Color

Source

pub const POWDERBLUE: Color

Source

pub const PURPLE: Color

Source

pub const RED: Color

Source

pub const ROSYBROWN: Color

Source

pub const ROYALBLUE: Color

Source

pub const SADDLEBROWN: Color

Source

pub const SALMON: Color

Source

pub const SANDYBROWN: Color

Source

pub const SEAGREEN: Color

Source

pub const SEASHELL: Color

Source

pub const SIENNA: Color

Source

pub const SILVER: Color

Source

pub const SKYBLUE: Color

Source

pub const SLATEBLUE: Color

Source

pub const SLATEGRAY: Color

Source

pub const SNOW: Color

Source

pub const SPRINGGREEN: Color

Source

pub const STEELBLUE: Color

Source

pub const TAN: Color

Source

pub const TEAL: Color

Source

pub const THISTLE: Color

Source

pub const TOMATO: Color

Source

pub const TURQUOISE: Color

Source

pub const VIOLET: Color

Source

pub const WHEAT: Color

Source

pub const WHITE: Color

Source

pub const WHITESMOKE: Color

Source

pub const YELLOW: Color

Source

pub const YELLOWGREEN: Color

Source

pub const TRANSPARENT: Color

Source

pub fn new<T: ToPrimitive>(r: T, g: T, b: T, a: T) -> Self

Creates a new color with the given red, green, blue, and alpha values. Values should be in the range [0.0, 1.0].

Examples found in repository?
examples/pipeline.rs (line 122)
61fn main() {
62    let mut runner = est_render::runner::new().expect("Failed to create runner");
63    let mut window = runner
64        .create_window("Engine Example", Point2::new(800, 600))
65        .build()
66        .expect("Failed to create window");
67
68    let mut gpu = est_render::gpu::new(Some(&mut window))
69        .build()
70        .expect("Failed to create GPU");
71
72    let mut msaa_texture = gpu
73        .create_texture()
74        .set_render_target(Point2::new(800, 600), None)
75        .set_sample_count(SampleCount::SampleCount4)
76        .build()
77        .expect("Failed to create MSAA texture");
78
79    let blank_texture = gpu
80        .create_texture()
81        .set_raw_image(
82            &[255u8; 4],
83            Point2::new(1, 1),
84            TextureFormat::Bgra8Unorm,
85        )
86        .set_usage(TextureUsage::Sampler)
87        .build()
88        .expect("Failed to create blank texture");
89
90    let shader = gpu
91        .create_graphics_shader()
92        .set_vertex_code(VERTEX_DRAWING_SHADER)
93        .set_fragment_code(FRAGMENT_DRAWING_SHADER)
94        .build()
95        .expect("Failed to create graphics shader");
96
97    let compute_shader = gpu
98        .create_compute_shader()
99        .set_source(COMPUTE_NOOP_SHADER)
100        .build()
101        .expect("Failed to create compute shader");
102
103    let pipeline = gpu
104        .create_render_pipeline()
105        .set_shader(Some(&shader))
106        .set_blend(Some(&BlendState::ALPHA_BLEND))
107        .set_attachment_texture(0, 0, Some(&blank_texture))
108        .set_attachment_sampler(0, 1, Some(&TextureSampler::DEFAULT))
109        .build()
110        .expect("Failed to create render pipeline");
111
112    let compute_pipeline = gpu
113        .create_compute_pipeline()
114        .set_shader(Some(&compute_shader))
115        .build()
116        .expect("Failed to create compute pipeline");
117
118    // Triangle vertices
119    let vertices = vec![
120        Vertex {
121            position: Vector3::new(-0.5, -0.5, 0.0),
122            color: Color::new(1.0, 0.0, 0.0, 1.0),
123            texcoord: Vector2::new(0.0, 1.0),
124        },
125        Vertex {
126            position: Vector3::new(0.5, -0.5, 0.0),
127            color: Color::new(0.0, 1.0, 0.0, 1.0),
128            texcoord: Vector2::new(1.0, 1.0),
129        },
130        Vertex {
131            position: Vector3::new(0.0, 0.5, 0.0),
132            color: Color::new(0.0, 0.0, 1.0, 1.0),
133            texcoord: Vector2::new(0.5, 0.0),
134        },
135    ];
136
137    let indexes = vec![0u16, 1u16, 2u16];
138
139    let vbo = gpu
140        .create_buffer()
141        .set_data_vec(vertices)
142        .set_usage(BufferUsage::VERTEX)
143        .build()
144        .expect("Failed to create vertex buffer");
145
146    let ibo = gpu
147        .create_buffer()
148        .set_data_vec(indexes)
149        .set_usage(BufferUsage::INDEX)
150        .build()
151        .expect("Failed to create index buffer");
152
153    while runner.pool_events(PollMode::WaitDraw) {
154        for event in runner.get_events() {
155            match event {
156                Event::KeyboardInput {
157                    window_id,
158                    key,
159                    pressed,
160                } => {
161                    if *window_id == window.id() && key == "Escape" && *pressed {
162                        window.quit();
163                    }
164                }
165                Event::WindowResized { window_id: _, size } => {
166                    if size.x <= 0 || size.y <= 0 {
167                        continue; // Skip invalid sizes
168                    }
169
170                    msaa_texture = gpu
171                        .create_texture()
172                        .set_render_target(Point2::new(size.x as u32, size.y as u32), None)
173                        .set_sample_count(SampleCount::SampleCount4)
174                        .build()
175                        .expect("Failed to resize MSAA texture");
176                }
177                Event::RedrawRequested { window_id: _ } => {
178                    if let Ok(mut cmd) = gpu.begin_command() {
179                        if let Ok(mut cm) = cmd.begin_computepass() {
180                            cm.set_pipeline(Some(&compute_pipeline));
181                            cm.dispatch(1, 1, 1);
182                        }
183
184                        if let Ok(mut rp) = cmd.begin_renderpass() {
185                            rp.set_clear_color(Color::BLACK);
186                            rp.push_msaa_texture(&msaa_texture);
187
188                            rp.set_pipeline(Some(&pipeline));
189                            rp.set_gpu_buffer(Some(&vbo), Some(&ibo));
190                            rp.draw_indexed(0..3, 0, 1);
191                        }
192                    }
193
194                    window.request_redraw();
195                }
196                _ => {}
197            }
198        }
199    }
200}
Source

pub const fn new_const(r: f32, g: f32, b: f32, a: f32) -> Self

Source

pub fn from_rgb<T: ToPrimitive>(r: T, g: T, b: T, a: T) -> Self

Creates a new color from RGBA values in the range [0, 255].

Source

pub fn into_rgb(self) -> [u8; 4]

Converts the color to an array of RGBA values in the range [0, 255].

Source

pub fn into_srgb(self) -> Self

Converts the color into sRGB color space.

Source

pub fn into_linear(self) -> Self

Converts the color from sRGB to linear RGB color space.

Trait Implementations§

Source§

impl Add<Color> for f32

Source§

type Output = Color

The resulting type after applying the + operator.
Source§

fn add(self, other: Color) -> Color

Performs the + operation. Read more
Source§

impl Add<f32> for Color

Source§

type Output = Color

The resulting type after applying the + operator.
Source§

fn add(self, other: f32) -> Self

Performs the + operation. Read more
Source§

impl Add for Color

Source§

type Output = Color

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
Source§

impl AddAssign<Color> for f32

Source§

fn add_assign(&mut self, other: Color)

Performs the += operation. Read more
Source§

impl AddAssign<f32> for Color

Source§

fn add_assign(&mut self, other: f32)

Performs the += operation. Read more
Source§

impl AddAssign for Color

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Color

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Color

Source§

fn default() -> Color

Returns the “default value” for a type. Read more
Source§

impl Div<Color> for f32

Source§

type Output = Color

The resulting type after applying the / operator.
Source§

fn div(self, other: Color) -> Color

Performs the / operation. Read more
Source§

impl Div<f32> for Color

Source§

type Output = Color

The resulting type after applying the / operator.
Source§

fn div(self, other: f32) -> Self

Performs the / operation. Read more
Source§

impl Div for Color

Source§

type Output = Color

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
Source§

impl DivAssign<Color> for f32

Source§

fn div_assign(&mut self, other: Color)

Performs the /= operation. Read more
Source§

impl DivAssign<f32> for Color

Source§

fn div_assign(&mut self, other: f32)

Performs the /= operation. Read more
Source§

impl DivAssign for Color

Source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
Source§

impl From<[f32; 4]> for Color

Source§

fn from(data: [f32; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 4]> for Color

Source§

fn from(data: [u8; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<(f32, f32, f32, f32)> for Color

Source§

fn from((r, g, b, a): (f32, f32, f32, f32)) -> Self

Converts to this type from the input type.
Source§

impl Mul<Color> for f32

Source§

type Output = Color

The resulting type after applying the * operator.
Source§

fn mul(self, other: Color) -> Color

Performs the * operation. Read more
Source§

impl Mul<f32> for Color

Source§

type Output = Color

The resulting type after applying the * operator.
Source§

fn mul(self, other: f32) -> Self

Performs the * operation. Read more
Source§

impl Mul for Color

Source§

type Output = Color

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<Color> for f32

Source§

fn mul_assign(&mut self, other: Color)

Performs the *= operation. Read more
Source§

impl MulAssign<f32> for Color

Source§

fn mul_assign(&mut self, other: f32)

Performs the *= operation. Read more
Source§

impl MulAssign for Color

Source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
Source§

impl PartialEq for Color

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub<Color> for f32

Source§

type Output = Color

The resulting type after applying the - operator.
Source§

fn sub(self, other: Color) -> Color

Performs the - operation. Read more
Source§

impl Sub<f32> for Color

Source§

type Output = Color

The resulting type after applying the - operator.
Source§

fn sub(self, other: f32) -> Self

Performs the - operation. Read more
Source§

impl Sub for Color

Source§

type Output = Color

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
Source§

impl SubAssign<Color> for f32

Source§

fn sub_assign(&mut self, other: Color)

Performs the -= operation. Read more
Source§

impl SubAssign<f32> for Color

Source§

fn sub_assign(&mut self, other: f32)

Performs the -= operation. Read more
Source§

impl SubAssign for Color

Source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
Source§

impl Zeroable for Color

Source§

fn zeroed() -> Self

Source§

impl Copy for Color

Source§

impl Eq for Color

Source§

impl Pod for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,