bevy_ui 0.18.1

A custom ECS-driven UI framework built specifically for Bevy Engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
use crate::{UiPosition, Val};
use bevy_color::{Color, Srgba};
use bevy_ecs::{component::Component, reflect::ReflectComponent};
use bevy_math::Vec2;
use bevy_reflect::prelude::*;
use bevy_utils::default;
use core::{f32, f32::consts::TAU};

/// A color stop for a gradient
#[derive(Debug, Copy, Clone, PartialEq, Reflect)]
#[reflect(Default, PartialEq, Debug)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
pub struct ColorStop {
    /// Color
    pub color: Color,
    /// Logical position along the gradient line.
    /// Stop positions are relative to the start of the gradient and not other stops.
    pub point: Val,
    /// Normalized position between this and the following stop of the interpolation midpoint.
    pub hint: f32,
}

impl ColorStop {
    /// Create a new color stop
    pub fn new(color: impl Into<Color>, point: Val) -> Self {
        Self {
            color: color.into(),
            point,
            hint: 0.5,
        }
    }

    /// An automatic color stop.
    /// The positions of automatic stops are interpolated evenly between explicit stops.
    pub fn auto(color: impl Into<Color>) -> Self {
        Self {
            color: color.into(),
            point: Val::Auto,
            hint: 0.5,
        }
    }

    /// A color stop with its position in logical pixels.
    pub fn px(color: impl Into<Color>, px: f32) -> Self {
        Self {
            color: color.into(),
            point: Val::Px(px),
            hint: 0.5,
        }
    }

    /// A color stop with a percentage position.
    pub fn percent(color: impl Into<Color>, percent: f32) -> Self {
        Self {
            color: color.into(),
            point: Val::Percent(percent),
            hint: 0.5,
        }
    }

    // Set the interpolation midpoint between this and the following stop
    pub const fn with_hint(mut self, hint: f32) -> Self {
        self.hint = hint;
        self
    }
}

impl From<(Color, Val)> for ColorStop {
    fn from((color, stop): (Color, Val)) -> Self {
        Self {
            color,
            point: stop,
            hint: 0.5,
        }
    }
}

impl From<Color> for ColorStop {
    fn from(color: Color) -> Self {
        Self {
            color,
            point: Val::Auto,
            hint: 0.5,
        }
    }
}

impl From<Srgba> for ColorStop {
    fn from(color: Srgba) -> Self {
        Self {
            color: color.into(),
            point: Val::Auto,
            hint: 0.5,
        }
    }
}

impl Default for ColorStop {
    fn default() -> Self {
        Self {
            color: Color::WHITE,
            point: Val::Auto,
            hint: 0.5,
        }
    }
}

/// An angular color stop for a conic gradient
#[derive(Debug, Copy, Clone, PartialEq, Reflect)]
#[reflect(Default, PartialEq, Debug)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
pub struct AngularColorStop {
    /// Color of the stop
    pub color: Color,
    /// The angle of the stop.
    /// Angles are relative to the start of the gradient and not other stops.
    /// If set to `None` the angle of the stop will be interpolated between the explicit stops or 0 and 2 PI degrees if there no explicit stops.
    /// Given angles are clamped to between `0.`, and [`TAU`].
    /// This means that a list of stops:
    /// ```
    /// # use std::f32::consts::TAU;
    /// # use bevy_ui::AngularColorStop;
    /// # use bevy_color::{Color, palettes::css::{RED, BLUE}};
    /// let stops = [
    ///     AngularColorStop::new(Color::WHITE, 0.),
    ///     AngularColorStop::new(Color::BLACK, -1.),
    ///     AngularColorStop::new(RED, 2. * TAU),
    ///     AngularColorStop::new(BLUE, TAU),
    /// ];
    /// ```
    /// is equivalent to:
    /// ```
    /// # use std::f32::consts::TAU;
    /// # use bevy_ui::AngularColorStop;
    /// # use bevy_color::{Color, palettes::css::{RED, BLUE}};
    /// let stops = [
    ///     AngularColorStop::new(Color::WHITE, 0.),
    ///     AngularColorStop::new(Color::BLACK, 0.),
    ///     AngularColorStop::new(RED, TAU),
    ///     AngularColorStop::new(BLUE, TAU),
    /// ];
    /// ```
    /// Resulting in a black to red gradient, not white to blue.
    pub angle: Option<f32>,
    /// Normalized angle between this and the following stop of the interpolation midpoint.
    pub hint: f32,
}

