agb 0.23.1

Library for Game Boy Advance Development
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
#![warn(missing_docs)]
mod registers;

use registers::{BlendControlAlpha, BlendControlBrightness, BlendControlRegister};

use super::tiled::BackgroundId;
use crate::{fixnum::Num, memory_mapped::MemoryMapped};

const BLEND_CONTROL: MemoryMapped<BlendControlRegister> = unsafe { MemoryMapped::new(0x0400_0050) };
const BLEND_ALPHA: MemoryMapped<BlendControlAlpha> = unsafe { MemoryMapped::new(0x0400_0052) };
const BLEND_BRIGHTNESS: MemoryMapped<BlendControlBrightness> =
    unsafe { MemoryMapped::new(0x0400_0054) };

/// The layers, top layer will be blended into the bottom layer
#[derive(Clone, Copy, Debug)]
pub enum Layer {
    /// Top layer gets blended into the bottom layer
    Top = 0,
    /// The bottom layer of the blend
    Bottom = 1,
}

/// Control the blending of two layers on the frame.
///
/// The Game Boy Advance offers very little in the way of alpha blending, which is something
/// you may be more familiar with if you've used other game engines or the layer settings in
/// image editors.
///
/// You can blend between a single [Top](Layer::Top) and [Bottom](Layer::Bottom) layer, and
/// only in one mode.
///
/// - [`alpha`](Blend::alpha) where some configurable amount of each layer will be rendered
///   to the screen.
/// - [`brighten`](Blend::brighten) where you fade the `Top` layer towards white
/// - [`darken`](Blend::darken) where you fade the `Top` layer towards black
/// - [`object_transparency`](Blend::object_transparency) which enables object transparency for certain objects
///
/// Note that for blending to actually work, whatever is in the `Top` layer has to be drawn after
/// anything in the `Bottom` layer (i.e. the `Top` layer's [`Priority`](crate::display::Priority)
/// must be _lower_ than the `Bottom` layer's `Priority`).
///
/// If you are using [`Windows`](super::Windows), blending won't happen unless you enable blending with
/// them, and then it will only work within the boundary of the window.
pub struct Blend {
    blend_control: registers::BlendControlRegister,
    alpha: registers::BlendControlAlpha,
    brightness: registers::BlendControlBrightness,
}

impl Blend {
    pub(crate) fn new() -> Self {
        Self {
            blend_control: Default::default(),
            alpha: Default::default(),
            brightness: Default::default(),
        }
    }

    fn reset(&mut self) {
        self.blend_control = Default::default();
        self.alpha = Default::default();
        self.brightness = Default::default();
    }

    /// Sets this blend effect to `alpha` which allows for a configurable amount of each layer to
    /// be rendered onto the screen.
    ///
    /// The final colour will be a weighted sum of the colours of each layer multiplied by `value`.
    /// So a `value` of `num!(0.5)` for both the top and the bottom layers will mean you get
    /// half of each colour added together.
    ///
    /// Any pixels which aren't shared by both layers will be drawn at their full pixel value.
    ///
    /// Values must be between 0 and 1 inclusive. This function panics if value > 1.
    pub fn alpha(
        &mut self,
        top_layer_alpha: Num<u8, 4>,
        bottom_layer_alpha: Num<u8, 4>,
    ) -> BlendAlphaEffect<'_> {
        self.reset();

        self.blend_control
            .set_colour_effect(registers::Effect::Alpha);
        self.set_layer_alpha(Layer::Top, top_layer_alpha);
        self.set_layer_alpha(Layer::Bottom, bottom_layer_alpha);

