我正在尝试向 map 添加点。而且无论这张 map 上有多少个图钉,每个图钉都会有自己的颜色。我只想改变色调
我正在使用看起来像这样的模板 png
我想创建一个函数,当一个新点出现时,这个文件会随机着色。
我该怎么做?
我正在使用下面的代码 - 我无法弄清楚如何在矩阵中抛出随机值以输出任何在色板上间隔足够远的好颜色
private Bitmap ColorMyPin()
{
Image imgPicture = Properties.Resources.green_MarkerBlank;
Bitmap bmp = new Bitmap(imgPicture.Width, imgPicture.Height);
ImageAttributes iaPicture = new ImageAttributes();
ColorMatrix cmPicture = new ColorMatrix(new float[][]
{
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0}, <-- //Hard part where do i throw random() values at
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0}
});
// Set the new color matrix
iaPicture.SetColorMatrix(cmPicture);
// Set the Graphics object from the bitmap
Graphics gfxPicture = Graphics.FromImage(bmp);
// New rectangle for the picture, same size as the original picture
Rectangle rctPicture = new Rectangle(0, 0, imgPicture.Width, imgPicture.Height);
// Draw the new image
gfxPicture.DrawImage(imgPicture, rctPicture, 0, 0, imgPicture.Width, imgPicture.Height, GraphicsUnit.Pixel, iaPicture);
return bmp;
}
之后
请您参考如下方法:
有据可查的是,在区分图表、图形、网格或 map 上的颜色时,人眼的表现并不好。我见过推荐的上限低至 8 种和高达 15 种独特的颜色(并且假设观看者不是色盲)。使用调色板可能会更好。
如果您想增加可能的图钉数量,您可以将调色板中的颜色数量乘以一些易于区分的形状(圆形、三角形、正方形等)。您甚至可以使用双色调方法(粗边框和内部颜色),这会将总数(颜色 * 形状)提高到二次方。
因此,假设有 8 种颜色、4 种形状和双色调配色方案,您将能够表示 1,024 个不同的图钉。
要进一步阅读,请查看这篇关于颜色和数据可视化表示的优秀文章: http://www.perceptualedge.com/articles/visual_business_intelligence/rules_for_using_color.pdf