impl AngularColorStop {
    // Create a new color stop
    pub fn new(color: impl Into<Color>, angle: f32) -> Self {
        Self {
            color: color.into(),
            angle: Some(angle),
            hint: 0.5,
        }
    }

    /// An angular stop without an explicit angle. The angles of automatic stops
    /// are interpolated evenly between explicit stops.
    pub fn auto(color: impl Into<Color>) -> Self {
        Self {
            color: color.into(),
            angle: None,
            hint: 0.5,
        }
    }

    // Set the interpolation midpoint between this and the following stop
    pub const fn with_hint(mut self, hint: f32) -> Self {
        self.hint = hint;
        self
    }
}

impl From<(Color, f32)> for AngularColorStop {
    fn from((color, angle): (Color, f32)) -> Self {
        Self {
            color,
            angle: Some(angle),
            hint: 0.5,
        }
    }
}

impl From<Color> for AngularColorStop {
    fn from(color: Color) -> Self {
        Self {
            color,
            angle: None,
            hint: 0.5,
        }
    }
}

impl From<Srgba> for AngularColorStop {
    fn from(color: Srgba) -> Self {
        Self {
            color: color.into(),
            angle: None,
            hint: 0.5,
        }
    }
}

impl Default for AngularColorStop {
    fn default() -> Self {
        Self {
            color: Color::WHITE,
            angle: None,
            hint: 0.5,
        }
    }
}

/// A linear gradient
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient>
#[derive(Default, Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
pub struct LinearGradient {
    /// The color space used for interpolation.
    pub color_space: InterpolationColorSpace,
    /// The direction of the gradient in radians.
    /// An angle of `0.` points upward, with the value increasing in the clockwise direction.
    pub angle: f32,
    /// The list of color stops
    pub stops: Vec<ColorStop>,
}

impl LinearGradient {
    /// Angle of a linear gradient transitioning from bottom to top
    pub const TO_TOP: f32 = 0.;
    /// Angle of a linear gradient transitioning from bottom-left to top-right
    pub const TO_TOP_RIGHT: f32 = TAU / 8.;
    /// Angle of a linear gradient transitioning from left to right
    pub const TO_RIGHT: f32 = 2. * Self::TO_TOP_RIGHT;
    /// Angle of a linear gradient transitioning from top-left to bottom-right
    pub const TO_BOTTOM_RIGHT: f32 = 3. * Self::TO_TOP_RIGHT;
    /// Angle of a linear gradient transitioning from top to bottom
    pub const TO_BOTTOM: f32 = 4. * Self::TO_TOP_RIGHT;
    /// Angle of a linear gradient transitioning from top-right to bottom-left
    pub const TO_BOTTOM_LEFT: f32 = 5. * Self::TO_TOP_RIGHT;
    /// Angle of a linear gradient transitioning from right to left
    pub const TO_LEFT: f32 = 6. * Self::TO_TOP_RIGHT;
    /// Angle of a linear gradient transitioning from bottom-right to top-left
    pub const TO_TOP_LEFT: f32 = 7. * Self::TO_TOP_RIGHT;

