// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osuTK; namespace osu.Framework.Graphics.Shapes { /// /// A triangle which has all side lengths and angles equal. /// public class EquilateralTriangle : Triangle { /// /// For equilateral triangles, height = cos(30) * sidelength = ~0.866 * sidelength. /// This is applied to the side length of the triangle to determine the height. /// private const float sidelength_to_height_factor = 0.866f; /// /// The size of this triangle. /// /// When setting the size, the Y-value is ignored (use if you desire a specific height instead). /// /// public override Vector2 Size => new Vector2(base.Size.X, base.Size.X * sidelength_to_height_factor); /// /// Sets the height of the triangle, adjusting the width as appropriate. /// public override float Height { get => Width * sidelength_to_height_factor; set => Size = new Vector2(value / sidelength_to_height_factor); } } }