示例#1
0
		public static Palette GeneratePallette(Color centralColor, int size, byte alpha, byte variance)
		{
			Palette p = new Palette();

			byte r = centralColor.R;
			byte g = centralColor.G;
			byte b = centralColor.B;

			for (int i = 0; i < size; i++)
			{
				p.Colors.Add(Color.FromArgb(alpha,r,g,b));
				GetNextShade(ref r, ref g, ref b, variance);
			}

			return p;
		}
示例#2
0
		public static Palette GetNeighborhood(Color c, int width)
		{
			int maxColorValue = Math.Max(c.R, Math.Max(c.G, c.B));

			ColorChannel maxChannel = maxColorValue == c.R ? ColorChannel.R : maxColorValue == c.G ? ColorChannel.G : ColorChannel.B;

			//need to generate intelligent way to range colors around the central value...

			Palette p = new Palette();

			int paletteWidth = width;

			int g = c.G < paletteWidth / 2 ? 0 : c.G - paletteWidth / 2;
			int r = c.R < paletteWidth / 2 ? 0 : c.R - paletteWidth / 2;
			int b = c.B < paletteWidth / 2 ? 0 : c.B - paletteWidth / 2;

			while (g < c.G + paletteWidth/2 && g<255)
			{			
				g++;
				p.Add(Color.FromArgb(r, g, b));
				while( r< c.R+paletteWidth/2 && r<255)
				{
					r++;
					p.Add(Color.FromArgb(r, g, b));
					while( b < c.B+paletteWidth/2 && b<255)
					{
						b++;
						p.Add(Color.FromArgb(r, g, b));
					}
				}
			}
			return p;		
		}
示例#3
0
		public static Palette Greens()
		{
			Color c = Color.ForestGreen;

			Palette p = new Palette();

			int paletteWidth = 150;

			int g = c.G < paletteWidth / 2 ? 0 : c.G - paletteWidth / 2;
			int r = c.R < paletteWidth / 2 ? 0 : c.R - paletteWidth / 2;
			int b = c.B < paletteWidth / 2 ? 0 : c.B - paletteWidth / 2;

			while (g < c.G + paletteWidth/2 && g<255)
			{			
				g++;
				while( r< c.R+paletteWidth/2 && r<255)
				{
					r++;
					while( b < c.B+paletteWidth/2 && b<255)
					{
						b++;
						p.Add(Color.FromArgb(r, g, b));
					}
				}
			}
			return p;
		}
示例#4
0
		public static Palette FromBitmap(Bitmap b)
		{
			Palette p = new Palette();
			for (int x = 0; x < b.Width; x++)
			{
				for (int y = 0; y < b.Height; y++)
				{
					p.Add(Color.FromArgb(b.GetPixel(x, y).ToArgb()));
				}
			}
			return p;
		}