コード例 #1
0
ファイル: RenderTarget.cs プロジェクト: pzaps/CrossGFX
 public void DrawString(Point position, IFont font, string text, int textSize, Color textColor,
     bool bold, bool italic, bool underline)
 {
     font.RenderText(this, position, text, textSize, textColor, bold, italic, underline);
 }
コード例 #2
0
ファイル: RenderTarget.cs プロジェクト: pzaps/CrossGFX
        public void DrawString(Point position, IFont font, string text, int textSize, Color textColor,
            bool bold, bool italic, bool underline)
        {
            if (newOrigin != Point.Empty) {
                DrawingSupport.Translate(newOrigin, ref position);
            }

            font.RenderText(this, position, text, textSize, textColor, bold, italic, underline);
        }
コード例 #3
0
ファイル: RenderTarget.cs プロジェクト: pzaps/CrossGFX
 public void DrawString(IFont font, string text, int textSize, global::System.Drawing.Color textColor, global::System.Drawing.Point position)
 {
     font.RenderText(text, textSize, textColor, this, position);
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: CloneDeath/SDL2
        private static void MainLoop(IRenderer renderer, IFont font, IEngine sdl)
        {
            var keepRunning = true;

            while (keepRunning)
            {
                for (var evt = sdl.PollEvent(); evt != null; evt = sdl.PollEvent())
                {
                    // ReSharper disable once SwitchStatementMissingSomeCases
                    switch (evt.Type)
                    {
                    case EventType.Quit:
                        keepRunning = false;
                        break;

                    case EventType.KeyDown:
                        Console.WriteLine(evt.Key.KeySymbol.Symbol);
                        break;

                    case EventType.KeyUp:
                        Console.WriteLine("-" + evt.Key.KeySymbol.Symbol);
                        break;

                    case EventType.MouseMotion:
                        Console.WriteLine(evt.Motion.DeltaX);
                        break;

                    case EventType.MouseButtonDown:
                        Console.WriteLine(evt.Button.Button + " " + evt.Button.Clicks);
                        break;

                    case EventType.MouseWheel:
                        Console.WriteLine(evt.Wheel.Y);
                        break;
                    }
                }
                renderer.DrawColor = Color.Black;
                renderer.Clear();

                renderer.DrawColor = Color.White;
                renderer.DrawRectangle(new Rectangle {
                    X      = 10,
                    Y      = 10,
                    Width  = 10,
                    Height = 10
                });
                using (var messageSurface = font.RenderText("Hello World", Color.Red))
                    using (var messageTexture = renderer.CreateTexture(messageSurface))
                    {
                        renderer.DrawTexture(messageTexture, Point.Empty);
                    }

                using (var messageSurface = font.RenderTextWrapped("Hello World", Color.Lime, 30))
                    using (var messageTexture = renderer.CreateTexture(messageSurface))
                    {
                        renderer.DrawTexture(messageTexture, new Point(0, 50));
                    }

                using (var giraffeTextureStream = GetGiraffeStream())
                    using (var giraffeTexture = renderer.LoadTexture(giraffeTextureStream)) {
                        giraffeTexture.BlendMode = SDL_BlendMode.Alpha;
                        giraffeTexture.DrawColor = Color.FromArgb(127, 31, 31, 255);
                        renderer.DrawTexture(giraffeTexture, new Point(0, 100));
                    }

                renderer.Present();

                sdl.Delay(TimeSpan.FromSeconds(1 / 60d));
            }
        }