コード例 #1
0
ファイル: SpriteBatch.cs プロジェクト: keppelcao/LGame
        public void Draw(LTexture texture, float dstX, float dstY, float dstWidth,
                float dstHeight, float srcX, float srcY, float srcWidth,
                float srcHeight, LColor c, float rotation, float originX,
                float originY, SpriteEffects effects)
        {
            if (effects == SpriteEffects.None && rotation == 0 && originX == 0
                    && originY == 0)
            {
                Draw(texture, dstX, dstY, dstWidth, dstHeight, srcX, srcY,
                        srcWidth, srcHeight, c);
                return;
            }
            uint old = GetIntColor();

            SetColor(c);

            bool flipX = false;
            bool flipY = false;
            switch (effects._code)
            {
                case 1:
                    flipX = true;
                    break;
                case 2:
                    flipY = true;
                    break;
                default:
                    break;
            }
            Draw(texture, dstX, dstY, originX, originY, dstWidth, dstHeight, 1f,
                    1f, rotation, srcX, srcY, srcWidth, srcHeight, flipX, flipY,
                    true);
            SetColor(old);
        }
コード例 #2
0
ファイル: SpriteBatch.cs プロジェクト: keppelcao/LGame
        public void Draw(LTexture texture, Vector2f position, float srcX,
                float srcY, float srcWidth, float srcHeight, LColor c,
                float rotation, Vector2f origin, Vector2f scale,
                SpriteEffects effects)
        {
            uint old = GetIntColor();

            SetColor(c);

            bool flipX = false;
            bool flipY = false;
            switch (effects._code)
            {
                case 1:
                    flipX = true;
                    break;
                case 2:
                    flipY = true;
                    break;
                default:
                    break;
            }
            Draw(texture, position.x, position.y, origin.x, origin.y, srcWidth,
                    srcHeight, scale.x, scale.y, rotation, srcX, srcY, srcWidth,
                    srcHeight, flipX, flipY, true);
            SetColor(old);
        }
コード例 #3
0
ファイル: SpriteBatch.cs プロジェクト: keppelcao/LGame
        public void Draw(LTexture texture, RectBox dst, RectBox src, LColor c,
                float rotation, Vector2f origin, SpriteEffects effects)
        {
            uint old = GetIntColor();

            SetColor(c);

            bool flipX = false;
            bool flipY = false;
            switch (effects._code)
            {
                case 1:
                    flipX = true;
                    break;
                case 2:
                    flipY = true;
                    break;
                default:
                    break;
            }
            if (src != null)
            {
                Draw(texture, dst.x, dst.y, origin.x, origin.y, dst.width,
                        dst.height, 1f, 1f, rotation, src.x, src.y, src.width,
                        src.height, flipX, flipY, true);
            }
            else
            {
                Draw(texture, dst.x, dst.y, origin.x, origin.y, dst.width,
                        dst.height, 1f, 1f, rotation, 0, 0, texture.Width,
                        texture.Height, flipX, flipY, true);
            }
            SetColor(old);
        }
コード例 #4
0
ファイル: SpriteBatch.cs プロジェクト: keppelcao/LGame
        public void Draw(LTexture texture, float px, float py, RectBox src,
                LColor c, float rotation, float ox, float oy, float scaleX,
                float scaleY, SpriteEffects effects)
        {
            uint old = GetIntColor();

            SetColor(c);

            bool flipX = false;
            bool flipY = false;
            switch (effects._code)
            {
                case 1:
                    flipX = true;
                    break;
                case 2:
                    flipY = true;
                    break;
                default:
                    break;
            }
            if (src != null)
            {
                Draw(texture, px, py, ox, oy, src.width, src.height, scaleX,
                        scaleY, rotation, src.x, src.y, src.width, src.height,
                        flipX, flipY, true);
            }
            else
            {
                Draw(texture, px, py, ox, oy, texture.Width,
                        texture.Height, scaleX, scaleY, rotation, 0, 0,
                        texture.Width, texture.Height, flipX, flipY, true);
            }
            SetColor(old);
        }
コード例 #5
0
ファイル: SpriteBatch.cs プロジェクト: keppelcao/LGame
        public void Draw(LTexture texture, float posX, float posY, float srcX,
                float srcY, float srcWidth, float srcHeight, LColor c,
                float rotation, float originX, float originY, float scaleX,
                float scaleY, SpriteEffects effects)
        {
            uint old = GetIntColor();

            SetColor(c);

            bool flipX = false;
            bool flipY = false;
            switch (effects._code)
            {
                case 1:
                    flipX = true;
                    break;
                case 2:
                    flipY = true;
                    break;
                default:
                    break;
            }
            Draw(texture, posX, posY, originX, originY, srcWidth, srcHeight,
                    scaleX, scaleY, rotation, srcX, srcY, srcWidth, srcHeight,
                    flipX, flipY, true);
            SetColor(old);
        }
