2022-11-16 19:53:55 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
using osu.Game.Graphics.Backgrounds;
|
2022-11-30 09:09:46 +08:00
|
|
|
using osu.Framework.Graphics.Colour;
|
2023-01-26 14:46:41 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
2022-11-16 19:53:55 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Background
|
|
|
|
{
|
2022-11-26 23:30:10 +08:00
|
|
|
public partial class TestSceneTrianglesV2Background : OsuTestScene
|
2022-11-16 19:53:55 +08:00
|
|
|
{
|
2022-11-16 20:17:50 +08:00
|
|
|
private readonly TrianglesV2 triangles;
|
2023-01-26 14:46:41 +08:00
|
|
|
private readonly TrianglesV2 maskedTriangles;
|
2022-11-30 10:12:26 +08:00
|
|
|
private readonly Box box;
|
2022-11-16 20:17:50 +08:00
|
|
|
|
2022-11-16 19:53:55 +08:00
|
|
|
public TestSceneTrianglesV2Background()
|
|
|
|
{
|
|
|
|
AddRange(new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Gray
|
|
|
|
},
|
2022-11-30 10:12:26 +08:00
|
|
|
new FillFlowContainer
|
2022-11-16 19:53:55 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-11-30 10:12:26 +08:00
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Direction = FillDirection.Vertical,
|
2023-01-26 14:46:41 +08:00
|
|
|
Spacing = new Vector2(0, 10),
|
2022-11-23 21:12:13 +08:00
|
|
|
Children = new Drawable[]
|
2022-11-16 19:53:55 +08:00
|
|
|
{
|
2023-01-26 14:46:41 +08:00
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Text = "Masked"
|
|
|
|
},
|
2022-11-30 10:12:26 +08:00
|
|
|
new Container
|
2022-11-23 21:12:13 +08:00
|
|
|
{
|
2022-11-30 10:12:26 +08:00
|
|
|
Size = new Vector2(500, 100),
|
2023-01-26 14:46:41 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-11-30 10:12:26 +08:00
|
|
|
Masking = true,
|
|
|
|
CornerRadius = 40,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Red
|
|
|
|
},
|
|
|
|
triangles = new TrianglesV2
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
}
|
|
|
|
}
|
2022-11-23 21:12:13 +08:00
|
|
|
},
|
2023-01-26 14:46:41 +08:00
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Text = "Non-masked"
|
|
|
|
},
|
|
|
|
new Container
|
|
|
|
{
|
|
|
|
Size = new Vector2(500, 100),
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4.Red
|
|
|
|
},
|
|
|
|
maskedTriangles = new TrianglesV2
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Text = "Gradient comparison box"
|
|
|
|
},
|
2022-11-30 10:12:26 +08:00
|
|
|
new Container
|
2022-11-23 21:12:13 +08:00
|
|
|
{
|
2022-11-30 10:12:26 +08:00
|
|
|
Size = new Vector2(500, 100),
|
2023-01-26 14:46:41 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2022-11-30 10:12:26 +08:00
|
|
|
Masking = true,
|
|
|
|
CornerRadius = 40,
|
|
|
|
Child = box = new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
}
|
2022-11-23 21:12:13 +08:00
|
|
|
}
|
2022-11-16 19:53:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-11-16 20:17:50 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-11-30 10:12:26 +08:00
|
|
|
AddSliderStep("Spawn ratio", 0f, 10f, 1f, s =>
|
2022-11-30 09:02:35 +08:00
|
|
|
{
|
2023-01-26 14:46:41 +08:00
|
|
|
triangles.SpawnRatio = maskedTriangles.SpawnRatio = s;
|
2022-11-30 09:02:35 +08:00
|
|
|
triangles.Reset(1234);
|
2023-01-26 14:46:41 +08:00
|
|
|
maskedTriangles.Reset(1234);
|
2022-11-30 09:02:35 +08:00
|
|
|
});
|
2023-01-26 14:46:41 +08:00
|
|
|
AddSliderStep("Thickness", 0f, 1f, 0.02f, t => triangles.Thickness = maskedTriangles.Thickness = t);
|
2022-11-30 09:17:37 +08:00
|
|
|
|
2023-01-26 14:46:41 +08:00
|
|
|
AddStep("White colour", () => box.Colour = triangles.Colour = maskedTriangles.Colour = Color4.White);
|
|
|
|
AddStep("Vertical gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientVertical(Color4.White, Color4.Red));
|
|
|
|
AddStep("Horizontal gradient", () => box.Colour = triangles.Colour = maskedTriangles.Colour = ColourInfo.GradientHorizontal(Color4.White, Color4.Red));
|
|
|
|
AddToggleStep("Masking", m => maskedTriangles.Masking = m);
|
2022-11-16 20:17:50 +08:00
|
|
|
}
|
2022-11-16 19:53:55 +08:00
|
|
|
}
|
|
|
|
}
|