Example #1
0
        public void AllOneColor(Color Color)
        {
            pixelColors = new List<Color>();

            for (int i = 0; i < spi.PixelCount; i++) 
            {
                pixelColors.Add(Color.FromArgb(255, Color.R,Color.G,Color.B));
            }

            SPIclass.SendPixels(pixelColors);
        }
Example #2
0
        public ColorPickerMenuItem(Color color)
        {
            Color = color;

            _fillBrush = new SolidBrush(Color);

            _borderPen = new Pen(
                Color.FromArgb(
                    (int)(color.R / 1.5f),
                    (int)(color.G / 1.5f),
                    (int)(color.B / 1.5f)
                )
            );
        }
		/// <summary>Lights up the provided color and returns it</summary>
		private Color LightColor(Color Color) {
			int A = Color.A;
			int R = (Convert.ToInt32(Color.R) + 1024)/5;
			int G = (Convert.ToInt32(Color.G) + 1024)/5;
			int B = (Convert.ToInt32(Color.B) + 1024)/5;

			return Color.FromArgb(A, R, G, B);
		}
Example #4
0
        private void Glassify(Rectangle Rectangle, PaintEventArgs e, Color Color, bool Pressed)
        {
            using (var gp = CreateRoundRectangle(Rectangle, 2))
            {
                var opacity = 0x7f;

                using (Brush brush = new SolidBrush(Color.FromArgb(opacity, Color)))
                {
                    e.Graphics.FillPath(brush, gp);
                }
            }

            using (var clip = CreateRoundRectangle(Rectangle, 2))
            {
                e.Graphics.SetClip(clip, CombineMode.Intersect);

                using (var gp = CreateBottomRadialPath(Rectangle))
                {
                    using (var brush = new PathGradientBrush(gp))
                    {
                        var opacity = (int) (0xB2*.99f + .5f);

                        var bounds = gp.GetBounds();

                        brush.CenterPoint = new PointF((bounds.Left + bounds.Right)/2f, (bounds.Top + bounds.Bottom)/2f);
                        brush.CenterColor = Color.FromArgb(opacity, Color.White);
                        brush.SurroundColors = new[] {Color.FromArgb(0, Color.White)};

                        e.Graphics.FillPath(brush, gp);
                    }
                }

                e.Graphics.ResetClip();
            }

            var newRect = Rectangle;
            newRect.Height >>= 1;

            if (newRect.Width > 0 && newRect.Height > 0)
            {
                newRect.Height++;

                using (var gp = CreateTopRoundRectangle(newRect, 2))
                {
                    var opacity = Pressed ? (int) (.4f*0x9 + .5f) : 0x99;

                    newRect.Height++;

                    using (
                        var brush = new LinearGradientBrush(newRect, Color.FromArgb(opacity, Color.White),
                            Color.FromArgb(opacity/3, Color.White), LinearGradientMode.Vertical))
                    {
                        e.Graphics.FillPath(brush, gp);
                    }
                }
            }

            var Y = Rectangle.Y + Rectangle.Height - 1;

            // e.Graphics.DrawLine(new Pen(Color.Black), Rectangle.Left, Y, Rectangle.Right, Y);
        }
Example #5
0
 public static void DrawFilledBox(float x, float y, float w, float h, Color Color, int alpha = 255)
 {
     Vector2[] vertexList = new Vector2[2];
     DXLine.GLLines = true;
     DXLine.Antialias = false;
     DXLine.Width = w;
     vertexList[0].X = x + (w / 2f);
     vertexList[0].Y = y;
     vertexList[1].X = x + (w / 2f);
     vertexList[1].Y = y + h;
     DXLine.Begin();
     DXLine.Draw(vertexList, Color.FromArgb(alpha, Color.R, Color.G, Color.B));
     DXLine.End();
 }
 public void Update()
 {
     switch (Order.Status)
     {
         case OrderStatus.New:
             Color = Color.FromArgb(255, 255, 230);
             break;
         case OrderStatus.PartiallyFilled:
             Color = Color.SkyBlue;
             break;
         case OrderStatus.Filled:
             Color = Color.FromArgb(220, 255, 220);
             break;
         case OrderStatus.Cancelled:
             Color = Color.FromArgb(255, 230, 230);
             break;
     }
 }
Example #7
0
        private void ColorSlide(object sender, MouseEventArgs e, ColorComponents colorComponent)
        {
            Control control = (sender as Control);

            int xLocation = e.X.Clamp(0, control.ClientRectangle.Width);
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                byte newValue = (byte)ScaleRange(xLocation, 0, control.ClientRectangle.Width, 0, 255);

                switch (colorComponent)
                {
                    case ColorComponents.Red:
                        Color = Color.FromArgb(color.A, newValue, color.G, color.B);
                        break;

                    case ColorComponents.Green:
                        Color = Color.FromArgb(color.A, color.R, newValue, color.B);
                        break;

                    case ColorComponents.Blue:
                        Color = Color.FromArgb(color.A, color.R, color.G, newValue);
                        break;

                    case ColorComponents.Alpha:
                        Color = Color.FromArgb(newValue, color.R, color.G, color.B);
                        break;
                }
            }
        }
        public override void LoadDetails(XmlNode node, KmlRoot owner)
        {
            base.LoadDetails(node, owner);

            Color = GetColor(node);

            ColorMode = GetColorMode(node);

            if (ColorMode == KmlColorModes.Random)
            {
                byte red = (Byte)(Color.R * rnd.NextDouble());
                byte green = (Byte)(Color.G * rnd.NextDouble());
                byte blue = (Byte)(Color.B * rnd.NextDouble());
                byte alpha = (Byte)(Color.A * rnd.NextDouble());
                Color = Color.FromArgb(alpha, red, green, blue);
            }
        }
