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


C# System.Color类代码示例

本文整理汇总了C#中System.Color的典型用法代码示例。如果您正苦于以下问题:C# Color类的具体用法?C# Color怎么用?C# Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Color类属于System命名空间,在下文中一共展示了Color类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        public static void Draw(ISpriteBatch sb, Vector2 source, Vector2 dest, Color color)
        {
            var dist = Vector2.Distance(source, dest);
            var angle = GetAngle(source, dest);

            // Get the length of the segments
            var segLen = dist / 6;
            if (segLen < 5.0f)
                segLen = 5.0f;
            if (segLen > 25.0f)
                segLen = 25.0f;

            // Primary line
            var tailLen = dist - (segLen / 2);
            var pDest = source + (new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * tailLen);
            RenderLine.Draw(sb, source, pDest, color);

            // Arrow segment 1
            var ang1 = angle - MathHelper.PiOver4;
            var seg1 = dest - (new Vector2((float)Math.Cos(ang1), (float)Math.Sin(ang1)) * segLen);
            RenderLine.Draw(sb, dest, seg1, color);

            // Arrow segment 2
            var ang2 = angle + MathHelper.PiOver4;
            var seg2 = dest - (new Vector2((float)Math.Cos(ang2), (float)Math.Sin(ang2)) * segLen);
            RenderLine.Draw(sb, dest, seg2, color);

            // Arrow segment 3
            RenderLine.Draw(sb, seg1, seg2, color);
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:30,代码来源:RenderArrow.cs

示例2: LineInfo

 /// <summary>
 /// Initializes a new instance of the <see cref="LineInfo" /> struct.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="color">The color.</param>
 /// <param name="size">The size.</param>
 /// <param name="offsetX">offset X alignment.</param>
 public LineInfo(string text, Color color, Vector2 size, float offsetX)
 {
     this.SubTextList = new List<SubTextInfo>();
     this.Size = Vector2.Zero;
     this.AlignmentOffsetX = offsetX;
     this.AddText(text, color, size);
 }
开发者ID:huodianyan,项目名称:Components,代码行数:14,代码来源:LineInfo.cs

示例3: ClassWithMultipleCtorArguments

 public ClassWithMultipleCtorArguments(Color color, string name, int age, DateTime day)
 {
     _color = color;
     _name = name;
     _age = age;
     _day = day;
 }
开发者ID:satish860,项目名称:StructureMap3,代码行数:7,代码来源:ObjectGraphBuilderTester.cs

示例4: Color_IsConstructedProperly_FromInt32RGBA

        public void Color_IsConstructedProperly_FromInt32RGBA()
        {
            var result = new Color(12, 34, 56, 78);

            TheResultingValue(result)
                .ShouldHaveArgbComponents(78, 12, 34, 56);
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:7,代码来源:ColorTests.cs

示例5: CreateGame

 public Game CreateGame(Color color)
 {
     // Отправляется запрос к серверу на создание в базе
     // новой записи Party/Game с исходными значениями
     // некоторых полей (FirstPlayerId и color)
     return new Game(this, 0000);
 }
开发者ID:Beginner7,项目名称:Command1,代码行数:7,代码来源:User.cs

示例6: Update

        /// <summary>
        /// Updates the light color like a torch
        /// </summary>
        /// <param name="gameTime">Time of the game </param>
        protected override void Update(TimeSpan gameTime)
        {
            if (!this.initialized)
            {
                this.RefColor = light.Color.ToVector3();
                this.initialized = true;
            }

            ellapsedGameTime += gameTime;

            if (this.ellapsedGameTime > this.nextColorTime)
            {
                light.Color = this.NextColor;

                float r = ((float)WaveServices.Random.NextDouble() * 0.15f + 0.85f);
                float att = ((float)WaveServices.Random.NextDouble() * 0.3f + 0.7f);
                this.period = ((float)WaveServices.Random.NextDouble() * 0.2f + 0.05f);

                this.PrevColor = this.NextColor;
                this.NextColor = new Color(
                    this.RefColor.X * ((float)WaveServices.Random.NextDouble() * 0.05f + 0.95f),
                    this.RefColor.Y * r,
                    this.RefColor.Z * r) * att;
                this.startColorTime = this.ellapsedGameTime;
                this.nextColorTime = this.ellapsedGameTime + TimeSpan.FromSeconds(this.period);
            }
            else
            {
                float lerp = (float)(this.ellapsedGameTime - this.startColorTime).TotalSeconds / this.period;

                this.light.Color = this.PrevColor * (1 - lerp) + this.NextColor * (lerp);
            }
        }
开发者ID:123asd123A,项目名称:Samples,代码行数:37,代码来源:TorchLightBehavior.cs

示例7: Run

        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                List<PreferenceColor.Item> allOptions = new List<PreferenceColor.Item>();

                foreach (CASCharacter.NameColorPair color in CASCharacter.kColors)
                {
                    allOptions.Add(new PreferenceColor.Item(color.mColor, (me.FavoriteColor == color.mColor) ? 1 : 0));
                }

                PreferenceColor.Item choice = new CommonSelection<PreferenceColor.Item>(Name, me.FullName, allOptions).SelectSingle();
                if (choice == null) return false;

                mFavoriteColor = choice.Value;
            }

            me.FavoriteColor = mFavoriteColor;

            if (PlumbBob.SelectedActor == me.CreatedSim)
            {
                (Sims3.Gameplay.UI.Responder.Instance.HudModel as HudModel).OnSimFavoritesChanged(me.CreatedSim.ObjectId);
            }

            return true;
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:26,代码来源:ChangeFavoriteColor.cs

示例8: CreateShadows

        public static bool CreateShadows()
        {

            Image img = spriteSheet.Texture.CopyToImage();

            for (uint k = 0; k < img.Size.X; k++)
                for (uint j = 0; j < img.Size.Y; j++)
                {
                    Color c = img.GetPixel(k, j);
                    if (c.A == 255)
                    {
                        Color d = new Color();
                        d.A = 40;
                        d.R = d.G = d.B = 0;
                        img.SetPixel(k, j, d);
                    }
                }

            Texture tex = new Texture(img);
            Sprite tempsprite = new Sprite();
            tempsprite.Texture = tex;

            shadowSpriteSheet = new RenderTexture(textureSize, textureSize);
            shadowSpriteSheet.Draw(tempsprite);
            shadowSpriteSheet.Display();

            shadowSprite.Texture = shadowSpriteSheet.Texture;

            img.Dispose();
            tempsprite.Dispose();
            tex.Dispose();

            return true;
        }
开发者ID:starboxgames,项目名称:superstarbox,代码行数:34,代码来源:TextureMan.cs

示例9: Face

 public Face()
 {
     for (int i = 0; i < 3; i++)
     {
         Colors[i] = new Color(1.0f, 1.0f, 1.0f, 1.0f);
     }
 }
开发者ID:kou-yeung,项目名称:Effekseer,代码行数:7,代码来源:Face.cs

示例10: Dfs

 private static void Dfs(Vertex vertex, Color currentColor, Color[] colors)
 {
     switch (colors[vertex.Number])
     {
         case Color.noColor:
         {
             colors[vertex.Number] = currentColor;
             break;
         }
         default:
         {
             if (colors[vertex.Number] != currentColor)
             {
                 for (var i = 0; i < colors.Length; ++i)
                 {
                     colors[i] = Color.firstColor;
                 }
             }
             return;
         }
     }
     foreach (var nextVertex in vertex.Connections)
     {
         Dfs(nextVertex, changeColor(currentColor), colors);
     }
 }
开发者ID:alexander-bzikadze,项目名称:University_tasks,代码行数:26,代码来源:Algorithm.cs

示例11: SetupGrid

        private void SetupGrid(Vector2u mapSize)
        {
            const int gridSize = 16;
            _gridTexture = new RenderTexture(2000, 2000);
            var col = new Color(120, 120, 120);
            var verticies = new List<Vertex>();
            for (int x = 0; x < mapSize.X; x += gridSize)
            {
                verticies.Add(new Vertex(new Vector2f(x, 0), col));
                verticies.Add(new Vertex(new Vector2f(x, mapSize.Y), col));
            }
            for (int y = 0; y < mapSize.Y; y += gridSize)
            {
                verticies.Add(new Vertex(new Vector2f(0, y), col));
                verticies.Add(new Vertex(new Vector2f(mapSize.X, y), col));
            }
            _gridlines = verticies.ToArray();

            _gridTexture.Clear(new Color(190, 190, 190));
            //_view = new View(new FloatRect(0,0,displaySize.X, displaySize.Y));
            _view = new View(new FloatRect(0, 0, DisplayView.Size.X, DisplayView.Size.Y));
            DisplayView = _view;
            //_gridTexture.SetView(_view);
            _gridTexture.Draw(_gridlines, PrimitiveType.Lines);
            _gridTexture.Display();

            _grid = new Sprite(_gridTexture.Texture);
            AddItemToDraw(_grid, 0);
        }
开发者ID:Sprunth,项目名称:Planetary-Explorers,代码行数:29,代码来源:SpaceMap.cs

示例12: Circle

        Texture2D Circle(GraphicsDevice graphics, int radius)
        {
            int aDiameter = radius * 2;
            Vector2 aCenter = new Vector2(radius, radius);

            Texture2D aCircle = new Texture2D(graphics, aDiameter, aDiameter, false, SurfaceFormat.Color);
            Color[] aColors = new Color[aDiameter * aDiameter];

            for (int i = 0; i < aColors.Length; i++)
            {
                int x = (i + 1) % aDiameter;
                int y = (i + 1) / aDiameter;

                Vector2 aDistance = new Vector2(Math.Abs(aCenter.X - x), Math.Abs(aCenter.Y - y));


                if (Math.Sqrt((aDistance.X * aDistance.X) + (aDistance.Y * aDistance.Y)) > radius)
                {
                    aColors[i] = Color.Transparent;
                }
                else
                {
                    aColors[i] = Color.White;
                }
            }

            aCircle.SetData<Color>(aColors);

            return aCircle;
        }
开发者ID:GhostTap,项目名称:MonoGame,代码行数:30,代码来源:MonoGameGamerServicesHelper.cs

示例13: CreateToolbar

        public static ToolbarDialog CreateToolbar(Point toolbar_pos, Point toolbar_size, Color toolbar_color)
        {
            var t = new ToolbarDialog
            {
                Color = toolbar_color,
                Size = toolbar_size
            };

            t.Control = new IHTMLDiv();
            t.Drag = new DragHelper(t.Control);
            t.Drag.Position = toolbar_pos;

            //t.ControlForm.BackColor = System.Drawing.Color.Green;
            t.ControlForm.MoveTo(t.Drag.Position.X, t.Drag.Position.Y);
            //t.ControlForm.SizeTo(toolbar_size.X + 16, toolbar_size.Y + 32);



            t.Control.style.SetLocation(t.Drag.Position.X, t.Drag.Position.Y, toolbar_size.X, toolbar_size.Y);

            t.Control.SetDialogColor(toolbar_color);
            t.Drag.Enabled = true;
            t.Drag.DragMove += t.ApplyPosition;

            t.Grow();

            return t;
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:28,代码来源:ToolbarDialog.cs

示例14: CoverCaption

 public CoverCaption(CoverManager coverManager, string font_name, Color color)
     : base(coverManager, font_name, color)
 {
     CoverManager.NewCurrentCover += HandleNewCurrentCover;
     CoverManager.TargetIndexChanged += HandleTargetIndexChanged;
     CoverManager.CoversChanged += HandleCoversChanged;
 }
开发者ID:nailyk,项目名称:banshee-community-extensions,代码行数:7,代码来源:CoverCaption.cs

示例15: Set

		public void Set ( float x, float y, float dx, float dy, float w, float h, float sin, float cos, Color color, Vector2 texCoordTL, Vector2 texCoordBR )
		{
            // TODO, Should we be just assigning the Depth Value to Z?
            // According to http://blogs.msdn.com/b/shawnhar/archive/2011/01/12/spritebatch-billboards-in-a-3d-world.aspx
            // We do.
			vertexTL.Position.X = x+dx*cos-dy*sin;
            vertexTL.Position.Y = y+dx*sin+dy*cos;
            vertexTL.Position.Z = Depth;
            vertexTL.Color = color;
            vertexTL.TextureCoordinate.X = texCoordTL.X;
            vertexTL.TextureCoordinate.Y = texCoordTL.Y;

			vertexTR.Position.X = x+(dx+w)*cos-dy*sin;
            vertexTR.Position.Y = y+(dx+w)*sin+dy*cos;
            vertexTR.Position.Z = Depth;
            vertexTR.Color = color;
            vertexTR.TextureCoordinate.X = texCoordBR.X;
            vertexTR.TextureCoordinate.Y = texCoordTL.Y;

			vertexBL.Position.X = x+dx*cos-(dy+h)*sin;
            vertexBL.Position.Y = y+dx*sin+(dy+h)*cos;
            vertexBL.Position.Z = Depth;
            vertexBL.Color = color;
            vertexBL.TextureCoordinate.X = texCoordTL.X;
            vertexBL.TextureCoordinate.Y = texCoordBR.Y;

			vertexBR.Position.X = x+(dx+w)*cos-(dy+h)*sin;
            vertexBR.Position.Y = y+(dx+w)*sin+(dy+h)*cos;
            vertexBR.Position.Z = Depth;
            vertexBR.Color = color;
            vertexBR.TextureCoordinate.X = texCoordBR.X;
            vertexBR.TextureCoordinate.Y = texCoordBR.Y;
		}
开发者ID:Boerlam001,项目名称:MonoGame,代码行数:33,代码来源:SpriteBatchItem.cs


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