        BlendAlphaEffect { blend: self }
    }

    /// Fade the `Top` layer towards white by a configurable amount.
    ///
    /// The `amount` must be between 0 and 1 inclusive. This function panics if `amount` > 1.
    /// Since the amount is a `Num<u8, 4>`, there are only 6 possible levels of fading.
    pub fn brighten(&mut self, amount: Num<u8, 4>) -> BlendFadeEffect<'_> {
        self.reset();

        self.blend_control
            .set_colour_effect(registers::Effect::Increase);
        self.set_fade(amount);

        BlendFadeEffect { blend: self }
    }

    /// Fade the `Top` layer towards black by a configurable amount.
    ///
    /// The `amount` must be between 0 and 1 inclusive. This function panics if `amount` > 1.
    /// Since the amount is a `Num<u8, 4>`, there are only 6 possible levels of fading.
    pub fn darken(&mut self, amount: Num<u8, 4>) -> BlendFadeEffect<'_> {
        self.reset();

        self.blend_control
            .set_colour_effect(registers::Effect::Decrease);
        self.set_fade(amount);

        BlendFadeEffect { blend: self }
    }

    /// Enable object transparency for every object which has its
    /// [`GraphicsMode`](crate::display::object::GraphicsMode) set to `AlphaBlending`.
    ///
    /// The final colour will be a weighted sum of the colours of each pixel in the object multiplied
    /// by `top_layer_alpha` and any enabled background layers by `bottom_layer_alpha`.
    ///
    /// So an `alpha` of `num!(0.5)` for both the top and the bottom layers will mean you get
    /// half of each colour added together. You'll probably want `top_layer_alpha` + `bottom_layer_alpha`
    /// to equal `1`, although this isn't required if you want some crazy effects.
    pub fn object_transparency(
        &mut self,
        top_layer_alpha: Num<u8, 4>,
        bottom_layer_alpha: Num<u8, 4>,
    ) -> BlendObjectTransparency<'_> {
        self.reset();

        assert!(top_layer_alpha <= 1.into());
        assert!(bottom_layer_alpha <= 1.into());

        self.blend_control
            .set_colour_effect(registers::Effect::None);
        self.set_layer_alpha(Layer::Top, top_layer_alpha);
        self.set_layer_alpha(Layer::Bottom, bottom_layer_alpha);

        BlendObjectTransparency { blend: self }
    }

    fn set_background_enable(&mut self, layer: Layer, background_id: impl Into<BackgroundId>) {
        self.with_target(layer, |mut target| {
            target.enable_background(background_id);
            target
        });
    }

    fn set_object_enable(&mut self, layer: Layer) {
        self.with_target(layer, |mut target| {
            target.enable_object();
            target
        });
    }

    fn set_backdrop_enable(&mut self, layer: Layer) {
        self.with_target(layer, |mut target| {
            target.enable_backdrop();
            target
        });
    }

    fn with_target(
        &mut self,
        layer: Layer,
        f: impl FnOnce(registers::BlendTarget) -> registers::BlendTarget,
    ) {
        match layer {
            Layer::Top => self
                .blend_control
                .set_first_target(f(self.blend_control.first_target())),
            Layer::Bottom => self
                .blend_control
                .set_second_target(f(self.blend_control.second_target())),
        }
    }

    fn set_layer_alpha(&mut self, layer: Layer, value: Num<u8, 4>) {
        assert!(value <= 1.into());

        match layer {
            Layer::Top => self.alpha.set_first_blend(value),
            Layer::Bottom => self.alpha.set_second_blend(value),
        }
    }

    fn set_fade(&mut self, value: Num<u8, 4>) {
        assert!(value <= 1.into());
        self.brightness.set(value);
    }

    pub(crate) fn commit(&self) {
        BLEND_CONTROL.set(self.blend_control);
        BLEND_ALPHA.set(self.alpha);
        BLEND_BRIGHTNESS.set(self.brightness);
    }
}

/// Configure the alpha setting for an alpha blend
pub struct BlendAlphaEffect<'blend> {
    blend: &'blend mut Blend,
}

impl BlendAlphaEffect<'_> {
    /// Enables a background for blending on `layer`.
    pub fn enable_background(
        &mut self,
        layer: Layer,
        background: impl Into<BackgroundId>,
    ) -> &mut Self {
        self.blend.set_background_enable(layer, background);
        self
    }

    /// Enables object blending on `layer`.
    ///
    /// This will only work for objects which have a
    /// [`GraphicsMode`](crate::display::object::GraphicsMode) set to `AlphaBlending`.
    pub fn enable_object(&mut self, layer: Layer) -> &mut Self {
        self.blend.set_object_enable(layer);
        self
    }

    /// Enables the backdrop for `layer`.
    ///
    /// The backdrop is the 0th colour in the palette. It is the colour that is displayed
    /// when there is no background displaying anything at that location.
    pub fn enable_backdrop(&mut self, layer: Layer) -> &mut Self {
        self.blend.set_backdrop_enable(layer);
        self
    }
}