Example #9
0
 /// <summary>
 /// Load the label from a github api json representation.
 /// </summary>
 /// <param name="json">The github api json representation</param>
 public override void LoadFromJson(JObject json)
 {
     Name = json["name"].Value<string>();
     Color = Color.Empty;
     var c = json["color"];
     int ic;
     if (Int32.TryParse(json["color"].Value<string>(), NumberStyles.HexNumber, null, out ic)) Color = Color.FromArgb(ic);
 }
Example #10
0
		public static Color EcuacionPhong(Foco3D[] Focos, PhongShader Constantes, Vector3D NormalSUR, Punto3D PuntoSUR, Color Color, Camara3D Camara)
		{
			Vector3D Rayo = null;
			Vector3D Salida = null;
			Vector3D Vista = null;
			byte r = 0;
			byte g = 0;
			byte b = 0;
			long rr = 0;
			long gg = 0;
			long bb = 0;
			long trr = 0;
			long tgg = 0;
			long tbb = 0;
			double Escalar = 0;
			double Ambiente = 0;
			double Difusa = 0;
			double Especular = 0;

			double AmbienteR = 0;
			double DifusaR = 0;
			double EspecularR = 0;
			double AmbienteG = 0;
			double DifusaG = 0;
			double EspecularG = 0;
			double AmbienteB = 0;
			double DifusaB = 0;
			double EspecularB = 0;

			trr = 0;
			tgg = 0;
			tbb = 0;

			Vista = new Vector3D(Camara.Posicion, PuntoSUR);
			Vista.Normalizar();

			Ambiente = Constantes.Ambiente;
			NormalSUR.Normalizar();

			for (long i = 0; i <= Focos.GetUpperBound(0); i++) {
				Rayo = new Vector3D(Focos[i].Coordenadas, PuntoSUR);
				Rayo = !Rayo.VectorUnitario;
				Salida = (((2 * (NormalSUR * Rayo)) * NormalSUR) - Rayo).VectorUnitario;

				Difusa = Focos[i].Intensidad * (Constantes.Difusa * (NormalSUR * Rayo));
				Escalar = (Salida * Vista);
				if (Escalar < 0) {
					Especular = Math.Abs((Constantes.Especular * Math.Pow(Escalar, Constantes.ExponenteEspecular)));
				} else {
					Especular = 0;
				}

				AmbienteR = Ambiente * (Focos[i].Color.R / 255);
				DifusaR = Difusa * (Focos[i].Color.R / 255);
				EspecularR = Especular * (Focos[i].Color.R / 255);

				AmbienteG = Ambiente * (Focos[i].Color.G / 255);
				DifusaG = Difusa * (Focos[i].Color.G / 255);
				EspecularG = Especular * (Focos[i].Color.G / 255);

				AmbienteB = Ambiente * (Focos[i].Color.B / 255);
				DifusaB = Difusa * (Focos[i].Color.B / 255);
				EspecularB = Especular * (Focos[i].Color.B / 255);

				rr = Color.R * (AmbienteR + DifusaR);
				rr = rr + ((Focos[i].Color.R - rr) * EspecularR);

				gg = Color.G * (AmbienteG + DifusaG);
				gg = gg + ((Focos[i].Color.G - gg) * EspecularG);

				bb = Color.B * (AmbienteB + DifusaB);
				bb = bb + ((Focos[i].Color.B - bb) * EspecularB);

				if (rr < 0)
					rr = 0;
				if (gg < 0)
					gg = 0;
				if (bb < 0)
					bb = 0;

				trr += rr;
				tgg += gg;
				tbb += bb;
			}

			if (trr > 255)
				trr = 255;
			if (trr < 0)
				trr = 0;

			if (tgg > 255)
				tgg = 255;
			if (tgg < 0)
				tgg = 0;

			if (tbb > 255)
				tbb = 255;
			if (tbb < 0)
				tbb = 0;

			r = trr;
			g = tgg;
			b = tbb;

			return Color.FromArgb(255, r, g, b);
		}
		public Color Fusionar()
		{
			if (mHijos == null) {
				return mColor;
			} else {
				long r = 0;
				long g = 0;
				long b = 0;
				Color Color = default(Color);

				r = 0;
				g = 0;
				b = 0;

				for (int i = 0; i <= 7; i++) {
					Color = mHijos[i].Fusionar();
					r += Color.R;
					g += Color.G;
					b += Color.B;
				}

				return Color.FromArgb(255, r / 8, g / 8, b / 8);
			}
		}