コード例 #6
0
ファイル: SpriteBatch.cs プロジェクト: keppelcao/LGame
 public void Draw(LTexture texture, float px, float py, RectBox src,
         LColor c, float rotation, float ox, float oy, float scale,
         SpriteEffects effects)
 {
     Draw(texture, px, py, src, c, rotation, ox, oy, scale, scale, effects);
 }
コード例 #7
0
ファイル: SpriteBatch.cs プロジェクト: keppelcao/LGame
 public void Draw(LTexture texture, float px, float py, RectBox src,
         LColor c, float rotation, Vector2f origin, float scale,
         SpriteEffects effects)
 {
     Draw(texture, px, py, src, c, rotation, origin.x, origin.y, scale,
             effects);
 }
コード例 #8
0
ファイル: SpriteBatch.cs プロジェクト: keppelcao/LGame
        public void Draw(LTexture texture, Vector2f position, RectBox src,
                LColor c, float rotation, float sx, float sy, float scale,
                SpriteEffects effects)
        {

            if (src == null && rotation == 0 && scale == 1f && sx == 0 && sy == 0)
            {
                Draw(texture, position, c);
                return;
            }

            uint old = GetIntColor();
            SetColor(c);
            bool flipX = false;
            bool flipY = false;
            switch (effects._code)
            {
                case 1:
                    flipX = true;
                    break;
                case 2:
                    flipY = true;
                    break;
                default:
                    break;
            }
            if (src != null)
            {
                Draw(texture, position.x, position.y, sx, sy, src.width,
                        src.height, scale, scale, rotation, src.x, src.y,
                        src.width, src.height, flipX, flipY, true);
            }
            else
            {
                Draw(texture, position.x, position.y, sx, sy, texture.Width,
                        texture.Height, scale, scale, rotation, 0, 0,
                        texture.Width, texture.Height, flipX, flipY, true);
            }
            SetColor(old);
        }
コード例 #9
0
ファイル: SpriteBatch.cs プロジェクト: keppelcao/LGame
        /**
         * Sample:
         * batch.Draw(font, "Test", new Vector2f(150, 150), LColor.red, 0,
                     Vector2f.Zero, new Vector2f(1f, 1f), SpriteEffects.None);
				
         * @param font
         * @param cs
         * @param local
         * @param color
         * @param rotation
         * @param origin
         * @param scale
         * @param spriteEffects
         */
        public void Draw(SpriteFont font, string cs, Vector2f local,
                LColor color, float rotation, Vector2f origin, Vector2f scale,
                SpriteEffects spriteEffects)
        {
            font.DrawString(this, cs, local, color, rotation, origin, scale,
                    spriteEffects);
        }
コード例 #10
0
ファイル: SpriteFont.cs プロジェクト: darragh-murphy/LGame
 protected internal void DrawString(SpriteBatch batch, string cs,
         Vector2f local, LColor color, float rotation, Vector2f origin,
         Vector2f scale, SpriteEffects spriteEffects)
 {
     pos.Set(0, 0);
     int flip = 1;
     float beginningofline = 0f;
     bool flag = true;
     if (spriteEffects == SpriteEffects.FlipHorizontally)
     {
         beginningofline = this.Measure(cs).x * scale.x;
         flip = -1;
     }
     if (spriteEffects == SpriteEffects.FlipVertically)
     {
         pos.y = (this.Measure(cs).y - this.lineSpacing) * scale.y;
     }
     else
     {
         pos.y = 0f;
     }
     pos.x = beginningofline;
     for (int i = 0; i < cs.Length; i++)
     {
         char character = cs[i];
         switch ((int)character)
         {
             case '\r':
                 break;
             case '\n':
                 flag = true;
                 pos.x = beginningofline;
                 if (spriteEffects == SpriteEffects.FlipVertically)
                 {
                     pos.y -= this.lineSpacing * scale.y;
                 }
                 else
                 {
                     pos.y += this.lineSpacing * scale.y;
                 }
                 break;
             default:
                 {
                     int indexForCharacter = this.CharacterIndex(character);
                     float[] charkerning = this.kerning[indexForCharacter];
                     if (flag)
                     {
                         charkerning[0] = Math.Max(charkerning[0], 0f);
                     }
                     else
                     {
                         pos.x += (this.spacing * scale.x) * flip;
                     }
                     pos.x += (charkerning[0] * scale.x) * flip;
                     RectBox rectangle = this.glyphs[indexForCharacter];
                     RectBox rectangle2 = this.cropping[indexForCharacter];
                     Vector2f position = pos.Cpy();
                     position.x += rectangle2.x * scale.x;
                     position.y += rectangle2.y * scale.y;
                     position.AddLocal(local);
                     batch.Draw(this.texture, position, rectangle, color, rotation,
                             origin, scale, spriteEffects);
                     flag = false;
                     pos.x += ((charkerning[1] + charkerning[2]) * scale.x) * flip;
                     break;
                 }
         }
     }
 }