tangled
alpha
login
or
join now
keii.dev
/
osu-framework
A game framework written with osu! in mind.
0
fork
atom
overview
issues
pulls
pipelines
Fix triangle not supporting TextureRectangle
smoogipoo
5 years ago
e1ed23fc
e83c1726
+42
-27
2 changed files
expand all
collapse all
unified
split
osu.Framework
Graphics
Shapes
Triangle.cs
osu.Framework.Tests
Visual
Sprites
TestSceneWrapModes.cs
+41
-26
osu.Framework.Tests/Visual/Sprites/TestSceneWrapModes.cs
···
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
0
0
4
using osu.Framework.Allocation;
5
using osu.Framework.Graphics;
6
using osu.Framework.Graphics.Containers;
···
25
{
26
}
27
28
-
protected override void LoadComplete()
0
0
0
29
{
30
-
base.LoadComplete();
0
0
0
0
0
31
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
32
for (int i = 0; i < Rows; ++i)
33
{
34
for (int j = 0; j < Cols; ++j)
35
{
36
-
Cell(i, j).AddRange(new Drawable[]
37
{
38
new SpriteText
39
{
···
46
Size = new Vector2(0.5f),
47
Anchor = Anchor.Centre,
48
Origin = Anchor.Centre,
49
-
Children = new Drawable[]
50
{
51
-
new Sprite
52
{
53
-
RelativeSizeAxes = Axes.Both,
54
-
Size = Vector2.One,
55
-
Texture = textures[i * 4 + j],
56
-
Anchor = Anchor.Centre,
57
-
Origin = Anchor.Centre,
58
-
TextureRectangle = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f),
59
-
},
60
new Container
61
{
62
RelativeSizeAxes = Axes.Both,
···
74
}
75
}
76
}
77
-
});
78
}
79
}
80
-
}
81
-
82
-
private readonly Texture[] textures = new Texture[4 * 4];
83
-
84
-
[BackgroundDependencyLoader]
85
-
private void load(TextureStore store)
86
-
{
87
-
for (int i = 0; i < 4; ++i)
88
-
{
89
-
for (int j = 0; j < 4; ++j)
90
-
textures[i * 4 + j] = store.Get(@"sample-texture", wrapModes[i], wrapModes[j]);
91
-
}
92
-
}
93
}
94
}
···
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
4
+
using System;
5
+
using NUnit.Framework;
6
using osu.Framework.Allocation;
7
using osu.Framework.Graphics;
8
using osu.Framework.Graphics.Containers;
···
27
{
28
}
29
30
+
private readonly Texture[] textures = new Texture[4 * 4];
31
+
32
+
[BackgroundDependencyLoader]
33
+
private void load(TextureStore store)
34
{
35
+
for (int i = 0; i < 4; ++i)
36
+
{
37
+
for (int j = 0; j < 4; ++j)
38
+
textures[i * 4 + j] = store.Get(@"sample-texture", wrapModes[i], wrapModes[j]);
39
+
}
40
+
}
41
42
+
[Test]
43
+
public void TestSprites() => createTest(tex => new Sprite
44
+
{
45
+
Texture = tex,
46
+
TextureRectangle = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f),
47
+
});
48
+
49
+
[Test]
50
+
public void TestTriangles() => createTest(tex => new EquilateralTriangle
51
+
{
52
+
Texture = tex,
53
+
TextureRectangle = new RectangleF(0.25f, 0.25f, 0.5f, 0.5f),
54
+
});
55
+
56
+
[Test, Ignore("not implemented yet")]
57
+
public void TestVideos() => createTest(_ => new TestVideo());
58
+
59
+
private void createTest(Func<Texture, Drawable> creatorFunc) => AddStep("create test", () =>
60
+
{
61
for (int i = 0; i < Rows; ++i)
62
{
63
for (int j = 0; j < Cols; ++j)
64
{
65
+
Cell(i, j).Children = new Drawable[]
66
{
67
new SpriteText
68
{
···
75
Size = new Vector2(0.5f),
76
Anchor = Anchor.Centre,
77
Origin = Anchor.Centre,
78
+
Children = new[]
79
{
80
+
creatorFunc(textures[i * 4 + j]).With(d =>
81
{
82
+
d.RelativeSizeAxes = Axes.Both;
83
+
d.Size = Vector2.One;
84
+
d.Anchor = Anchor.Centre;
85
+
d.Origin = Anchor.Centre;
86
+
}),
0
0
87
new Container
88
{
89
RelativeSizeAxes = Axes.Both,
···
101
}
102
}
103
}
104
+
};
105
}
106
}
107
+
});
0
0
0
0
0
0
0
0
0
0
0
0
108
}
109
}
+1
-1
osu.Framework/Graphics/Shapes/Triangle.cs
···
44
protected override void Blit(Action<TexturedVertex2D> vertexAction)
45
{
46
DrawTriangle(Texture, toTriangle(ScreenSpaceDrawQuad), DrawColourInfo.Colour, null, null,
47
-
new Vector2(InflationAmount.X / DrawRectangle.Width, InflationAmount.Y / DrawRectangle.Height));
48
}
49
}
50
}
···
44
protected override void Blit(Action<TexturedVertex2D> vertexAction)
45
{
46
DrawTriangle(Texture, toTriangle(ScreenSpaceDrawQuad), DrawColourInfo.Colour, null, null,
47
+
new Vector2(InflationAmount.X / DrawRectangle.Width, InflationAmount.Y / DrawRectangle.Height), TextureCoords);
48
}
49
}
50
}