A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using NUnit.Framework;
5using osu.Framework.Graphics;
6using osu.Framework.Graphics.Containers;
7using osu.Framework.Graphics.Shapes;
8using osuTK;
9using osuTK.Graphics;
10
11namespace osu.Framework.Tests.Visual.Drawables
12{
13 public class TestSceneBlending : FrameworkTestScene
14 {
15 [Test]
16 public void TestBlendSelf()
17 {
18 Drawable blended = null;
19
20 AddStep("create test", () =>
21 {
22 Child = new Container
23 {
24 Size = new Vector2(200),
25 Children = new[]
26 {
27 new Box
28 {
29 RelativeSizeAxes = Axes.Both,
30 Colour = Color4.Orange
31 },
32 blended = new Box
33 {
34 Anchor = Anchor.Centre,
35 Origin = Anchor.Centre,
36 Size = new Vector2(50),
37 Alpha = 0.5f,
38 Blending = BlendingParameters.Additive
39 }
40 }
41 };
42 });
43
44 AddAssert("blended additively", () => blended.DrawColourInfo.Blending == BlendingParameters.Additive);
45 }
46
47 [Test]
48 public void TestBlendThroughMultipleParents()
49 {
50 Drawable blended = null;
51
52 AddStep("create test", () =>
53 {
54 Child = new Container
55 {
56 Size = new Vector2(200),
57 Children = new Drawable[]
58 {
59 new Box
60 {
61 RelativeSizeAxes = Axes.Both,
62 Colour = Color4.Orange
63 },
64 new Container
65 {
66 Anchor = Anchor.Centre,
67 Origin = Anchor.Centre,
68 Size = new Vector2(50),
69 Blending = BlendingParameters.Additive,
70 Child = new Container
71 {
72 RelativeSizeAxes = Axes.Both,
73 Child = blended = new Box
74 {
75 RelativeSizeAxes = Axes.Both,
76 Alpha = 0.5f,
77 }
78 }
79 }
80 }
81 };
82 });
83
84 AddAssert("blended additively", () => blended.DrawColourInfo.Blending == BlendingParameters.Additive);
85 }
86 }
87}