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


C# Color类代码示例

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


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

示例1: ToColor

        public static Color ToColor(this char character)
        {
            Color color = new Color();

            switch (character)
            {
                case 'y':
                    color = Color.Yellow;
                    break;
                case 'r':
                    color = Color.Red;
                    break;
                case 'g':
                    color = Color.Green;
                    break;
                case 'o':
                    color = Color.Orange;
                    break;
                case 'b':
                    color = Color.Blue;
                    break;
                case 'w':
                    color = Color.White;
                    break;
            }

            return color;
        }
开发者ID:CrazyRoma,项目名称:CubeAutoSolving,代码行数:28,代码来源:MainForm.cs

示例2: Initialise

		public void Initialise()
		{
			_primitives = new List<Cube>();
			var random = new Random();
			for (int i = 0; i < Constants.CubeCount; i++)
			{
				_primitives.Add(new Cube
					{
						Color = Color.Red,
						Position = new Vector3(random.Next(100) - 50, random.Next(100) - 50, -random.Next(100)),
						Radius = random.Next(100),
						Rotation = Vector3.Zero
					});
			}
            //How to create a kernel and a channel?
//			_kernel = 
//		    _channel = 

			

			_colour = Color.Beige;
			
			_kernel.Factory.NewCoroutine(ChangePosition);
			_kernel.Factory.NewCoroutine(ChangeColour);
		    
		}
开发者ID:maconbot,项目名称:c4g,代码行数:26,代码来源:World.cs

示例3: CustomLine

		public CustomLine(int startLineNr, int endLineNr, Color customColor, bool readOnly)
		{
			this.StartLineNr = startLineNr;
			this.EndLineNr = endLineNr;
			this.Color  = customColor;
			this.ReadOnly = readOnly;
		}
开发者ID:BackupTheBerlios,项目名称:ch3etah-svn,代码行数:7,代码来源:CustomLineManager.cs

示例4: Inventory

        public Inventory(int SCREEN_WIDTH, int SCREEN_HEIGHT, Pantheon gameReference)
        {
            locationBoxes = new List<Rectangle>();
            equippedBoxes = new List<Rectangle>();
            types = new List<int>();
            infoBox = new Rectangle();
            movingBox = new Rectangle();
            trashBox = new Rectangle();

            tempStorage = new Item();

            this.SCREEN_WIDTH = SCREEN_WIDTH;
            this.SCREEN_HEIGHT = SCREEN_HEIGHT;

            SetBoxes();

            selected = -1;
            hoveredOver = -1;

            color = new Color(34, 167, 222, 50);
            trashColor = Color.White;

            inventorySelector = gameReference.Content.Load<Texture2D>("Inventory/InvSelect");
            trashCan = gameReference.Content.Load<Texture2D>("Inventory/TrashCan");
            nullImage = new Texture2D(gameReference.GraphicsDevice, 1,1);
            nullImage.SetData(new[] { new Color(0,0,0,0) });
        }
开发者ID:Tangent128,项目名称:PantheonPrototype,代码行数:27,代码来源:Inventory.cs

示例5: RenderPolygone

 public static void RenderPolygone(SpriteBatch spriteBatch, Texture2D texture, Polygon polygon, int lineThickness, Color color)
 {
     for (int i = 0; i < polygon.Points.Count; ++i)
     {
         RenderLine(spriteBatch, texture, polygon.Points[i], polygon.Edges[i], 1, lineThickness, color);
     }
 }
开发者ID:Norskan,项目名称:Playground,代码行数:7,代码来源:RenderUtil.cs

示例6: GetHexCode

 public string GetHexCode(Color c)
 {
     return string.Format("#{0}{1}{2}",
         c.R.ToString("X2"),
         c.G.ToString("X2"),
         c.B.ToString("X2"));
 }
开发者ID:b00tbu9,项目名称:GCB,代码行数:7,代码来源:ColorSpace.cs

示例7: DrawRectangle

 /// <summary>
 /// Draw a rectangle.
 /// </summary>
 /// <param name="rectangle">The rectangle to draw.</param>
 /// <param name="color">The draw color.</param>
 public void DrawRectangle(Rectangle rectangle, Color color)
 {
     this.Draw(this.WhiteTexture, new Rectangle(rectangle.Left, rectangle.Top, rectangle.Width, 1), color);
     this.Draw(this.WhiteTexture, new Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, 1), color);
     this.Draw(this.WhiteTexture, new Rectangle(rectangle.Left, rectangle.Top, 1, rectangle.Height), color);
     this.Draw(this.WhiteTexture, new Rectangle(rectangle.Right, rectangle.Top, 1, rectangle.Height + 1), color);
 }
开发者ID:dotKokott,项目名称:MathFighter,代码行数:12,代码来源:ExtendedSpriteBatch.cs

