#[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: f32Implementations§
Source§impl Color
impl Color
pub const TRANSPARENT: Color
pub const ALICE_BLUE: Color
pub const ANTIQUE_WHITE: Color
pub const AQUA: Color
pub const AQUAMARINE: Color
pub const AZURE: Color
pub const BEIGE: Color
pub const BISQUE: Color
pub const BLACK: Color
pub const BLANCHED_ALMOND: Color
pub const BLUE: Color
pub const BLUE_VIOLET: Color
pub const BROWN: Color
pub const BURLY_WOOD: Color
pub const CADET_BLUE: Color
pub const CHARTREUSE: Color
pub const CHOCOLATE: Color
pub const CORAL: Color
pub const CORNFLOWER_BLUE: Color
pub const CORNSILK: Color
pub const CRIMSON: Color
pub const CYAN: Color
pub const DARK_BLUE: Color
pub const DARK_CYAN: Color
pub const DARK_GOLDEN_ROD: Color
pub const DARK_GRAY: Color
pub const DARK_GREEN: Color
pub const DARK_GREY: Color
pub const DARK_KHAKI: Color
pub const DARK_MAGENTA: Color
pub const DARK_OLIVE_GREEN: Color
pub const DARK_ORANGE: Color
pub const DARK_ORCHID: Color
pub const DARK_RED: Color
pub const DARK_SALMON: Color
pub const DARK_SEA_GREEN: Color
pub const DARK_SLATE_BLUE: Color
pub const DARK_SLATE_GRAY: Color
pub const DARK_SLATE_GREY: Color
pub const DARK_TURQUOISE: Color
pub const DARK_VIOLET: Color
pub const DEEP_PINK: Color
pub const DEEP_SKY_BLUE: Color
pub const DIM_GRAY: Color
pub const DIM_GREY: Color
pub const DODGER_BLUE: Color
pub const FIRE_BRICK: Color
pub const FLORAL_WHITE: Color
pub const FOREST_GREEN: Color
pub const FUCHSIA: Color
pub const GAINSBORO: Color
pub const GHOST_WHITE: Color
pub const GOLD: Color
pub const GOLDEN_ROD: Color
pub const GRAY: Color
pub const GREEN: Color
pub const GREEN_YELLOW: Color
pub const GREY: Color
pub const HONEY_DEW: Color
pub const HOT_PINK: Color
pub const INDIAN_RED: Color
pub const INDIGO: Color
pub const IVORY: Color
pub const KHAKI: Color
pub const LAVENDER: Color
pub const LAVENDER_BLUSH: Color
pub const LAWN_GREEN: Color
pub const LEMON_CHIFFON: Color
pub const LIGHT_BLUE: Color
pub const LIGHT_CORAL: Color
pub const LIGHT_CYAN: Color
pub const LIGHT_GOLDEN_ROD_YELLOW: Color
pub const LIGHT_GRAY: Color
pub const LIGHT_GREEN: Color
pub const LIGHT_GREY: Color
pub const LIGHT_PINK: Color
pub const LIGHT_SALMON: Color
pub const LIGHT_SEA_GREEN: Color
pub const LIGHT_SKY_BLUE: Color
pub const LIGHT_SLATE_GRAY: Color
pub const LIGHT_SLATE_GREY: Color
pub const LIGHT_STEEL_BLUE: Color
pub const LIGHT_YELLOW: Color
pub const LIME: Color
pub const LIME_GREEN: Color
pub const LINEN: Color
pub const MAGENTA: Color
pub const MAROON: Color
pub const MEDIUM_AQUA_MARINE: Color
pub const MEDIUM_BLUE: Color
pub const MEDIUM_ORCHID: Color
pub const MEDIUM_PURPLE: Color
pub const MEDIUM_SEA_GREEN: Color
pub const MEDIUM_SLATE_BLUE: Color
pub const MEDIUM_SPRING_GREEN: Color
pub const MEDIUM_TURQUOISE: Color
pub const MEDIUM_VIOLET_RED: Color
pub const MIDNIGHT_BLUE: Color
pub const MINT_CREAM: Color
pub const MISTY_ROSE: Color
pub const MOCCASIN: Color
pub const NAVAJO_WHITE: Color
pub const NAVY: Color
pub const OLD_LACE: Color
pub const OLIVE: Color
pub const OLIVE_DRAB: Color
pub const ORANGE: Color
pub const ORANGE_RED: Color
pub const ORCHID: Color
pub const PALE_GOLDEN_ROD: Color
pub const PALE_GREEN: Color
pub const PALE_TURQUOISE: Color
pub const PALE_VIOLET_RED: Color
pub const PAPAYA_WHIP: Color
pub const PEACH_PUFF: Color
pub const PERU: Color
pub const PINK: Color
pub const PLUM: Color
pub const POWDER_BLUE: Color
pub const PURPLE: Color
pub const REBECCA_PURPLE: Color
pub const RED: Color
pub const ROSY_BROWN: Color
pub const ROYAL_BLUE: Color
pub const SADDLE_BROWN: Color
pub const SALMON: Color
pub const SANDY_BROWN: Color
pub const SEA_GREEN: Color
pub const SEA_SHELL: Color
pub const SIENNA: Color
pub const SILVER: Color
pub const SKY_BLUE: Color
pub const SLATE_BLUE: Color
pub const SLATE_GRAY: Color
pub const SLATE_GREY: Color
pub const SNOW: Color
pub const SPRING_GREEN: Color
pub const STEEL_BLUE: Color
pub const TAN: Color
pub const TEAL: Color
pub const THISTLE: Color
pub const TOMATO: Color
pub const TURQUOISE: Color
pub const VIOLET: Color
pub const WHEAT: Color
pub const WHITE: Color
pub const WHITE_SMOKE: Color
pub const YELLOW: Color
pub const YELLOW_GREEN: Color
pub const AMBER_50: Color
pub const AMBER_100: Color
pub const AMBER_200: Color
pub const AMBER_300: Color
pub const AMBER_400: Color
pub const AMBER_500: Color
pub const AMBER_600: Color
pub const AMBER_700: Color
pub const AMBER_800: Color
pub const AMBER_900: Color
pub const AMBER_950: Color
pub const BLUE_50: Color
pub const BLUE_100: Color
pub const BLUE_200: Color
pub const BLUE_300: Color
pub const BLUE_400: Color
pub const BLUE_500: Color
pub const BLUE_600: Color
pub const BLUE_700: Color
pub const BLUE_800: Color
pub const BLUE_900: Color
pub const BLUE_950: Color
pub const CYAN_50: Color
pub const CYAN_100: Color
pub const CYAN_200: Color
pub const CYAN_300: Color
pub const CYAN_400: Color
pub const CYAN_500: Color
pub const CYAN_600: Color
pub const CYAN_700: Color
pub const CYAN_800: Color
pub const CYAN_900: Color
pub const CYAN_950: Color
pub const EMERALD_50: Color
pub const EMERALD_100: Color
pub const EMERALD_200: Color
pub const EMERALD_300: Color
pub const EMERALD_400: Color
pub const EMERALD_500: Color
pub const EMERALD_600: Color
pub const EMERALD_700: Color
pub const EMERALD_800: Color
pub const EMERALD_900: Color
pub const EMERALD_950: Color
pub const FUCHSIA_50: Color
pub const FUCHSIA_100: Color
pub const FUCHSIA_200: Color
pub const FUCHSIA_300: Color
pub const FUCHSIA_400: Color
pub const FUCHSIA_500: Color
pub const FUCHSIA_600: Color
pub const FUCHSIA_700: Color
pub const FUCHSIA_800: Color
pub const FUCHSIA_900: Color
pub const FUCHSIA_950: Color
pub const GRAY_50: Color
pub const GRAY_100: Color
pub const GRAY_200: Color
pub const GRAY_300: Color
pub const GRAY_400: Color
pub const GRAY_500: Color
pub const GRAY_600: Color
pub const GRAY_700: Color
pub const GRAY_800: Color
pub const GRAY_900: Color
pub const GRAY_950: Color
pub const GREEN_50: Color
pub const GREEN_100: Color
pub const GREEN_200: Color
pub const GREEN_300: Color
pub const GREEN_400: Color
pub const GREEN_500: Color
pub const GREEN_600: Color
pub const GREEN_700: Color
pub const GREEN_800: Color
pub const GREEN_900: Color
pub const GREEN_950: Color
pub const INDIGO_50: Color
pub const INDIGO_100: Color
pub const INDIGO_200: Color
pub const INDIGO_300: Color
pub const INDIGO_400: Color
pub const INDIGO_500: Color
pub const INDIGO_600: Color
pub const INDIGO_700: Color
pub const INDIGO_800: Color
pub const INDIGO_900: Color
pub const INDIGO_950: Color
pub const LIME_50: Color
pub const LIME_100: Color
pub const LIME_200: Color
pub const LIME_300: Color
pub const LIME_400: Color
pub const LIME_500: Color
pub const LIME_600: Color
pub const LIME_700: Color
pub const LIME_800: Color
pub const LIME_900: Color
pub const LIME_950: Color
pub const NEUTRAL_50: Color
pub const NEUTRAL_100: Color
pub const NEUTRAL_200: Color
pub const NEUTRAL_300: Color
pub const NEUTRAL_400: Color
pub const NEUTRAL_500: Color
pub const NEUTRAL_600: Color
pub const NEUTRAL_700: Color
pub const NEUTRAL_800: Color
pub const NEUTRAL_900: Color
pub const NEUTRAL_950: Color
pub const ORANGE_50: Color
pub const ORANGE_100: Color
pub const ORANGE_200: Color
pub const ORANGE_300: Color
pub const ORANGE_400: Color
pub const ORANGE_500: Color
pub const ORANGE_600: Color
pub const ORANGE_700: Color
pub const ORANGE_800: Color
pub const ORANGE_900: Color
pub const ORANGE_950: Color
pub const PINK_50: Color
pub const PINK_100: Color
pub const PINK_200: Color
pub const PINK_300: Color
pub const PINK_400: Color
pub const PINK_500: Color
pub const PINK_600: Color
pub const PINK_700: Color
pub const PINK_800: Color
pub const PINK_900: Color
pub const PINK_950: Color
pub const PURPLE_50: Color
pub const PURPLE_100: Color
pub const PURPLE_200: Color
pub const PURPLE_300: Color
pub const PURPLE_400: Color
pub const PURPLE_500: Color
pub const PURPLE_600: Color
pub const PURPLE_700: Color
pub const PURPLE_800: Color
pub const PURPLE_900: Color
pub const PURPLE_950: Color
pub const RED_50: Color
pub const RED_100: Color
pub const RED_200: Color
pub const RED_300: Color
pub const RED_400: Color
pub const RED_500: Color
pub const RED_600: Color
pub const RED_700: Color
pub const RED_800: Color
pub const RED_900: Color
pub const RED_950: Color
pub const ROSE_50: Color
pub const ROSE_100: Color
pub const ROSE_200: Color
pub const ROSE_300: Color
pub const ROSE_400: Color
pub const ROSE_500: Color
pub const ROSE_600: Color
pub const ROSE_700: Color
pub const ROSE_800: Color
pub const ROSE_900: Color
pub const ROSE_950: Color
pub const SKY_50: Color
pub const SKY_100: Color
pub const SKY_200: Color
pub const SKY_300: Color
pub const SKY_400: Color
pub const SKY_500: Color
pub const SKY_600: Color
pub const SKY_700: Color
pub const SKY_800: Color
pub const SKY_900: Color
pub const SKY_950: Color
pub const SLATE_50: Color
pub const SLATE_100: Color
pub const SLATE_200: Color
pub const SLATE_300: Color
pub const SLATE_400: Color
pub const SLATE_500: Color
pub const SLATE_600: Color
pub const SLATE_700: Color
pub const SLATE_800: Color
pub const SLATE_900: Color
pub const SLATE_950: Color
pub const STONE_50: Color
pub const STONE_100: Color
pub const STONE_200: Color
pub const STONE_300: Color
pub const STONE_400: Color
pub const STONE_500: Color
pub const STONE_600: Color
pub const STONE_700: Color
pub const STONE_800: Color
pub const STONE_900: Color
pub const STONE_950: Color
pub const TEAL_50: Color
pub const TEAL_100: Color
pub const TEAL_200: Color
pub const TEAL_300: Color
pub const TEAL_400: Color
pub const TEAL_500: Color
pub const TEAL_600: Color
pub const TEAL_700: Color
pub const TEAL_800: Color
pub const TEAL_900: Color
pub const TEAL_950: Color
pub const VIOLET_50: Color
pub const VIOLET_100: Color
pub const VIOLET_200: Color
pub const VIOLET_300: Color
pub const VIOLET_400: Color
pub const VIOLET_500: Color
pub const VIOLET_600: Color
pub const VIOLET_700: Color
pub const VIOLET_800: Color
pub const VIOLET_900: Color
pub const VIOLET_950: Color
pub const YELLOW_50: Color
pub const YELLOW_100: Color
pub const YELLOW_200: Color
pub const YELLOW_300: Color
pub const YELLOW_400: Color
pub const YELLOW_500: Color
pub const YELLOW_600: Color
pub const YELLOW_700: Color
pub const YELLOW_800: Color
pub const YELLOW_900: Color
pub const YELLOW_950: Color
pub const ZINC_50: Color
pub const ZINC_100: Color
pub const ZINC_200: Color
pub const ZINC_300: Color
pub const ZINC_400: Color
pub const ZINC_500: Color
pub const ZINC_600: Color
pub const ZINC_700: Color
pub const ZINC_800: Color
pub const ZINC_900: Color
pub const ZINC_950: Color
pub const ALL: [Color; 242]
Source§impl Color
impl Color
pub const fn new(r: f32, g: f32, b: f32) -> Color
pub const fn from_rgb(r: f32, g: f32, b: f32) -> Color
pub const fn from_rgb_u8(r: u8, g: u8, b: u8) -> Color
pub fn from_gpu(v: [f32; 4]) -> Color
pub fn to_u8(&self) -> (u8, u8, u8)
pub fn from_string(s: impl AsRef<str>) -> Option<Color>
pub const fn to_rgba_u8(&self) -> (u8, u8, u8, u8)
pub const fn from_rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Color
pub const fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Color
pub const fn for_gpu(&self) -> [f32; 4]
pub const fn to_vec4(&self) -> Vec4
pub fn from_vec4(v: Vec4) -> Color
pub fn splat(v: f32) -> Color
pub fn grey(v: f32) -> Color
Sourcepub const fn with_alpha(self, a: f32) -> Color
pub const fn with_alpha(self, a: f32) -> Color
Examples found in repository?
examples/space_game.rs (line 216)
209 fn emit_movement_particles(&self) {
210 let batch = ParticleOneshot::builder()
211 .shape(&Circle::new(
212 Vec2::ZERO,
213 Vec2::splat(LINE_THICKNESS * 1.5),
214 FG,
215 ))
216 .end_color(RED.with_alpha(0.0))
217 .speed(self.speed * 0.8)
218 .direction(-self.rotation)
219 .direction_randomness(0.2)
220 .speed_randomness(self.speed * 0.5)
221 .lifetime(0.8)
222 .lifetime_randomness(0.4)
223 .quantity((self.speed * 5.0).max(1.0) as usize)
224 .position_randomness(Vec2::splat(PLAYER_SIZE * 0.3))
225 .build();
226 get_particles().spawn_oneshot(
227 &batch,
228 self.pos + vec2(0.0, -PLAYER_SIZE * 0.3).rotated_around_origin(-self.rotation),
229 );
230 }
231
232 fn update_input(&mut self) {
233 if action_held(UP) {
234 self.speed += PLAYER_ACCEL;
235 self.emit_movement_particles();
236
237 if once_per_n_seconds(0.1) {
238 play_sound_ex(get_sounds().engine).volume(0.1).start();
239 }
240 }
241
242 if action_held(DOWN) {
243 self.speed -= PLAYER_ACCEL;
244 }
245
246 if action_held(RIGHT) {
247 self.angvel -= PLAYER_TURN_SPEED;
248 }
249
250 if action_held(LEFT) {
251 self.angvel += PLAYER_TURN_SPEED;
252 }
253
254 if action_pressed(SHOOT) {
255 play_sound(get_sounds().shoot);
256 let tip = self.pos + vec2(0.0, PLAYER_SIZE).rotated_around_origin(-self.rotation);
257 self.bullets
258 .push(Bullet::new(tip, self.rotation, self.vel()));
259 }
260 }
261
262 fn update_velocities(&mut self) {
263 self.pos += self.vel();
264 self.rotation += self.angvel;
265
266 self.speed *= PLAYER_LIN_DECEL;
267 self.angvel *= PLAYER_ANG_DECEL;
268
269 if self.speed.abs() < 0.1 {
270 self.speed = 0.0;
271 }
272
273 if self.angvel.abs() < 0.1 {
274 self.angvel = 0.0;
275 }
276 }
277
278 fn draw(&self) {
279 for bullet in &self.bullets {
280 bullet.draw();
281 }
282
283 let c = self.pos;
284 let tip = c + vec2(0.0, PLAYER_SIZE);
285 let elbow = c + vec2(0.0, -PLAYER_SIZE * 0.5);
286 let left_wing = c + vec2(-PLAYER_SIZE, -PLAYER_SIZE);
287 let right_wing = c + vec2(PLAYER_SIZE, -PLAYER_SIZE);
288
289 let now = time();
290 let time = (now - self.last_hit) * 10.0;
291 let blink_on = time as i32 % 2 == 0;
292 let currently_invincible = now - self.last_hit < PLAYER_INVINCIBILITY_DURATION;
293 let color = if currently_invincible && blink_on {
294 FG.with_alpha(0.3)
295 } else {
296 FG
297 };
298
299 if currently_invincible && blink_on {
300 vignette_screen(RED, 0.5);
301 }
302
303 draw_circle_path_world(
304 &[tip, left_wing, elbow, right_wing, tip]
305 .map(|p| p.rotated_around_point(c, -self.rotation)),
306 LINE_THICKNESS,
307 color,
308 );
309
310 self.draw_healthbar();
311 }
312
313 fn draw_healthbar(&self) {
314 let width = PLAYER_HEALTHBAR_WIDTH / MAX_PLAYER_HEALTH as f32;
315 let height = PLAYER_HEALTHBAR_HEIGHT;
316
317 for i in 0..self.health {
318 let offset = (width + PLAYER_HEALTHBAR_PADDING) * i as f32 + PLAYER_HEALTHBAR_PADDING;
319 draw_rect(
320 vec2(offset, window_height() - height - PLAYER_HEALTHBAR_PADDING),
321 vec2(width, height),
322 FG,
323 );
324 }
325 }
326}
327
328struct Asteroid {
329 health: usize,
330 max_health: usize,
331 last_hit: f32,
332 points: Vec<Vec2>,
333 pos: Vec2,
334 velocity: Vec2,
335 rotation: f32,
336 angvel: f32,
337 radius: f32,
338}
339
340impl Asteroid {
341 fn new() -> Self {
342 let radius = rand_range(MIN_ASTEROID_RADIUS..MAX_ASTEROID_RADIUS);
343 let health = (radius / MIN_ASTEROID_RADIUS) as usize * 2;
344 let last_hit = f32::MIN;
345 let pos = rand_vec2() * BASE_WINDOW_SIZE / 2.0;
346 let velocity = rand_vec2() * MAX_ASTEROID_SPEED;
347 let rotation = rand_f32() * TAU;
348 let angvel = rand_f32() * MAX_ASTEROID_ANGVEL;
349
350 let num_points = (radius * MAX_ASTEROID_POINTS) as usize;
351 let max_offset = radius * MAX_ASTEROID_POINT_OFFSET / 2.0;
352
353 let mut points = Vec::with_capacity(num_points + 1);
354
355 for i in 0..num_points {
356 let angle = (TAU / num_points as f32) * i as f32;
357 let offset = rand_range(-max_offset..max_offset) + radius;
358 let pos = Vec2::new(0.0, offset).rotated_around_origin(angle);
359 points.push(pos);
360 }
361
362 points.push(points[0]);
363
364 Self {
365 health,
366 last_hit,
367 points,
368 pos,
369 velocity,
370 rotation,
371 angvel,
372 radius,
373 max_health: health,
374 }
375 }
376
377 fn update(&mut self) {
378 self.pos += self.velocity;
379 self.rotation += self.angvel;
380 self.pos = wrap_position(self.pos, self.radius);
381 }
382
383 fn draw(&self) {
384 let points = &self
385 .points
386 .iter()
387 .map(|p| p.rotated_around_origin(self.rotation) + self.pos)
388 .collect::<Vec<_>>();
389
390 let blinking = time() - self.last_hit < ASTEROID_BLINK_DURATION;
391 let fill = if blinking { FG } else { BG };
392
393 draw_custom_shape_world(points, fill);
394 draw_circle_path_world(points, LINE_THICKNESS, FG);
395 }
396}
397
398struct Sounds {
399 shoot: SoundRef,
400 asteroid_hit: SoundRef,
401 asteroid_death: SoundRef,
402 player_hit: SoundRef,
403 game_over: SoundRef,
404 engine: SoundRef,
405}
406
407impl Sounds {
408 fn new() -> Result<Self, SoundLoadError> {
409 Ok(Self {
410 shoot: include_sound!("../assets/sounds/Gun.wav")?,
411 asteroid_hit: include_sound!("../assets/sounds/Click.wav")?,
412 asteroid_death: include_sound!("../assets/sounds/Explosion.wav")?,
413 player_hit: include_sound!("../assets/sounds/Hurt.wav")?,
414 game_over: include_sound!("../assets/sounds/Powerdown.wav")?,
415 engine: include_sound!("../assets/sounds/Crunch.wav")?,
416 })
417 }
418}
419
420#[main("Space game")]
421fn main() -> anyhow::Result<()> {
422 storage_store_state(ParticleSystem::new());
423 storage_store_state(Sounds::new()?);
424
425 bind! {
426 UP => KeyCode::ArrowUp;
427 UP => KeyCode::KeyW;
428 DOWN => KeyCode::ArrowDown;
429 DOWN => KeyCode::KeyS;
430 LEFT => KeyCode::ArrowLeft;
431 LEFT => KeyCode::KeyA;
432 RIGHT => KeyCode::ArrowRight;
433 RIGHT => KeyCode::KeyD;
434 SHOOT => KeyCode::Space;
435 }
436
437 let mut state = State::new();
438
439 loop {
440 clear_screen(BG);
441 let scale = window_size() / BASE_WINDOW_SIZE * BASE_SCALE;
442 let scale = scale.x.min(scale.y);
443 get_camera_2d_mut().set_scale(scale);
444
445 state.update();
446
447 get_particles().update();
448 get_particles().draw_world();
449 state.draw();
450
451 if should_quit() {
452 break;
453 }
454
455 next_frame().await;
456 }
457
458 Ok(())
459}
460
461fn get_particles() -> &'static mut ParticleSystem {
462 storage_get_state_mut()
463}
464
465fn get_sounds() -> &'static Sounds {
466 storage_get_state()
467}
468
469fn spawn_hit_particles(pos: Vec2, impact_dir: Vec2) {
470 play_sound(get_sounds().asteroid_hit);
471 let batch = ParticleOneshot::builder()
472 .shape(&Circle::new(
473 Vec2::ZERO,
474 Vec2::splat(LINE_THICKNESS * 1.5),
475 FG.with_alpha(0.5),
476 ))
477 .end_color(FG.with_alpha(0.0))
478 .speed(3.0)
479 .direction(impact_dir.to_angle() + FRAC_PI_2)
480 .direction_randomness(1.5)
481 .speed_randomness(2.0)
482 .lifetime(0.4)
483 .lifetime_randomness(0.2)
484 .quantity(8)
485 .build();
486 get_particles().spawn_oneshot(&batch, pos);
487}
488
489fn spawn_death_particles(pos: Vec2, radius: f32) {
490 play_sound(get_sounds().asteroid_death);
491 let batch = ParticleOneshot::builder()
492 .shape(&Circle::new(
493 Vec2::ZERO,
494 Vec2::splat(LINE_THICKNESS * 2.0),
495 FG.with_alpha(0.7),
496 ))
497 .end_color(FG.with_alpha(0.0))
498 .speed(radius * 0.1)
499 .direction(0.0)
500 .direction_randomness(std::f32::consts::TAU)
501 .speed_randomness(radius * 0.2)
502 .lifetime(0.8)
503 .lifetime_randomness(0.4)
504 .quantity((radius * 1.5) as usize)
505 .position_randomness(Vec2::splat(radius * 0.5))
506 .build();
507 get_particles().spawn_oneshot(&batch, pos);
508}pub const fn with_red(self, r: f32) -> Color
pub const fn with_green(self, g: f32) -> Color
pub const fn with_blue(self, b: f32) -> Color
pub const fn with_alpha8(self, a: u8) -> Color
pub const fn with_red8(self, r: u8) -> Color
pub const fn with_green8(self, g: u8) -> Color
pub const fn with_blue8(self, b: u8) -> Color
pub fn inverted(self) -> Color
pub const fn hex(hex: u32) -> Color
pub const fn hex_alpha(hex: u32) -> Color
pub const fn to_hex(&self) -> u32
pub fn to_hex_string(&self) -> String
pub fn from_hsla(hue: f32, saturation: f32, lightness: f32, alpha: f32) -> Color
pub fn from_hsl(hue: f32, saturation: f32, lightness: f32) -> Color
pub fn to_oklch(&self) -> (f32, f32, f32)
pub fn from_oklch_with_alpha( lightness: f32, chroma: f32, hue: f32, alpha: f32, ) -> Color
Sourcepub fn from_oklch(lightness: f32, chroma: f32, hue: f32) -> Color
pub fn from_oklch(lightness: f32, chroma: f32, hue: f32) -> Color
Examples found in repository?
More examples
examples/screenshot.rs (line 64)
57async fn draw_pattern() {
58 let mut hue = 0.0;
59 let mut offset = vec2(0.0, 0.0);
60
61 loop {
62 hue += 20.0 * delta_time();
63 hue %= 360.0;
64 let color = Color::from_oklch(0.727, 0.1219, hue);
65 let alt_color = color.darken_oklch(0.05);
66
67 offset -= vec2(0.5, 0.25) * delta_time();
68
69 draw_sdf(
70 Sdf::rect_tl(vec2(0.0, 0.0), window_size())
71 .with_fill(color, alt_color, FRAC_PI_2, 5.0, SdfFill::Truchet)
72 .with_fill_offset(offset),
73 );
74
75 let r = min_window_dimension() / 5.0;
76
77 draw_circle(window_center(), r, Color::BLACK);
78 push_scissor(Area::new(vec2(window_center().x, 0.0), window_size()).to_rect());
79 draw_circle(window_center(), r, Color::WHITE);
80 pop_scissor();
81
82 next_frame().await;
83 }
84}pub fn lighten(self, factor: f32) -> Color
pub fn darken(self, factor: f32) -> Color
pub fn saturate(self, factor: f32) -> Color
pub fn desaturate(self, factor: f32) -> Color
pub fn hue_rotate(self, degrees: f32) -> Color
pub fn lighten_oklch(self, factor: f32) -> Color
Sourcepub fn darken_oklch(self, factor: f32) -> Color
pub fn darken_oklch(self, factor: f32) -> Color
Examples found in repository?
examples/screenshot.rs (line 65)
57async fn draw_pattern() {
58 let mut hue = 0.0;
59 let mut offset = vec2(0.0, 0.0);
60
61 loop {
62 hue += 20.0 * delta_time();
63 hue %= 360.0;
64 let color = Color::from_oklch(0.727, 0.1219, hue);
65 let alt_color = color.darken_oklch(0.05);
66
67 offset -= vec2(0.5, 0.25) * delta_time();
68
69 draw_sdf(
70 Sdf::rect_tl(vec2(0.0, 0.0), window_size())
71 .with_fill(color, alt_color, FRAC_PI_2, 5.0, SdfFill::Truchet)
72 .with_fill_offset(offset),
73 );
74
75 let r = min_window_dimension() / 5.0;
76
77 draw_circle(window_center(), r, Color::BLACK);
78 push_scissor(Area::new(vec2(window_center().x, 0.0), window_size()).to_rect());
79 draw_circle(window_center(), r, Color::WHITE);
80 pop_scissor();
81
82 next_frame().await;
83 }
84}pub fn hue_rotate_oklch(self, degrees: f32) -> Color
pub fn to_color_u8(self) -> ColorU8
pub fn blend_two(a: Color, b: Color, fac: f32) -> Color
pub fn blend_two_halfway(a: Color, b: Color) -> Color
pub fn blend(self, other: Color, fac: f32) -> Color
pub fn blend_halfway(self, other: Color) -> Color
pub fn to_linear(self) -> Color
pub fn from_usize(n: usize) -> Color
pub fn from_usize_no_alpha(n: usize) -> Color
Trait Implementations§
Source§impl AddAssign for Color
impl AddAssign for Color
Source§fn add_assign(&mut self, rhs: Color)
fn add_assign(&mut self, rhs: Color)
Performs the
+= operation. Read moreSource§impl Archive for Color
impl Archive for Color
Source§const COPY_OPTIMIZATION: CopyOptimization<Color>
const COPY_OPTIMIZATION: CopyOptimization<Color>
An optimization flag that allows the bytes of this type to be copied
directly to a writer instead of calling
serialize. Read moreSource§type Archived = ArchivedColor
type Archived = ArchivedColor
The archived representation of this type. Read more
Source§type Resolver = ColorResolver
type Resolver = ColorResolver
The resolver for this type. It must contain all the additional
information from serializing needed to make the archived type from
the normal type.
Source§impl PartialLerp for Color
impl PartialLerp for Color
Source§impl PartialOrd for Color
impl PartialOrd for Color
Source§impl SubAssign for Color
impl SubAssign for Color
Source§fn sub_assign(&mut self, rhs: Color)
fn sub_assign(&mut self, rhs: Color)
Performs the
-= operation. Read moreimpl Copy for Color
impl StructuralPartialEq 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 UnsafeUnpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Convert the source color to the destination color using the specified
method.
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford
method by default.
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
The archived counterpart of this type. Unlike
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
Creates the archived version of the metadata for this value.
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Cast a collection of colors into a collection of arrays.
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
Cast this collection of arrays into a collection of colors.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
The number type that’s used in
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
Converts
self into C, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Cast a collection of colors into a collection of color components.
Source§impl<T> Content for Twhere
T: Copy,
impl<T> Content for Twhere
T: Copy,
Source§unsafe fn read<F, E>(size: usize, f: F) -> Result<T, E>
unsafe fn read<F, E>(size: usize, f: F) -> Result<T, E>
Prepares an output buffer, then turns this buffer into an
Owned.
User-provided closure F must only write to and not read from &mut Self.Source§fn get_elements_size() -> usize
fn get_elements_size() -> usize
Returns the size of each element.
Source§fn to_void_ptr(&self) -> *const ()
fn to_void_ptr(&self) -> *const ()
Produces a pointer to the data.
Source§fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>
fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>
Builds a pointer to this type from a raw pointer.
Source§fn is_size_suitable(size: usize) -> bool
fn is_size_suitable(size: usize) -> bool
Returns true if the size is suitable to store a type like this.
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
Performs a conversion from
angle.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
Converts
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
Performs a conversion into
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
The number type that’s used in
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
Converts
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Convert into T with values clamped to the color defined bounds Read more
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Convert into T. The resulting color might be invalid in its color space Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
Converts
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Set the foreground color generically Read more
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Set the background color generically. Read more
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Change the foreground color to black
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Change the background color to black
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Change the foreground color to red
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Change the background color to red
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Change the foreground color to green
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Change the background color to green
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Change the foreground color to yellow
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Change the background color to yellow
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Change the foreground color to blue
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Change the background color to blue
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Change the foreground color to magenta
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Change the background color to magenta
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Change the foreground color to purple
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Change the background color to purple
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Change the foreground color to cyan
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Change the background color to cyan
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Change the foreground color to white
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Change the background color to white
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Change the foreground color to the terminal default
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Change the background color to the terminal default
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Change the foreground color to bright black
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Change the background color to bright black
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Change the foreground color to bright red
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Change the background color to bright red
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Change the foreground color to bright green
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Change the background color to bright green
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Change the foreground color to bright yellow
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Change the background color to bright yellow
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Change the foreground color to bright blue
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Change the background color to bright blue
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright magenta
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright magenta
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright purple
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright purple
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Change the foreground color to bright cyan
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Change the background color to bright cyan
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Change the foreground color to bright white
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Change the background color to bright white
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Make the text bold
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Make the text dim
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Make the text italicized
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Make the text underlined
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Make the text blink
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Make the text blink (but fast!)
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Swap the foreground and background colors
Hide the text
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Cross out the text
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the foreground color at runtime. Only use if you do not know which color will be used at
compile-time. If the color is constant, use either
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the background color at runtime. Only use if you do not know what color to use at
compile-time. If the color is constant, use either
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the foreground color to a specific RGB value.
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the background color to a specific RGB value.
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Sets the foreground color to an RGB value.
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Sets the background color to an RGB value.
Source§impl<T> PartialClamp for Twhere
T: PartialOrd,
impl<T> PartialClamp for Twhere
T: PartialOrd,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, S> SerializeUnsized<S> for T
impl<T, S> SerializeUnsized<S> for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
The error for when
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Try to cast this collection of color components into a collection of
colors. Read more
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
Convert into T, returning ok if the color is inside of its defined
range, otherwise an
OutOfBounds error is returned which contains
the unclamped color. Read moreSource§impl<C, U> UintsFrom<C> for Uwhere
C: IntoUints<U>,
impl<C, U> UintsFrom<C> for Uwhere
C: IntoUints<U>,
Source§fn uints_from(colors: C) -> U
fn uints_from(colors: C) -> U
Cast a collection of colors into a collection of unsigned integers.
Source§impl<C, U> UintsInto<C> for Uwhere
C: FromUints<U>,
impl<C, U> UintsInto<C> for Uwhere
C: FromUints<U>,
Source§fn uints_into(self) -> C
fn uints_into(self) -> C
Cast this collection of unsigned integers into a collection of colors.