Exemplo n.º 1
0
        /// <summary>
        /// Function to add a vertex to the polysprite.
        /// </summary>
        /// <param name="vertex">The vertex to add.</param>
        /// <returns>The fluent interface for this builder.</returns>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="vertex"/> is <b>null</b>.</exception>
        public GorgonPolySpriteBuilder AddVertex(GorgonPolySpriteVertex vertex)
        {
            if (vertex == null)
            {
                throw new ArgumentNullException(nameof(vertex));
            }

            _workingSprite.RwVertices.Add(vertex);
            return(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Function to insert a vertex at the specified index.
        /// </summary>
        /// <param name="index">The index to insert into.</param>
        /// <param name="vertex">The vertex to insert.</param>
        /// <returns>The fluent interface for the this builder.</returns>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name=" vertex"/> parameter is <b>null</b>.</exception>
        public GorgonPolySpriteBuilder InsertVertex(int index, GorgonPolySpriteVertex vertex)
        {
            if (vertex == null)
            {
                throw new ArgumentNullException(nameof(vertex));
            }

            _workingSprite.RwVertices.Insert(index, vertex);
            return(this);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Function to move the specified vertex to a new location in the list.
        /// </summary>
        /// <param name="vertex">The vertex to move.</param>
        /// <param name="newIndex">The new index for the vertex.</param>
        /// <returns>The fluent interface for the this builder.</returns>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="vertex"/> parameter is <b>null</b>.</exception>
        public GorgonPolySpriteBuilder MoveVertex(GorgonPolySpriteVertex vertex, int newIndex)
        {
            if (vertex == null)
            {
                throw new ArgumentNullException(nameof(vertex));
            }

            int index = _workingSprite.RwVertices.IndexOf(vertex);

            return(index == -1 ? this : MoveVertex(index, newIndex));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Function to move the vertex at the specified index to a new location in the list.
        /// </summary>
        /// <param name="oldIndex">The index of the vertex to move.</param>
        /// <param name="newIndex">The new index for the vertex.</param>
        /// <returns>The fluent interface for the this builder.</returns>
        public GorgonPolySpriteBuilder MoveVertex(int oldIndex, int newIndex)
        {
            oldIndex = oldIndex.Max(0).Min(_workingSprite.RwVertices.Count - 1);
            newIndex = newIndex.Max(0).Min(_workingSprite.RwVertices.Count);

            if (newIndex == oldIndex)
            {
                return(this);
            }

            GorgonPolySpriteVertex pass = _workingSprite.RwVertices[oldIndex];

            _workingSprite.RwVertices[oldIndex] = null;
            _workingSprite.RwVertices.Insert(newIndex, pass);
            _workingSprite.RwVertices.Remove(null);

            return(this);
        }