Render() public static method

public static Render ( SystemManagers managers, SpriteRenderer spriteRenderer, IRenderableIpso ipso, Microsoft.Xna.Framework.Graphics.Texture2D texture ) : void
managers SystemManagers
spriteRenderer SpriteRenderer
ipso IRenderableIpso
texture Microsoft.Xna.Framework.Graphics.Texture2D
return void
コード例 #1
0
ファイル: SolidRectangle.cs プロジェクト: patridge/Gum
        void IRenderable.Render(SpriteRenderer spriteRenderer, SystemManagers managers)
        {
            if (this.AbsoluteVisible && this.Width > 0 && this.Height > 0)
            {
                Renderer renderer = null;
                if (managers == null)
                {
                    renderer = Renderer.Self;
                }
                else
                {
                    renderer = managers.Renderer;
                }

                var       texture    = renderer.SinglePixelTexture;
                Rectangle?sourceRect = renderer.SinglePixelSourceRectangle;
                if (mTexture != null)
                {
                    texture    = mTexture;
                    sourceRect = SinglePixelTextureSourceRectangle;
                }

                Sprite.Render(managers, spriteRenderer, this, texture, Color, sourceRect, false, this.GetAbsoluteRotation());
            }
        }
コード例 #2
0
        private void RenderUsingBitmapFont(SpriteRenderer spriteRenderer, SystemManagers managers)
        {
            if (mTempForRendering == null)
            {
                mTempForRendering = new LineRectangle(managers);
            }

            mTempForRendering.X      = this.X;
            mTempForRendering.Y      = this.Y;
            mTempForRendering.Width  = this.mTextureToRender.Width * mFontScale;
            mTempForRendering.Height = this.mTextureToRender.Height * mFontScale;

            //mTempForRendering.Parent = this.Parent;

            float widthDifference = this.EffectiveWidth - mTempForRendering.Width;

            if (this.HorizontalAlignment == Graphics.HorizontalAlignment.Center)
            {
                mTempForRendering.X += widthDifference / 2.0f;
            }
            else if (this.HorizontalAlignment == Graphics.HorizontalAlignment.Right)
            {
                mTempForRendering.X += widthDifference;
            }

            if (this.VerticalAlignment == Graphics.VerticalAlignment.Center)
            {
                mTempForRendering.Y += (this.EffectiveHeight - mTempForRendering.Height) / 2.0f;
            }
            else if (this.VerticalAlignment == Graphics.VerticalAlignment.Bottom)
            {
                mTempForRendering.Y += this.EffectiveHeight - mTempForRendering.Height;
            }

            if (this.Parent != null)
            {
                mTempForRendering.X += Parent.GetAbsoluteX();
                mTempForRendering.Y += Parent.GetAbsoluteY();
            }

            if (mBitmapFont?.AtlasedTexture != null)
            {
                mBitmapFont.RenderAtlasedTextureToScreen(mWrappedText, this.HorizontalAlignment, mTextureToRender.Height,
                                                         new Color(mRed, mGreen, mBlue, mAlpha), Rotation, mFontScale, managers, spriteRenderer, this);
            }
            else
            {
                Sprite.Render(managers, spriteRenderer, mTempForRendering, mTextureToRender,
                              new Color(mRed, mGreen, mBlue, mAlpha), null, false, false, Rotation, treat0AsFullDimensions: false,
                              objectCausingRenering: this);
            }
        }
コード例 #3
0
ファイル: NineSlice.cs プロジェクト: patridge/Gum
        void Render(Sprite sprite, SystemManagers managers, SpriteRenderer spriteRenderer)
        {
            var texture         = sprite.Texture;
            var sourceRectangle = sprite.EffectiveRectangle;

            if (sprite.AtlasedTexture != null)
            {
                texture = sprite.AtlasedTexture.Texture;
            }

            Sprite.Render(managers, spriteRenderer, sprite, texture, sprite.Color,
                          sourceRectangle, sprite.FlipVertical, sprite.Rotation, treat0AsFullDimensions: false);
        }
コード例 #4
0
        private void RenderUsingBitmapFont(SpriteRenderer spriteRenderer, SystemManagers managers)
        {
            UpdateIpsoForRendering();

            if (mBitmapFont?.AtlasedTexture != null)
            {
                mBitmapFont.RenderAtlasedTextureToScreen(mWrappedText, this.HorizontalAlignment, mTextureToRender.Height,
                                                         new Color(mRed, mGreen, mBlue, mAlpha), Rotation, mFontScale, managers, spriteRenderer, this);
            }
            else
            {
                Sprite.Render(managers, spriteRenderer, mTempForRendering, mTextureToRender,
                              new Color(mRed, mGreen, mBlue, mAlpha), null, false, false, Rotation, treat0AsFullDimensions: false,
                              objectCausingRenering: this);
            }
        }
コード例 #5
0
ファイル: SolidRectangle.cs プロジェクト: Aethere21/Pokamen
        void IRenderable.Render(SpriteBatch spriteBatch, SystemManagers managers)
        {
            if (this.AbsoluteVisible && this.Width > 0 && this.Height > 0)
            {
                Renderer renderer = null;
                if (managers == null)
                {
                    renderer = Renderer.Self;
                }
                else
                {
                    renderer = managers.Renderer;
                }

                Sprite.Render(managers, spriteBatch, this,
                              renderer.SinglePixelTexture,
                              this.Color, null, false, false, Rotation);
            }
        }
