示例#1
0
        public void Draw(object texture, Vector2 position, Rectangle?sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, float depth)
        {
            var tex = (Texture2D)texture;

            _batch.Draw(tex,
                        position,
                        sourceRectangle,
                        color.ToTrippy(),
                        scale,
                        rotation,
                        origin,
                        depth);
        }
示例#2
0
        public void Draw(TextureBatcher textureBatcher)
        {
            for (int i = trail.Length - 1; i >= 0; i--)
            {
                byte alpha = (byte)(127 - i * 127 / trail.Length);
                textureBatcher.Draw(texture, trail[i], new Color4b(255, 255, 255, alpha));
            }

            textureBatcher.Draw(texture, position);

            for (int i = trail.Length - 1; i != 0; i--)
            {
                trail[i] = trail[i - 1];
            }
            trail[0] = position;
        }
        protected override void OnRender(double dt)
        {
            float time = (float)stopwatch.Elapsed.TotalSeconds;

            graphicsDevice.Clear(ClearBufferMask.ColorBufferBit);

            Vector2 mousePos = new Vector2(InputContext.Mice[0].Position.X, InputContext.Mice[0].Position.Y);

            textureBatcher.Begin(BatcherBeginMode.OnTheFly);

            float loreIpsumScale = 1 + 0.1f * MathF.Sin(time * 4.32f);

            textureBatcher.DrawString(arialFont, loremIpsum, new Vector2(50, 25), Color4b.White, loreIpsumScale, Vector2.Zero);

            string  comicText      = "You can draw text!!\nIt's very nice :)";
            Vector2 comicTextSize  = comicSansFont.Measure(comicText);
            Color4b comicTextColor = Color4b.FromHSV(time % 1, 1f, 1f);
            float   comicTextScale = 1 + 0.1f * MathF.Sin(time);
            float   comicTextRot   = 0.3f * MathF.Sin(time * 4.32f);

            textureBatcher.DrawString(comicSansFont, comicText, new Vector2(500, 610), comicTextColor, comicTextScale, comicTextRot, comicTextSize / 2f);

            foreach (Particle particle in particles)
            {
                particle.Draw(textureBatcher);
            }
            for (int i = 0; i < diamonds.Length; i++)
            {
                diamonds[i].Draw(textureBatcher);
            }
            for (int i = 0; i < balls.Length; i++)
            {
                balls[i].Draw(textureBatcher);
            }

            textureBatcher.End();


            textureBatcher.Begin(BatcherBeginMode.SortBackToFront);
            Vector2     rectOrigin = new Vector2(rectangleTexture.Width / 2f, rectangleTexture.Height / 2f);
            const float meh        = 100;
            const int   times      = 6;

            for (float x = -meh * times; x <= meh * times; x += meh)
            {
                for (float y = -meh * times; y <= meh * times; y += meh)
                {
                    float dist  = Math.Abs(x) + Math.Abs(y);
                    byte  alpha = (byte)Math.Max(0, 255 - (3f / times) * dist);
                    float dep   = dist / 500f;
                    float sc    = dist / meh * 0.175f;
                    sc = 1 - sc * sc;
                    Vector2 pos = mousePos + new Vector2(MathF.Sign(x), MathF.Sign(y)) * Vector2.SquareRoot(new Vector2(MathF.Abs(x), MathF.Abs(y)) / meh) * meh;
                    textureBatcher.Draw(rectangleTexture, pos, null, new Color4b(255, 255, 255, alpha), sc, time, rectOrigin, dep);
                }
            }
            textureBatcher.End();

            Window.SwapBuffers();
        }
示例#4
0
        protected override void OnRender(double dt)
        {
            graphicsDevice.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.DepthBufferBit);
            //			_desktop.Render();

            _batch.Begin();

            _batch.Draw(_white, new Vector2(0, 0), null, Color4b.Red, 100, 0);

            _batch.End();

            Window.SwapBuffers();
        }
示例#5
0
 public void Draw(TextureBatcher textureBatcher)
 {
     textureBatcher.Draw(texture, position, source, color, 5f, rotation, new Vector2(source.Width, source.Height) / 2f);
 }