Beispiel #1
0
        /// <summary>
        /// Function to create a new triangle object.
        /// </summary>
        /// <param name="name">Name of the triangle.</param>
        /// <param name="point1">First point in the triangle.</param>
        /// <param name="point2">Second point in the triangle.</param>
        /// <param name="point3">Third point in the triangle.</param>
        /// <param name="filled">TRUE to create a filled triangle, FALSE to create an unfilled triangle.</param>
        /// <returns>A new triangle primitive object.</returns>
        /// <remarks>The points defined in the triangle use relative coordinates, and are offset from an origin that is defined by the <see cref="P:GorgonLibrary.Renderers.GorgonTriangle.Anchor">Anchor</see> property.</remarks>
        /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="name"/> parameter is NULL (Nothing in VB.Net).</exception>
        /// <exception cref="System.ArgumentException">Thrown when the name parameter is an empty string.</exception>
        public GorgonTriangle CreateTriangle(string name, GorgonPolygonPoint point1, GorgonPolygonPoint point2, GorgonPolygonPoint point3, bool filled)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException(Resources.GOR2D_PARAMETER_MUST_NOT_BE_EMPTY, "name");
            }

            var result = new GorgonTriangle(_gorgon2D, name)
            {
                IsFilled = filled
            };

            result.SetPoint(0, point1);
            result.SetPoint(1, point2);
            result.SetPoint(2, point3);

            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// Function to draw a filled triangle.
 /// </summary>
 /// <param name="position">Position of the triangle.</param>
 /// <param name="point1">First point in the triangle.</param>
 /// <param name="point2">Second point in the triangle.</param>
 /// <param name="point3">Third point in the triangle.</param>
 /// <param name="texture">Texture to apply to the triangle.</param>
 public void FilledTriangle(Vector2 position, GorgonPolygonPoint point1, GorgonPolygonPoint point2, GorgonPolygonPoint point3, GorgonTexture2D texture)
 {
     SetStates(_triangle);
     _triangle.IsFilled = true;
     _triangle.Position = position;
     _triangle.SetPoint(0, point1);
     _triangle.SetPoint(1, point2);
     _triangle.SetPoint(2, point3);
     _triangle.Texture       = texture;
     _triangle.LineThickness = new Vector2(1.0f);
     _triangle.Draw();
 }