/// Configure the fade effect for a darken or lighten blend.
///
/// Fade effects will blend the [`Layer::Top`] layer towards either black or white by the amount
/// given to the `.brighten()` or `.darken()` methods on [`Blend`]. This is useful if you want to fade part
/// of the screen to white or black, or apply some other effects like adding lightning to the
/// background.
///
/// Due to hardware restrictions, there are only 6 levels of fade available. Therefore, this
/// probably isn't the best effect for smoothly fading in and out as a transition, and that
/// is better left to changing the colour palette.
///
/// ```rust,no_run
/// # #![no_main]
/// # #![no_std]
/// use agb::fixnum::num;
///
/// # fn test(frame: &mut agb::display::GraphicsFrame, bg_id: agb::display::tiled::BackgroundId) {
/// frame
///    .blend()
///    .brighten(num!(0.5))
///    .enable_background(bg_id);
/// # }
/// ```
pub struct BlendFadeEffect<'blend> {
    blend: &'blend mut Blend,
}

impl BlendFadeEffect<'_> {
    /// Enables a background for blending.
    ///
    /// This will cause the background to be faded towards black or white (depending on whether
    /// this is darken or lighten).
    pub fn enable_background(&mut self, background: impl Into<BackgroundId>) -> &mut Self {
        self.blend.set_background_enable(Layer::Top, background);
        self
    }

    /// Enables object blending.
    ///
    /// This will only work for objects which have a
    /// [`GraphicsMode`](crate::display::object::GraphicsMode) set to `AlphaBlending` and will
    /// cause any object with that graphics mode to blend towards white / black (depending on
    /// whether this is lighten or darken).
    ///
    /// This interacts with object transparency in a strange way. If object transparency is also
    /// enabled as part of this blend, then the parts of the sprite which overlap with the enabled
    /// backgrounds will show as transparent but anything which doesn't overlap with the background
    /// will be shown as faded towards black or white.
    pub fn enable_object(&mut self) -> &mut Self {
        self.blend.set_object_enable(Layer::Top);
        self
    }

    /// Enables the backdrop for this layer.
    ///
    /// The backdrop is the 0th colour in the palette. It is the colour that is displayed
    /// when there is no background displaying anything at that location.
    pub fn enable_backdrop(&mut self) -> &mut Self {
        self.blend.set_backdrop_enable(Layer::Top);
        self
    }

    /// Configure object transparency in addition to the fading.
    ///
    /// Any part of the object which intersects with the enabled layer will show as transparent by
    /// the given amount, and any which isn't will (if `enable_object()` was called) show
    /// as faded towards black / white.
    pub fn object_transparency(
        &mut self,
        top_fade_amount: Num<u8, 4>,
        bottom_fade_amount: Num<u8, 4>,
    ) -> BlendObjectTransparency<'_> {
        self.blend.set_layer_alpha(Layer::Top, top_fade_amount);
        self.blend
            .set_layer_alpha(Layer::Bottom, bottom_fade_amount);

        BlendObjectTransparency { blend: self.blend }
    }
}

/// Configure the fade effect for making objects optionally transparent.
///
/// Every object with the [`GraphicsMode`](crate::display::object::GraphicsMode) set to `AlphaBlending`
/// will have the same transparency level. Objects will only blend into backgrounds which have
/// been enabled via the [`enable_background`](BlendObjectTransparency::enable_background) method
/// called on them. Otherwise, the object will be rendered as-if there was no blending at all.
pub struct BlendObjectTransparency<'blend> {
    blend: &'blend mut Blend,
}

impl BlendObjectTransparency<'_> {
    /// Enables a given background to have transparent objects on top.
    ///
    /// The [`BackgroundId`] will likely come from a call to `show()`
    /// from either [regular backgrounds](crate::display::tiled::RegularBackground::show) or
    /// [affine backgrounds](crate::display::tiled::AffineBackground::show).
    pub fn enable_background(&mut self, background: impl Into<BackgroundId>) -> &mut Self {
        self.blend.set_background_enable(Layer::Bottom, background);
        self
    }
}

