当前位置: 首页>>代码示例>>C#>>正文


C# Renderer.StrokeAndFill方法代码示例

本文整理汇总了C#中Renderer.StrokeAndFill方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.StrokeAndFill方法的具体用法?C# Renderer.StrokeAndFill怎么用?C# Renderer.StrokeAndFill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Renderer的用法示例。


在下文中一共展示了Renderer.StrokeAndFill方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

 public override void Draw(Renderer renderer, Vector2 position, double direction, Cairo.Color? fillColor, Cairo.Color? strokeColor, double scale)
 {
     Context g = renderer.Context;
     g.MoveTo(position.ToPointD());
     g.LineTo(position.AddLengthDir(scale, MathHelper.PiOver2).ToPointD());
     g.LineTo(position.AddLengthDir(scale, MathHelper.PiOver4 * 9).ToPointD());
     g.ClosePath();
     renderer.StrokeAndFill(fillColor, strokeColor);
 }
开发者ID:adamrezich,项目名称:arena,代码行数:9,代码来源:Shapes.cs

示例2: Draw

        public static void Draw(GameTime gameTime, Renderer renderer, Player player)
        {
            Context g = renderer.Context;
            if (player == null)
                return;

            // SCOREBOARD
            int sbTop = 3;
            if (ScoreboardScale > 0) {
                renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), "HOME", 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, Config.HomeColor2, 0, "chunky");
                sbTop++;
                foreach (KeyValuePair<int, Player> kvp in Client.Local.Players) {
                    if (kvp.Value.Team == Teams.Home) {
                        renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), kvp.Value.Name.ToUpper(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
                        sbTop++;
                    }
                }
                renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), "AWAY", 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, Config.AwayColor2, 0, "chunky");
                sbTop++;
                foreach (KeyValuePair<int, Player> kvp in Client.Local.Players) {
                    if (kvp.Value.Team == Teams.Away) {
                        renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), kvp.Value.Name.ToUpper(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
                        sbTop++;
                    }
                }
            }

            // LEFT
            DrawBox(renderer, LeftBox, Arena.Config.HUDBackground, null);

            // health background
            g.MoveTo(new Vector2(0 + Margin, 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin + BarWidth), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2(0 + Margin, renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.ClosePath();
            renderer.StrokeAndFill(new Cairo.Color(0, 0, 0), null);

            // health foreground
            if (player.CurrentUnit != null) {
                g.MoveTo(new Vector2(0 + Margin, renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetHealthPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetHealthPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.LineTo(new Vector2(0 + Margin, renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.ClosePath();
                renderer.StrokeAndFill(new Cairo.Color(0, 128, 0), null);
            }

            // energy background
            g.MoveTo(new Vector2((float)(0 + Margin * 2 + BarWidth), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.ClosePath();
            renderer.StrokeAndFill(new Cairo.Color(0, 0, 0), null);

            // energy foreground
            if (player.CurrentUnit != null) {
                g.MoveTo(new Vector2((float)(0 + Margin * 2 + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetEnergyPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetEnergyPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.ClosePath();
                renderer.StrokeAndFill(new Cairo.Color(0, 0, 128), null);
            }

            // experience background
            g.MoveTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.ClosePath();
            renderer.StrokeAndFill(new Cairo.Color(0, 0, 0), null);

            // experience foreground
            if (player.CurrentUnit != null) {
                g.MoveTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetExperiencePercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetExperiencePercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.ClosePath();
                renderer.StrokeAndFill(new Cairo.Color(0, 128, 128), null);
            }

            // minimap
            DrawBox(renderer, MinimapBackground, new Cairo.Color(0, 0, 0), null);
            renderer.DrawText(MinimapBackground[0] + new Vector2((float)(MinimapSize / 2), (float)(MinimapSize / 2)), "MINIMAP", 14, TextAlign.Center, TextAlign.Middle, MainTextFill, MainTextStroke, null, 0, "chunky");

            // RIGHT
            DrawBox(renderer, RightBox, Arena.Config.HUDBackground, null);

            if (player.CurrentUnit != null) {
                DrawAbility(gameTime, renderer, player, 0);
                DrawAbility(gameTime, renderer, player, 2);
                DrawAbility(gameTime, renderer, player, 1);
                DrawAbility(gameTime, renderer, player, 3);
            }

            if (player.CurrentUnit != null) {
                renderer.DrawText(new Vector2(Margin, Margin), "MOVE SPEED: " + player.CurrentUnit.MoveSpeed.ToString(), 14, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
//.........这里部分代码省略.........
开发者ID:adamrezich,项目名称:arena,代码行数:101,代码来源:HUD.cs

示例3: DrawBox

 private static void DrawBox(Renderer renderer, List<Vector2> points, Cairo.Color? fillColor, Cairo.Color? strokeColor)
 {
     renderer.Context.MoveTo(points[0].ToPointD());
     renderer.Context.LineTo(points[1].ToPointD());
     renderer.Context.LineTo(points[2].ToPointD());
     renderer.Context.LineTo(points[3].ToPointD());
     renderer.Context.ClosePath();
     renderer.StrokeAndFill(fillColor, strokeColor);
 }
开发者ID:adamrezich,项目名称:arena,代码行数:9,代码来源:HUD.cs

示例4: DrawAbility

 private static void DrawAbility(GameTime gameTime, Renderer renderer, Player player, int ability)
 {
     Context g = renderer.Context;
     DrawBox(renderer, Ability[ability], new Cairo.Color(0, 0, 0), null);
     if (player.CurrentUnit.Abilities[ability].Ready || player.CurrentUnit.Abilities[ability].ActivationType == AbilityActivationType.Passive) {
         if (player.CurrentUnit.Abilities[ability].Level > 0)
             if (player.CurrentUnit.Energy >= player.CurrentUnit.Abilities[ability].EnergyCost && player.CurrentUnit.Abilities[ability].ActivationType != AbilityActivationType.Passive)
                 DrawBox(renderer, Ability[ability], new Cairo.Color(0, 0.9, 0), null);
             else
                 DrawBox(renderer, Ability[ability], new Cairo.Color(0.25, 0.5, 0.25), null);
         else
             DrawBox(renderer, Ability[ability], new Cairo.Color(0.1, 0.2, 0.1), null);
     }
     else {
         DrawBox(renderer, Ability[ability], new Cairo.Color(0, 0, 0.9), null);
         Vector2 timerCenter = Ability[ability][0] + new Vector2((float)AbilitySize / 2);
         g.MoveTo(timerCenter.ToPointD());
         double angle = Math.Max(0, MathHelper.TwoPi - (player.CurrentUnit.Abilities[ability].ReadyTime - gameTime.TotalGameTime).TotalMilliseconds / player.CurrentUnit.Abilities[ability].Cooldown / 25 / MathHelper.TwoPi);
         double adjustedAngle = angle - MathHelper.PiOver2;
         double flip = angle % MathHelper.PiOver2;
         if (flip > MathHelper.PiOver4) {
             flip -= MathHelper.PiOver2;
             flip = Math.Abs(flip);
         }
         g.LineTo(timerCenter.AddLengthDir(AbilitySize / 2 / Math.Cos(flip), adjustedAngle).ToPointD());
         if (angle > 7 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][0].ToPointD());
         if (angle > 5 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][3].ToPointD());
         if (angle > 3 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][2].ToPointD());
         if (angle > 1 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][1].ToPointD());
         g.LineTo(timerCenter.AddLengthDir(AbilitySize / 2, 3 * MathHelper.PiOver2).ToPointD());
         //g.LineTo(timerCenter.AddLengthDir(AbilitySize / 2, 3 * MathHelper.PiOver2).ToPointD());
         g.ClosePath();
         if (player.CurrentUnit.Energy >= player.CurrentUnit.Abilities[ability].EnergyCost)
             renderer.StrokeAndFill(new Cairo.Color(0, 0.5, 0), null);
         else
             renderer.StrokeAndFill(new Cairo.Color(0.25, 0.4, 0.25), null);
     }
     renderer.DrawText(Ability[ability][0] + new Vector2(Padding, Padding), player.CurrentUnit.Abilities[ability].Name.ToUpper(), 14, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, AbilityNameBackground, 0, "chunky");
     if (player.CurrentUnit.Abilities[ability].ActivationType != AbilityActivationType.Passive) {
         renderer.DrawText(Ability[ability][1] + new Vector2(-Padding, Padding), TemporaryKeyList[ability], 19, TextAlign.Right, TextAlign.Top, MainTextFill, MainTextStroke, AbilityKeyBackground, 0, "chunky");
         renderer.DrawText(Ability[ability][2] + new Vector2(-Padding, -Padding), player.CurrentUnit.Abilities[ability].Cooldown.ToString(), 14, TextAlign.Right, TextAlign.Bottom, MainTextFill, MainTextStroke, AbilityCooldownBackground, 0, "chunky");
         renderer.DrawText(Ability[ability][3] + new Vector2(Padding, -Padding), player.CurrentUnit.Abilities[ability].EnergyCost.ToString(), 14, TextAlign.Left, TextAlign.Bottom, MainTextFill, MainTextStroke, AbilityEnergyBackground, 0, "chunky");
     }
     if (!player.CurrentUnit.Abilities[ability].Ready && player.CurrentUnit.Abilities[ability].ActivationType != AbilityActivationType.Passive) {
         string str = Math.Round(((double)(player.CurrentUnit.Abilities[ability].ReadyTime - gameTime.TotalGameTime).TotalMilliseconds) / (double)1000, 1).ToString().MakeDecimal();
         renderer.DrawText(Ability[ability][0] + new Vector2((float)(AbilitySize / 2), (float)(AbilitySize / 2)), str, 32, TextAlign.Center, TextAlign.Middle, MainTextFill, MainTextStroke, null, 0, "chunky");
     }
     Vector2 levelOrigin = Ability[ability][1] + new Vector2(-Padding - LevelBoxSize, (float)((AbilitySize / 2) - (LevelBoxSize * player.CurrentUnit.Abilities[ability].Levels) / 2 - (LevelBoxPadding * (player.CurrentUnit.Abilities[ability].Levels) / 2) + LevelBoxPadding / 2));
     for (var i = 0; i < player.CurrentUnit.Abilities[ability].Levels; i++) {
         DrawBox(renderer, new List<Vector2>() {
             levelOrigin + new Vector2(0, LevelBoxSize * i + LevelBoxPadding * i),
             levelOrigin + new Vector2(LevelBoxSize, LevelBoxSize * i + LevelBoxPadding * i),
             levelOrigin + new Vector2(LevelBoxSize, LevelBoxSize * i + LevelBoxSize + LevelBoxPadding * i),
             levelOrigin + new Vector2(0, LevelBoxSize * i + LevelBoxSize + LevelBoxPadding * i)
         }, (player.CurrentUnit.Abilities[ability].Level >= i + 1 ? new Cairo.Color(1, 1, 1) : new Cairo.Color(0, 0, 0)), new Cairo.Color(1, 1, 1));
     }
 }
开发者ID:adamrezich,项目名称:arena,代码行数:61,代码来源:HUD.cs


注:本文中的Renderer.StrokeAndFill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。