示例8: DrawSpriteGlyph

        internal void DrawSpriteGlyph(Texture2D texture, Vector4 dest, Vector4 source, Color color)
        {
            if (!m_DrawString_InProgress)
                Logging.Fatal("BeginDrawString() must be called before DrawSpriteGlyph()");

            Vector4 uv = new Vector4(
                (float)source.X / texture.Width,
                (float)source.Y / texture.Height,
                (float)(source.X + source.Z) / texture.Width,
                (float)(source.Y + source.W) / texture.Height);

            VertexPositionTextureHueExtra[] v = new VertexPositionTextureHueExtra[4]
            {
                new VertexPositionTextureHueExtra(new Vector3(dest.X, dest.Y, m_DrawString_Depth), new Vector2(uv.X, uv.Y), color, Vector4.Zero), // top left
                new VertexPositionTextureHueExtra(new Vector3(dest.X + dest.Z, dest.Y, m_DrawString_Depth), new Vector2(uv.Z, uv.Y), color, Vector4.Zero), // top right
                new VertexPositionTextureHueExtra(new Vector3(dest.X, dest.Y + dest.W, m_DrawString_Depth), new Vector2(uv.X, uv.W), color, Vector4.Zero), // bottom left
                new VertexPositionTextureHueExtra(new Vector3(dest.X + dest.Z, dest.Y + dest.W, m_DrawString_Depth), new Vector2(uv.Z, uv.W), color, Vector4.Zero) // bottom right
            };

            /*if (shadow != null)
            {
                Color shadow2 = new Color(
                    shadow.Value.R, shadow.Value.G,
                    shadow.Value.B, 128);
                for (int i = 0; i < 4; i++)
                {
                    VertexPositionTextureHueExtra v0 = v[i];
                    v0.Hue = shadow.Value;
                    v0.Position.Y += 1f;
                    m_DrawString_VertexList.Add(v0);
                }
            }*/
            for (int i = 0; i < 4; i++)
                m_DrawString_VertexList.Add(v[i]);
        }
开发者ID:FreeReign,项目名称:UltimaXNA,代码行数:35,代码来源:YSpriteBatch_DrawString.cs

示例9: Create

        public Model3DGroup Create(Color modelColor,string pictureName, Point3D startPos, double maxHigh)
        {
            try
            {
                Uri inpuri = new Uri(@pictureName, UriKind.Relative);
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.UriSource = inpuri;
                bi.EndInit();
                ImageBrush imagebrush = new ImageBrush(bi);
                imagebrush.Opacity = 100;
                imagebrush.Freeze();

                Point[] ptexture0 = { new Point(0, 0), new Point(0, 1), new Point(1, 0) };
                Point[] ptexture1 = { new Point(1, 0), new Point(0, 1), new Point(1, 1) };

                SolidColorBrush modelbrush = new SolidColorBrush(modelColor);
                Model3DGroup cube = new Model3DGroup();
                Point3D uppercircle = startPos;
                modelbrush.Freeze();
                uppercircle.Y = startPos.Y + maxHigh;
                cube.Children.Add(CreateEllipse2D(modelbrush, uppercircle, _EllipseHigh, new Vector3D(0, 1, 0)));
                cube.Children.Add(CreateEllipse2D(modelbrush, startPos, _EllipseHigh, new Vector3D(0, -1, 0)));
                cube.Children.Add(CreateEllipse3D(imagebrush, startPos, _EllipseHigh, maxHigh, ptexture0));
                return cube;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:kse-jp,项目名称:RM-3000,代码行数:31,代码来源:EllipseModel.cs

示例10: Texte

 public Texte(string message, Point position, Color couleur)
 {
     this.message = message;
     this.position = position;
     this.couleur = couleur;
     this.police = Fonte.Arial15;
 }
开发者ID:gconfs-conferences,项目名称:bdsp-2012,代码行数:7,代码来源:Texte.cs

示例11: OnInspectorGUI

        public override void OnInspectorGUI()
        {
            serObj.Update();

            EditorGUILayout.LabelField("Overlays animated noise patterns", EditorStyles.miniLabel);

            EditorGUILayout.PropertyField(dx11Grain, new GUIContent("DirectX 11 Grain"));

            if (dx11Grain.boolValue && !(target as NoiseAndGrain).Dx11Support()) {
                EditorGUILayout.HelpBox("DX11 mode not supported (need DX11 GPU and enable DX11 in PlayerSettings)", MessageType.Info);
            }

            EditorGUILayout.PropertyField(monochrome, new GUIContent("Monochrome"));

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(intensityMultiplier, new GUIContent("Intensity Multiplier"));
            EditorGUILayout.PropertyField(generalIntensity, new GUIContent(" General"));
            EditorGUILayout.PropertyField(blackIntensity, new GUIContent(" Black Boost"));
            EditorGUILayout.PropertyField(whiteIntensity, new GUIContent(" White Boost"));
            midGrey.floatValue = EditorGUILayout.Slider( new GUIContent(" Mid Grey (for Boost)"), midGrey.floatValue, 0.0f, 1.0f);
            if (monochrome.boolValue == false) {
                Color c = new Color(intensities.vector3Value.x,intensities.vector3Value.y,intensities.vector3Value.z,1.0f);
                c = EditorGUILayout.ColorField(new GUIContent(" Color Weights"), c);
                intensities.vector3Value = new Vector3(c.r, c.g, c.b);
            }

            if (!dx11Grain.boolValue) {
                EditorGUILayout.Separator();

                EditorGUILayout.LabelField("Noise Shape");
                EditorGUILayout.PropertyField(noiseTexture, new GUIContent(" Texture"));
                EditorGUILayout.PropertyField(filterMode, new GUIContent(" Filter"));
            }
            else {
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Noise Shape");
            }

            softness.floatValue = EditorGUILayout.Slider( new GUIContent(" Softness"),softness.floatValue, 0.0f, 0.99f);

            if (!dx11Grain.boolValue) {
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Advanced");

                if (monochrome.boolValue == false)
                {
                    Vector3 temp = tiling.vector3Value;
                    temp.x = EditorGUILayout.FloatField(new GUIContent(" Tiling (Red)"), tiling.vector3Value.x);
                    temp.y = EditorGUILayout.FloatField(new GUIContent(" Tiling (Green)"), tiling.vector3Value.y);
                    temp.z = EditorGUILayout.FloatField(new GUIContent(" Tiling (Blue)"), tiling.vector3Value.z);
                    tiling.vector3Value = temp;
                }
                else {
                    EditorGUILayout.PropertyField(monochromeTiling, new GUIContent(" Tiling"));
                }
            }

            serObj.ApplyModifiedProperties();
        }
开发者ID:RewindAlice,项目名称:RewindAlice,代码行数:60,代码来源:NoiseAndGrainEditor.cs

示例12: CalculateGraphicsPathFromBitmap

		// From http://edu.cnzz.cn/show_3281.html
		public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent) 
		{ 
			GraphicsPath graphicsPath = new GraphicsPath(); 
			if (colorTransparent == Color.Empty)
				colorTransparent = bitmap.GetPixel(0, 0); 

			for(int row = 0; row < bitmap.Height; row ++) 
			{ 
				int colOpaquePixel = 0;
				for(int col = 0; col < bitmap.Width; col ++) 
				{ 
					if(bitmap.GetPixel(col, row) != colorTransparent) 
					{ 
						colOpaquePixel = col; 
						int colNext = col; 
						for(colNext = colOpaquePixel; colNext < bitmap.Width; colNext ++) 
							if(bitmap.GetPixel(colNext, row) == colorTransparent) 
								break;
 
						graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1)); 
						col = colNext; 
					} 
				} 
			} 
			return graphicsPath; 
		} 
