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


C# Renderer.SetColor方法代码示例

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


在下文中一共展示了Renderer.SetColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
     if (strokeColor.HasValue) {
         g.MoveTo(position.ToPointD());
         g.LineTo(position.AddLengthDir(Distance, direction).ToPointD());
         renderer.SetColor((Cairo.Color)strokeColor);
         g.Stroke();
     }
 }
开发者ID:adamrezich,项目名称:arena,代码行数:10,代码来源:Shapes.cs

示例2: Draw

 public void Draw(Renderer renderer)
 {
     int polys = 0;
     Context g = renderer.Context;
     int padding = 32;
     VGame.Rectangle r = new VGame.Rectangle((int)Math.Round(Client.Local.ViewOrigin.X) - padding, (int)Math.Round(Client.Local.ViewOrigin.Y) - padding, Client.Local.Game.Renderer.Width + 2 * padding, Client.Local.Game.Renderer.Height + 2 * padding);
     double scale = renderer.GetUnitSize();
     foreach (Polygon p in Terrain) {
         Polygon sp = p.ScaleAndOffset(scale, -Client.Local.ViewPosition + Client.Local.ViewOrigin);
         bool draw = false;
         foreach (Line l in sp.Lines) {
             if (r.IntersectsLine(new Vector2((float)(l.Point1.X), (float)(l.Point1.Y)), new Vector2((float)(l.Point2.X), (float)(l.Point2.Y)))) {
                 draw = true;
                 break;
             }
         }
         if (draw || sp.Contains(r)) {
             p.Draw(renderer, -Client.Local.ViewPosition + Client.Local.ViewOrigin, scale);
             polys++;
         }
         /*g.MoveTo(r.X, r.Y);
         g.LineTo(r.X + r.Width, r.Y);
         g.LineTo(r.X + r.Width, r.Y + r.Height);
         g.LineTo(r.X, r.Y + r.Height);
         g.ClosePath();
         renderer.StrokeAndFill(new Color(0.2, 0.5, 0.2, 0.5), new Color(0.2, 0.5, 0.2, 0.25));*/
     }
     foreach (Tuple<Line, Color> t in Decorations) {
         if (r.IntersectsLine(t.Item1.Point1, t.Item1.Point2)) {
             g.MoveTo((new Vector2((float)(t.Item1.Point1.X * scale), (float)(t.Item1.Point1.Y * scale)) - Client.Local.ViewPosition + Client.Local.ViewOrigin).ToPointD());
             g.LineTo((new Vector2((float)(t.Item1.Point2.X * scale), (float)(t.Item1.Point2.Y * scale)) - Client.Local.ViewPosition + Client.Local.ViewOrigin).ToPointD());
             renderer.SetColor(new Color(t.Item2.R, t.Item2.G, t.Item2.B, 0.4));
             g.Stroke();
         }
     }
     //renderer.DrawText(Client.Local.ViewOrigin, string.Format("polys: {0}", polys), 20, TextAlign.Left, TextAlign.Top, ColorPresets.White, ColorPresets.Black, null, 0, null);
 }
开发者ID:adamrezich,项目名称:arena,代码行数:37,代码来源:Pitch.cs

示例3: DrawUIBelow

        public void DrawUIBelow(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
        {
            Vector2 position = GetPosition(renderer, offset);
            Context g = renderer.Context;
            if (Unit.Health < 1)
                return;
            double percent = (double)Unit.Health / (double)Unit.MaxHealth;
            double size = renderer.GetUnitSize((double)Arena.Config.ActorSize / 2) * 1.25;
            Vector2 start = position + new Vector2(0, (float)-size);
            g.MoveTo(start.X, start.Y);
            g.ArcNegative(position.X, position.Y, size, 3 * MathHelper.PiOver2, 3 * MathHelper.PiOver2 - (MathHelper.TwoPi * percent));
            if (percent < 1) {
                g.LineTo(position.X, position.Y);
                g.LineTo(start.X, start.Y);
            }
            renderer.SetColor(Unit.Team == localPlayer.Team ? Arena.Config.HealthColor1 : Arena.Config.EnemyHealthColor1);
            g.FillPreserve();
            renderer.SetColor(Unit.Team == localPlayer.Team ? Arena.Config.HealthColor2 : Arena.Config.EnemyHealthColor2);

            double unit = MathHelper.TwoPi / Unit.MaxHealth;
            for (int i = 0; i < Unit.Health; i++) {
                Vector2 dest = position + new Vector2((float)(Math.Cos(3 * MathHelper.PiOver2 - unit * i) * size), (float)(Math.Sin(3 * MathHelper.PiOver2 - unit * i) * size));
                g.MoveTo(position.X, position.Y);
                g.LineTo(dest.X, dest.Y);
                renderer.SetColor(Unit.Team == localPlayer.Team ? Arena.Config.HealthColor2 : Arena.Config.EnemyHealthColor2);
                g.Stroke();
            }

            if (Unit.Energy < 1 || Unit.Team != localPlayer.Team)
                return;
            double ePercent = (double)Unit.Energy / (double)Unit.MaxEnergy;
            g.MoveTo(position.X, position.Y - size);
            double energy = 3 * MathHelper.PiOver2 - (MathHelper.TwoPi * ePercent);
            double energySize = size / 7;
            g.ArcNegative(position.X, position.Y, size, 3 * MathHelper.PiOver2, energy);
            g.LineTo(position.X + Math.Cos(energy) * (energySize + size), position.Y + Math.Sin(energy) * (size + energySize));
            g.Arc(position.X, position.Y, size + energySize, energy, 3 * MathHelper.PiOver2);
            g.ClosePath();
            renderer.SetColor(Arena.Config.EnergyColor1);
            g.FillPreserve();
            renderer.SetColor(Arena.Config.EnergyColor2);
            g.Stroke();

            unit = MathHelper.TwoPi / Unit.MaxEnergy;
            for (int i = 0; i < Unit.Energy; i++) {
                Vector2 src = position + new Vector2((float)(Math.Cos(3 * MathHelper.PiOver2 - unit * i) * size), (float)(Math.Sin(3 * MathHelper.PiOver2 - unit * i) * size));
                Vector2 dest = position + new Vector2((float)(Math.Cos(3 * MathHelper.PiOver2 - unit * i) * (size + energySize)), (float)(Math.Sin(3 * MathHelper.PiOver2 - unit * i) * (size + energySize)));
                g.MoveTo(src.X, src.Y);
                g.LineTo(dest.X, dest.Y);
                renderer.SetColor(Arena.Config.EnergyColor2);
                g.Stroke();
            }
        }
开发者ID:adamrezich,项目名称:arena,代码行数:53,代码来源:Actor.cs


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