Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonDrawing"/> class.
        /// </summary>
        /// <param name="gorgon2D">The gorgon 2D interface that owns this object.</param>
        internal GorgonDrawing(Gorgon2D gorgon2D)
        {
            _depthStencil = new GorgonRenderable.DepthStencilStates();
            _sampler      = new GorgonRenderable.TextureSamplerState();
            _blend        = new GorgonRenderable.BlendState();

            // Default to modulated blending for drawing operations.
            BlendingMode = BlendingMode.Modulate;

            CullingMode = CullingMode.Back;

            _rect = new GorgonRectangle(gorgon2D, "Gorgon2D.Rectangle", false)
            {
                Position = Vector2.Zero,
                Size     = Vector2.Zero
            };
            _point = new GorgonPoint(gorgon2D, "Gorgon2D.Point")
            {
                Position = Vector2.Zero,
                Color    = GorgonColor.White
            };
            _line = new GorgonLine(gorgon2D, "Gorgon2D.Line")
            {
                Color      = GorgonColor.White,
                StartPoint = Vector2.Zero,
                EndPoint   = Vector2.Zero
            };
            _ellipse = new GorgonEllipse(gorgon2D, "Gorgon2D.Ellipse")
            {
                Quality = 64,
                Color   = GorgonColor.White
            };
            _triangle = new GorgonTriangle(gorgon2D,
                                           "Gorgon2D.Triangle")
            {
                IsFilled = false
            };
            _string = gorgon2D.Renderables.CreateText("Gorgon2D.String");
        }
Example #2
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);
        }