开发者ID:hanistory,项目名称:hasuite,代码行数:27,代码来源:DrawHelper.cs

示例13: SetPixel

 public void SetPixel(int x, int y, Color colour)
 {
     PixelData* p = PixelAt(x, y);
     p->Red = colour.R;
     p->Green = colour.G;
     p->Blue = colour.B;
 }
开发者ID:DigiM4x,项目名称:Afterglow,代码行数:7,代码来源:FastBitmap.cs

示例14: Evaluate

        protected override Node Evaluate(Env env)
        {
            Guard.ExpectMinArguments(2, Arguments.Count, this, Index);
            Guard.ExpectMaxArguments(3, Arguments.Count, this, Index);
            Guard.ExpectAllNodes<Color>(Arguments.Take(2), this, Index);

            double weight = 50;
            if (Arguments.Count == 3)
            {
                Guard.ExpectNode<Number>(Arguments[2], this, Index);

                weight = ((Number) Arguments[2]).Value;
            }

            var colors = Arguments.Take(2).Cast<Color>().ToArray();

            // Note: this algorithm taken from http://github.com/nex3/haml/blob/0e249c844f66bd0872ed68d99de22b774794e967/lib/sass/script/functions.rb

            var p = weight/100.0;
            var w = p*2 - 1;
            var a = colors[0].Alpha - colors[1].Alpha;

            var w1 = (((w*a == -1) ? w : (w + a)/(1 + w*a)) + 1)/2.0;
            var w2 = 1 - w1;

            var rgb = colors[0].RGB.Select((x, i) => x*w1 + colors[1].RGB[i]*w2).ToArray();

            var alpha = colors[0].Alpha*p + colors[1].Alpha*(1 - p);

            var color = new Color(rgb[0], rgb[1], rgb[2], alpha);
            return color;
        }
开发者ID:Tigraine,项目名称:dotless,代码行数:32,代码来源:MixFunction.cs

示例15: GetCustomColor

		/// <remarks>
		/// Returns the Color if the line <code>lineNr</code> has custom bg color
		/// otherwise returns <code>defaultColor</code>
		/// </remarks>
		public Color GetCustomColor(int lineNr, Color defaultColor)
		{
			foreach(CustomLine line in lines)
				if (line.StartLineNr <= lineNr && line.EndLineNr >= lineNr)
					return line.Color;
			return defaultColor;
		}
开发者ID:BackupTheBerlios,项目名称:ch3etah-svn,代码行数:11,代码来源:CustomLineManager.cs


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