#[cfg(test)]
mod test {
    use super::*;
    use crate::{
        Gba,
        display::{
            AffineMatrix, Priority, WinIn,
            object::{AffineMatrixObject, AffineMode, GraphicsMode, Object, ObjectAffine},
            tiled::{
                AffineBackground, AffineBackgroundSize, AffineBackgroundWrapBehaviour,
                RegularBackground, RegularBackgroundSize, VRAM_MANAGER,
            },
        },
        fixnum::{Rect, num, vec2},
        include_aseprite, include_background_gfx,
        test_runner::assert_image_output,
    };

    include_background_gfx!(mod background,
        LOGO => deduplicate "gfx/test_logo.aseprite",
        LOGO_256 => 256 "gfx/test_logo.aseprite",
    );

    include_aseprite!(
        mod sprites,
        "examples/gfx/crab.aseprite",
    );

    #[test_case]
    fn can_blend_to_white(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = RegularBackground::new(
            Priority::P0,
            RegularBackgroundSize::Background32x32,
            background::LOGO.tiles.format(),
        );

        bg.fill_with(&background::LOGO);

        let mut frame = gfx.frame();
        let bg_id = bg.show(&mut frame);

        frame.blend().brighten(num!(0.5)).enable_background(bg_id);

        frame.commit();

        assert_image_output("gfx/test_output/blend/regular_to_white.png");
    }

    #[test_case]
    fn can_blend_to_white_in_window(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = RegularBackground::new(
            Priority::P0,
            RegularBackgroundSize::Background32x32,
            background::LOGO.tiles.format(),
        );

        bg.fill_with(&background::LOGO);

        let mut frame = gfx.frame();
        let bg_id = bg.show(&mut frame);

        frame.blend().brighten(num!(0.5)).enable_background(bg_id);
        frame
            .windows()
            .win_in(WinIn::Win0)
            .enable_background(bg_id)
            .enable_blending()
            .set_pos(Rect::new(vec2(20, 20), vec2(100, 100)));

        frame.windows.win_out().enable_background(bg_id);

        frame.commit();

        assert_image_output("gfx/test_output/blend/regular_to_white_in_window.png");
    }

    #[test_case]
    fn can_blend_two_layers_into_each_other(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = RegularBackground::new(
            Priority::P0,
            RegularBackgroundSize::Background32x32,
            background::LOGO.tiles.format(),
        );

        bg.fill_with(&background::LOGO);

        let mut frame = gfx.frame();
        let bg1_id = bg.show(&mut frame);

        bg.set_scroll_pos((40, 40));
        let bg2_id = bg.show(&mut frame);

        frame
            .blend()
            .alpha(num!(0.8), num!(0.2))
            .enable_background(Layer::Top, bg1_id)
            .enable_background(Layer::Bottom, bg2_id);

        frame.commit();

        assert_image_output("gfx/test_output/blend/blend_two_layers_into_each_other.png");
    }

    #[test_case]
    fn can_blend_affine_backgrounds(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = AffineBackground::new(
            Priority::P0,
            AffineBackgroundSize::Background32x32,
            AffineBackgroundWrapBehaviour::Wrap,
        );

        for i in 0..32 {
            for j in 0..32 {
                bg.set_tile(
                    (i, j),
                    &background::LOGO_256.tiles,
                    3 * 30 + 3 + (i + j) as u16 % 5,
                );
            }
        }

        bg.set_transform(AffineMatrix::from_rotation(num!(0.125)));

        let mut frame = gfx.frame();
        let bg_id = bg.show(&mut frame);

        frame.blend().darken(num!(0.5)).enable_background(bg_id);

        frame.commit();

        assert_image_output("gfx/test_output/blend/blend_affine_darken.png");
    }

    #[test_case]
    fn can_blend_objects_to_create_transparency_effects(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = RegularBackground::new(
            Priority::P0,
            RegularBackgroundSize::Background32x32,
            background::LOGO.tiles.format(),
        );

        bg.fill_with(&background::LOGO);

        let mut frame = gfx.frame();
        let bg_id = bg.show(&mut frame);

        frame
            .blend()
            .object_transparency(num!(0.5), num!(0.5))
            .enable_background(bg_id);

        Object::new(sprites::IDLE.sprite(0))
            .set_pos((100, 100))
            .set_graphics_mode(GraphicsMode::AlphaBlending)
            .show(&mut frame);

        frame.commit();

        assert_image_output("gfx/test_output/blend/blend_object_transparency.png");
    }