    /// Create a new linear gradient
    pub fn new(angle: f32, stops: Vec<ColorStop>) -> Self {
        Self {
            angle,
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    /// A linear gradient transitioning from bottom to top
    pub fn to_top(stops: Vec<ColorStop>) -> Self {
        Self {
            angle: Self::TO_TOP,
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    /// A linear gradient transitioning from bottom-left to top-right
    pub fn to_top_right(stops: Vec<ColorStop>) -> Self {
        Self {
            angle: Self::TO_TOP_RIGHT,
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    /// A linear gradient transitioning from left to right
    pub fn to_right(stops: Vec<ColorStop>) -> Self {
        Self {
            angle: Self::TO_RIGHT,
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    /// A linear gradient transitioning from top-left to bottom-right
    pub fn to_bottom_right(stops: Vec<ColorStop>) -> Self {
        Self {
            angle: Self::TO_BOTTOM_RIGHT,
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    /// A linear gradient transitioning from top to bottom
    pub fn to_bottom(stops: Vec<ColorStop>) -> Self {
        Self {
            angle: Self::TO_BOTTOM,
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    /// A linear gradient transitioning from top-right to bottom-left
    pub fn to_bottom_left(stops: Vec<ColorStop>) -> Self {
        Self {
            angle: Self::TO_BOTTOM_LEFT,
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    /// A linear gradient transitioning from right to left
    pub fn to_left(stops: Vec<ColorStop>) -> Self {
        Self {
            angle: Self::TO_LEFT,
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    /// A linear gradient transitioning from bottom-right to top-left
    pub fn to_top_left(stops: Vec<ColorStop>) -> Self {
        Self {
            angle: Self::TO_TOP_LEFT,
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    /// A linear gradient with the given angle in degrees
    pub fn degrees(degrees: f32, stops: Vec<ColorStop>) -> Self {
        Self {
            angle: degrees.to_radians(),
            stops,
            color_space: InterpolationColorSpace::default(),
        }
    }

    pub fn in_color_space(mut self, color_space: InterpolationColorSpace) -> Self {
        self.color_space = color_space;
        self
    }
}

/// A radial gradient
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/radial-gradient>
#[derive(Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
pub struct RadialGradient {
    /// The color space used for interpolation.
    pub color_space: InterpolationColorSpace,
    /// The center of the radial gradient
    pub position: UiPosition,
    /// Defines the end shape of the radial gradient
    pub shape: RadialGradientShape,
    /// The list of color stops
    pub stops: Vec<ColorStop>,
}

impl RadialGradient {
    /// Create a new radial gradient
    pub fn new(position: UiPosition, shape: RadialGradientShape, stops: Vec<ColorStop>) -> Self {
        Self {
            color_space: default(),
            position,
            shape,
            stops,
        }
    }

    pub const fn in_color_space(mut self, color_space: InterpolationColorSpace) -> Self {
        self.color_space = color_space;
        self
    }
}

impl Default for RadialGradient {
    fn default() -> Self {
        Self {
            position: UiPosition::CENTER,
            shape: RadialGradientShape::ClosestCorner,
            stops: Vec::new(),
            color_space: default(),
        }
    }
}

/// A conic gradient
///
/// <https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/conic-gradient>
#[derive(Default, Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
pub struct ConicGradient {
    /// The color space used for interpolation.
    pub color_space: InterpolationColorSpace,
    /// The starting angle of the gradient in radians
    pub start: f32,
    /// The center of the conic gradient
    pub position: UiPosition,
    /// The list of color stops
    pub stops: Vec<AngularColorStop>,
}

impl ConicGradient {
    /// Create a new conic gradient
    pub fn new(position: UiPosition, stops: Vec<AngularColorStop>) -> Self {
        Self {
            color_space: default(),
            start: 0.,
            position,
            stops,
        }
    }

    /// Sets the starting angle of the gradient in radians
    pub const fn with_start(mut self, start: f32) -> Self {
        self.start = start;
        self
    }

    /// Sets the position of the gradient
    pub const fn with_position(mut self, position: UiPosition) -> Self {
        self.position = position;
        self
    }

    pub const fn in_color_space(mut self, color_space: InterpolationColorSpace) -> Self {
        self.color_space = color_space;
        self
    }
}

#[derive(Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
pub enum Gradient {
    /// A linear gradient
    ///
    /// <https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient>
    Linear(LinearGradient),
    /// A radial gradient
    ///
    /// <https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/radial-gradient>
    Radial(RadialGradient),
    /// A conic gradient
    ///
    /// <https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/conic-gradient>
    Conic(ConicGradient),
}

impl Gradient {
    /// Returns true if the gradient has no stops.
    pub const fn is_empty(&self) -> bool {
        match self {
            Gradient::Linear(gradient) => gradient.stops.is_empty(),
            Gradient::Radial(gradient) => gradient.stops.is_empty(),
            Gradient::Conic(gradient) => gradient.stops.is_empty(),
        }
    }

    /// If the gradient has only a single color stop, `get_single` returns its color.
    pub fn get_single(&self) -> Option<Color> {
        match self {
            Gradient::Linear(gradient) => gradient
                .stops
                .first()
                .and_then(|stop| (gradient.stops.len() == 1).then_some(stop.color)),
            Gradient::Radial(gradient) => gradient
                .stops
                .first()
                .and_then(|stop| (gradient.stops.len() == 1).then_some(stop.color)),
            Gradient::Conic(gradient) => gradient
                .stops
                .first()
                .and_then(|stop| (gradient.stops.len() == 1).then_some(stop.color)),
        }
    }
}

impl From<LinearGradient> for Gradient {
    fn from(value: LinearGradient) -> Self {
        Self::Linear(value)
    }
}

impl From<RadialGradient> for Gradient {
    fn from(value: RadialGradient) -> Self {
        Self::Radial(value)
    }
}

impl From<ConicGradient> for Gradient {
    fn from(value: ConicGradient) -> Self {
        Self::Conic(value)
    }
}

#[derive(Component, Clone, PartialEq, Debug, Default, Reflect)]
#[reflect(Component, Default, PartialEq, Debug, Clone)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
/// A UI node that displays a gradient
pub struct BackgroundGradient(pub Vec<Gradient>);

impl<T: Into<Gradient>> From<T> for BackgroundGradient {
    fn from(value: T) -> Self {
        Self(vec![value.into()])
    }
}

#[derive(Component, Clone, PartialEq, Debug, Default, Reflect)]
#[reflect(Component, Default, PartialEq, Debug, Clone)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
/// A UI node border that displays a gradient
pub struct BorderGradient(pub Vec<Gradient>);

impl<T: Into<Gradient>> From<T> for BorderGradient {
    fn from(value: T) -> Self {
        Self(vec![value.into()])
    }
}

#[derive(Default, Copy, Clone, PartialEq, Debug, Reflect)]
#[reflect(PartialEq, Default)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
pub enum RadialGradientShape {
    /// A circle with radius equal to the distance from its center to the closest side
    ClosestSide,
    /// A circle with radius equal to the distance from its center to the farthest side
    FarthestSide,
    /// An ellipse with extents equal to the distance from its center to the nearest corner
    #[default]
    ClosestCorner,
    /// An ellipse with extents equal to the distance from its center to the farthest corner
    FarthestCorner,
    /// A circle
    Circle(Val),
    /// An ellipse
    Ellipse(Val, Val),
}

const fn close_side(p: f32, h: f32) -> f32 {
    (-h - p).abs().min((h - p).abs())
}

const fn far_side(p: f32, h: f32) -> f32 {
    (-h - p).abs().max((h - p).abs())
}

const fn close_side2(p: Vec2, h: Vec2) -> f32 {
    close_side(p.x, h.x).min(close_side(p.y, h.y))
}

const fn far_side2(p: Vec2, h: Vec2) -> f32 {
    far_side(p.x, h.x).max(far_side(p.y, h.y))
}

impl RadialGradientShape {
    /// Resolve the physical dimensions of the end shape of the radial gradient
    pub fn resolve(
        self,
        position: Vec2,
        scale_factor: f32,
        physical_size: Vec2,
        physical_target_size: Vec2,
    ) -> Vec2 {
        let half_size = 0.5 * physical_size;
        match self {
            RadialGradientShape::ClosestSide => Vec2::splat(close_side2(position, half_size)),
            RadialGradientShape::FarthestSide => Vec2::splat(far_side2(position, half_size)),
            RadialGradientShape::ClosestCorner => Vec2::new(
                close_side(position.x, half_size.x),
                close_side(position.y, half_size.y),
            ),
            RadialGradientShape::FarthestCorner => Vec2::new(
                far_side(position.x, half_size.x),
                far_side(position.y, half_size.y),
            ),
            RadialGradientShape::Circle(radius) => Vec2::splat(
                radius
                    .resolve(scale_factor, physical_size.x, physical_target_size)
                    .unwrap_or(0.),
            ),
            RadialGradientShape::Ellipse(x, y) => Vec2::new(
                x.resolve(scale_factor, physical_size.x, physical_target_size)
                    .unwrap_or(0.),
                y.resolve(scale_factor, physical_size.y, physical_target_size)
                    .unwrap_or(0.),
            ),
        }
    }
}

/// The color space used for interpolation.
#[derive(Default, Copy, Clone, Hash, Debug, PartialEq, Eq, Reflect)]
#[cfg_attr(
    feature = "serialize",
    derive(serde::Serialize, serde::Deserialize),
    reflect(Serialize, Deserialize)
)]
pub enum InterpolationColorSpace {
    /// Interpolates in OKLABA space.
    #[default]
    Oklaba,
    /// Interpolates in OKLCHA space, taking the shortest hue path.
    Oklcha,
    /// Interpolates in OKLCHA space, taking the longest hue path.
    OklchaLong,
    /// Interpolates in sRGBA space.
    Srgba,
    /// Interpolates in linear sRGBA space.
    LinearRgba,
    /// Interpolates in HSLA space, taking the shortest hue path.
    Hsla,
    /// Interpolates in HSLA space, taking the longest hue path.
    HslaLong,
    /// Interpolates in HSVA space, taking the shortest hue path.
    Hsva,
    /// Interpolates in HSVA space, taking the longest hue path.
    HsvaLong,
}

/// Set the color space used for interpolation.
pub trait InColorSpace: Sized {
    /// Interpolate in the given `color_space`.
    fn in_color_space(self, color_space: InterpolationColorSpace) -> Self;

    /// Interpolate in `OKLab` space.
    fn in_oklaba(self) -> Self {
        self.in_color_space(InterpolationColorSpace::Oklaba)
    }

    /// Interpolate in OKLCH space (short hue path).
    fn in_oklch(self) -> Self {
        self.in_color_space(InterpolationColorSpace::Oklcha)
    }

    /// Interpolate in OKLCH space (long hue path).
    fn in_oklch_long(self) -> Self {
        self.in_color_space(InterpolationColorSpace::OklchaLong)
    }

    /// Interpolate in sRGB space.
    fn in_srgb(self) -> Self {
        self.in_color_space(InterpolationColorSpace::Srgba)
    }

    /// Interpolate in linear sRGB space.
    fn in_linear_rgb(self) -> Self {
        self.in_color_space(InterpolationColorSpace::LinearRgba)
    }
}

impl InColorSpace for LinearGradient {
    /// Interpolate in the given `color_space`.
    fn in_color_space(mut self, color_space: InterpolationColorSpace) -> Self {
        self.color_space = color_space;
        self
    }
}

impl InColorSpace for RadialGradient {
    /// Interpolate in the given `color_space`.
    fn in_color_space(mut self, color_space: InterpolationColorSpace) -> Self {
        self.color_space = color_space;
        self
    }
}

impl InColorSpace for ConicGradient {
    /// Interpolate in the given `color_space`.
    fn in_color_space(mut self, color_space: InterpolationColorSpace) -> Self {
        self.color_space = color_space;
        self
    }
}