コード例 #6
0
        private void RenderUsingBitmapFont(SpriteBatch spriteBatch, SystemManagers managers)
        {
            if (mTempForRendering == null)
            {
                mTempForRendering = new LineRectangle(managers);
            }

            mTempForRendering.X      = this.X;
            mTempForRendering.Y      = this.Y;
            mTempForRendering.Width  = this.mTextureToRender.Width * mFontScale;
            mTempForRendering.Height = this.mTextureToRender.Height * mFontScale;
            mTempForRendering.Parent = this.Parent;

            float widthDifference = this.EffectiveWidth - mTempForRendering.Width;

            if (this.HorizontalAlignment == Graphics.HorizontalAlignment.Center)
            {
                mTempForRendering.X += widthDifference / 2.0f;
            }
            else if (this.HorizontalAlignment == Graphics.HorizontalAlignment.Right)
            {
                mTempForRendering.X += widthDifference;
            }

            if (this.VerticalAlignment == Graphics.VerticalAlignment.Center)
            {
                mTempForRendering.Y += (this.EffectiveHeight - mTextureToRender.Height) / 2.0f;
            }
            else if (this.VerticalAlignment == Graphics.VerticalAlignment.Bottom)
            {
                mTempForRendering.Y += this.EffectiveHeight - mTempForRendering.Height;
            }

            Sprite.Render(managers, spriteBatch, mTempForRendering, mTextureToRender,
                          new Color(mRed, mGreen, mBlue, mAlpha), null, false, false, Rotation, treat0AsFullDimensions: false);
        }
コード例 #7
0
        /// <summary>
        /// Used for rendering directly to screen with an atlased texture.
        /// </summary>
        public void RenderAtlasedTextureToScreen(List <string> lines, HorizontalAlignment horizontalAlignment,
                                                 float textureToRenderHeight, Color color, float rotation, float fontScale, SystemManagers managers, SpriteRenderer spriteRenderer,
                                                 object objectRequestingChange)
        {
            var        textObject = (Text)objectRequestingChange;
            var        point      = new Point();
            int        requiredWidth;
            int        requiredHeight;
            List <int> widths = new List <int>();

            GetRequiredWidthAndHeight(lines, out requiredWidth, out requiredHeight, widths);

            int lineNumber = 0;

            if (mCharRect == null)
            {
                mCharRect = new LineRectangle(managers);
            }

            var yoffset = 0f;

            if (textObject.VerticalAlignment == Graphics.VerticalAlignment.Center)
            {
                yoffset = (textObject.EffectiveHeight - textureToRenderHeight) / 2.0f;
            }
            else if (textObject.VerticalAlignment == Graphics.VerticalAlignment.Bottom)
            {
                yoffset = textObject.EffectiveHeight - textureToRenderHeight * fontScale;
            }

            foreach (string line in lines)
            {
                // scoot over to leave room for the outline
                point.X = mOutlineThickness;

                if (horizontalAlignment == HorizontalAlignment.Right)
                {
                    point.X = (int)(textObject.Width - widths[lineNumber] * fontScale);
                }
                else if (horizontalAlignment == HorizontalAlignment.Center)
                {
                    point.X = (int)(textObject.Width - widths[lineNumber] * fontScale) / 2;
                }

                foreach (char c in line)
                {
                    Rectangle destRect;
                    int       pageIndex;
                    var       sourceRect = GetCharacterRect(c, lineNumber, ref point, out destRect, out pageIndex, textObject.FontScale);

                    var origin = new Point((int)textObject.X, (int)(textObject.Y + yoffset));
                    var rotate = (float)-(textObject.Rotation * System.Math.PI / 180f);

                    var rotatingPoint = new Point(origin.X + destRect.X, origin.Y + destRect.Y);
                    MathFunctions.RotatePointAroundPoint(new Point(origin.X, origin.Y), ref rotatingPoint, rotate);

                    mCharRect.X      = rotatingPoint.X;
                    mCharRect.Y      = rotatingPoint.Y;
                    mCharRect.Width  = destRect.Width;
                    mCharRect.Height = destRect.Height;

                    if (textObject.Parent != null)
                    {
                        mCharRect.X += textObject.Parent.GetAbsoluteX();
                        mCharRect.Y += textObject.Parent.GetAbsoluteY();
                    }

                    Sprite.Render(managers, spriteRenderer, mCharRect, mTextures[0], color, sourceRect, false, false, rotation,
                                  treat0AsFullDimensions: false, objectCausingRenering: objectRequestingChange);
                }
                point.X = 0;
                lineNumber++;
            }
        }
コード例 #8
0
ファイル: NineSlice.cs プロジェクト: jiailiuyan/Gum
 void Render(Sprite sprite, SystemManagers managers, SpriteBatch spriteBatch)
 {
     Sprite.Render(managers, spriteBatch, sprite, sprite.Texture, sprite.Color,
                   sprite.SourceRectangle, sprite.FlipHorizontal, sprite.FlipVertical, sprite.Rotation, treat0AsFullDimensions: false);
 }