    #[test_case]
    fn can_blend_object_to_white(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = RegularBackground::new(
            Priority::P0,
            RegularBackgroundSize::Background32x32,
            background::LOGO.tiles.format(),
        );

        bg.fill_with(&background::LOGO);

        let mut frame = gfx.frame();
        bg.show(&mut frame);

        frame.blend().brighten(num!(0.5)).enable_object();

        Object::new(sprites::IDLE.sprite(0))
            .set_pos((100, 100))
            .set_graphics_mode(GraphicsMode::AlphaBlending)
            .show(&mut frame);

        frame.commit();

        assert_image_output("gfx/test_output/blend/blend_object_lighten.png");
    }

    #[test_case]
    fn can_blend_object_to_black(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = RegularBackground::new(
            Priority::P0,
            RegularBackgroundSize::Background32x32,
            background::LOGO.tiles.format(),
        );

        bg.fill_with(&background::LOGO);

        let mut frame = gfx.frame();
        bg.show(&mut frame);

        frame.blend().darken(num!(0.75)).enable_object();

        Object::new(sprites::IDLE.sprite(0))
            .set_pos((100, 100))
            .set_graphics_mode(GraphicsMode::AlphaBlending)
            .show(&mut frame);

        frame.commit();

        assert_image_output("gfx/test_output/blend/blend_object_darken.png");
    }

    #[test_case]
    fn can_blend_object_shape_to_black(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = RegularBackground::new(
            Priority::P0,
            RegularBackgroundSize::Background32x32,
            background::LOGO.tiles.format(),
        );

        bg.fill_with(&background::LOGO);

        let mut frame = gfx.frame();
        let bg_id = bg.show(&mut frame);

        frame.blend().darken(num!(0.75)).enable_background(bg_id);
        frame
            .windows()
            .win_obj()
            .enable_blending()
            .enable_background(bg_id);
        frame.windows().win_out().enable_background(bg_id);

        Object::new(sprites::IDLE.sprite(0))
            .set_pos((100, 100))
            .set_graphics_mode(GraphicsMode::Window)
            .show(&mut frame);

        frame.commit();

        assert_image_output("gfx/test_output/blend/blend_object_darken_window.png");
    }

    #[test_case]
    fn can_blend_affine_object_to_black(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = RegularBackground::new(
            Priority::P0,
            RegularBackgroundSize::Background32x32,
            background::LOGO.tiles.format(),
        );

        bg.fill_with(&background::LOGO);

        let mut frame = gfx.frame();
        bg.show(&mut frame);

        frame.blend().darken(num!(0.75)).enable_object();

        let matrix = AffineMatrixObject::from(AffineMatrix::from_rotation(num!(0.125)));

        ObjectAffine::new(sprites::IDLE.sprite(0), matrix, AffineMode::AffineDouble)
            .set_pos((100, 100))
            .set_graphics_mode(GraphicsMode::AlphaBlending)
            .show(&mut frame);

        frame.commit();

        assert_image_output("gfx/test_output/blend/blend_object_affine_darken.png");
    }

    #[test_case]
    fn can_fade_and_have_object_transparency(gba: &mut Gba) {
        VRAM_MANAGER.set_background_palettes(background::PALETTES);
        let mut gfx = gba.graphics.get();

        let mut bg = RegularBackground::new(
            Priority::P0,
            RegularBackgroundSize::Background32x32,
            background::LOGO.tiles.format(),
        );

        bg.fill_with(&background::LOGO);
        bg.set_scroll_pos((-116, -116));

        let mut frame = gfx.frame();
        let bg_id = bg.show(&mut frame);

        frame
            .blend()
            .darken(num!(0.75))
            .enable_object()
            .object_transparency(num!(0.5), num!(0.5))
            .enable_background(bg_id);

        Object::new(sprites::IDLE.sprite(0))
            .set_pos((100, 100))
            .set_graphics_mode(GraphicsMode::AlphaBlending)
            .show(&mut frame);

        frame.commit();

        assert_image_output("gfx/test_output/blend/blend_object_fade_transparent.png");
    }
}