コード例 #1
0
ファイル: ColoredRegion.cs プロジェクト: haryck/Myra
        public void Draw(RenderContext context, Rectangle dest, Color color)
        {
            if (color == Color.White)
            {
                TextureRegion.Draw(context, dest, Color);
            }
            else
            {
                var c = ColorStorage.CreateColor((int)(Color.R * color.R / 255.0f),
                                                 (int)(Color.G * color.G / 255.0f),
                                                 (int)(Color.B * color.B / 255.0f),
                                                 (int)(Color.A * color.A / 255.0f));

                TextureRegion.Draw(context, dest, c);
            }
        }
コード例 #2
0
ファイル: ColoredRegion.cs プロジェクト: xvwvx/Myra
        public void Draw(SpriteBatch batch, Rectangle dest, Color color)
        {
            if (color == Color.White)
            {
                TextureRegion.Draw(batch, dest, Color);
            }
            else
            {
                var c = new Color((int)(Color.R * color.R / 255.0f),
                                  (int)(Color.G * color.G / 255.0f),
                                  (int)(Color.B * color.B / 255.0f),
                                  (int)(Color.A * color.A / 255.0f));

                TextureRegion.Draw(batch, dest, c);
            }
        }
コード例 #3
0
        public override void Draw(SpriteBatch batch, Rectangle dest, Color color)
        {
            var y = dest.Y;

            var centerWidth  = dest.Width - _info.Left - _info.Right;
            var centerHeight = dest.Height - _info.Top - _info.Bottom;

            if (_topLeft != null)
            {
                _topLeft.Draw(batch,
                              new Rectangle(dest.X,
                                            y,
                                            _info.Left,
                                            _info.Top),
                              color);
            }

            if (_topCenter != null)
            {
                _topCenter.Draw(batch,
                                new Rectangle(dest.X + _info.Left,
                                              y,
                                              centerWidth,
                                              _info.Top),
                                color);
            }

            if (_topRight != null)
            {
                _topRight.Draw(batch,
                               new Rectangle(dest.X + Info.Left + centerWidth,
                                             y,
                                             _info.Right,
                                             _info.Top),
                               color);
            }

            y += _info.Top;
            if (_centerLeft != null)
            {
                _centerLeft.Draw(batch,
                                 new Rectangle(dest.X,
                                               y,
                                               _info.Left,
                                               centerHeight),
                                 color);
            }

            if (_center != null)
            {
                _center.Draw(batch,
                             new Rectangle(dest.X + _info.Left,
                                           y,
                                           centerWidth,
                                           centerHeight),
                             color);
            }

            if (_centerRight != null)
            {
                _centerRight.Draw(batch,
                                  new Rectangle(dest.X + Info.Left + centerWidth,
                                                y,
                                                _info.Right,
                                                centerHeight),
                                  color);
            }

            y += centerHeight;
            if (_bottomLeft != null)
            {
                _bottomLeft.Draw(batch,
                                 new Rectangle(dest.X,
                                               y,
                                               _info.Left,
                                               _info.Bottom),
                                 color);
            }

            if (_bottomCenter != null)
            {
                _bottomCenter.Draw(batch,
                                   new Rectangle(dest.X + _info.Left,
                                                 y,
                                                 centerWidth,
                                                 _info.Bottom),
                                   color);
            }

            if (_bottomRight != null)
            {
                _bottomRight.Draw(batch,
                                  new Rectangle(dest.X + Info.Left + centerWidth,
                                                y,
                                                _info.Right,
                                                _info.Bottom),
                                  color);
            }
        }