- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
一周多以来,我一直在寻找如何创建这样的东西。
我有代码和 for 循环来通过 X、Y 坐标和所有内容创建每个面板。每个面板都是数组的一部分,从左上角的 0 开始,到右上角的 90 结束,但我不关心它是如何完成的,只要它完成了,它的面板和工作就可以了。颜色不需要相同但相似,这样我就可以拥有全屏颜色选择器。如果有人知道使用 Color.FromARGB 或仅使用 Color 类来采用一种特定颜色并使其变亮十倍以设置面板 backColor 的代码,请帮助我。谢谢。
(这是我为 windows 平板电脑制作的应用程序,是触摸屏。该应用程序的目的是全屏,而不是评论它是 windows 平板电脑,因为我必须自己制作颜色选择器,不能使用内置颜色对话框。)
最佳答案
为了获得最佳控制,我建议使用颜色计算函数。
那里有很多;这是我使用的一个:
Color HsvToRgb(double h, double S, double V)
{
/// Convert HSV to RGB
/// h is from 0d - 360d
/// s,v values are 0d - 1d
/// r,g,b values are 0 - 255
int hi = Convert.ToInt32(Math.Floor(hue / 60)) % 6;
double f = hue / 60 - Math.Floor(hue / 60);
value = value * 255;
int v = Convert.ToInt32(value);
int p = Convert.ToInt32(value * (1 - saturation));
int q = Convert.ToInt32(value * (1 - f * saturation));
int t = Convert.ToInt32(value * (1 - (1 - f) * saturation));
if (hi == 0) return Color.FromArgb(255, v, t, p);
else if (hi == 1) return Color.FromArgb(255, q, v, p);
else if (hi == 2) return Color.FromArgb(255, p, v, t);
else if (hi == 3) return Color.FromArgb(255, p, q, v);
else if (hi == 4) return Color.FromArgb(255, t, p, v);
else return Color.FromArgb(255, v, p, q);
}
请注意输入范围!!
现在很容易在类级别设置Color
数组:
int width = 10;
int height = 9;
Color[,] colors;
并填写:
void loadColors()
{
colors = new Color[width, height];
// load greys
for (int i = 0; i < width; i++ ) colors[i, 0] = HsvToRgb(0f, 0f, 1f * i / width);
// load bright stripe:
for (int i = 0; i < width; i++) colors[i, 1] = HsvToRgb(i* 360f / width, 0.33f, 1f);
// load matrix:
for (int j = 2; j < height; j++)
for (int i = 0; i < width; i++)
colors[i, j] = HsvToRgb(i * 360f / width, 1f, 1f * (height - j + 2) / height);
}
从这里可以快速设置 Panels
的 BackColors
。
这是一个 Form.Paint
函数,我用来创建上面的屏幕截图:
private void Form1_Paint(object sender, PaintEventArgs e)
{
int w = ClientSize.Width / width;
int h = ClientSize.Height / height;
for (int j = 0; j < height; j++)
for (int i = 0; i < width; i++)
{
using (SolidBrush brush = new SolidBrush(colors[i,j]))
e.Graphics.FillRectangle(brush, i * w, j * h, w, h);
}
}
当然很简单,就是把两个数改成更细的网格,这里是20x20:
另请注意,色调的均匀间距并不能很好地发挥作用,human eye 也不是这样。我们常见的显示系统对整个光谱的色调变化也同样敏感。
眼睛其实相当sensitive变成绿色
the just-noticeable difference in wavelength varies from about 1 nm in the blue-green and yellow wavelengths, to 10 nm and more in the longer red and shorter blue wavelengths
但是我们的显示器在创建不同的绿色色调方面做得非常糟糕..
使用 perceptionally evenly spaced hues 的改编列表可能会有所帮助,具体取决于您想要什么..
使用这个单行:
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
int hue = (int) ((Bitmap)pictureBox1.Image).GetPixel(e.X, e.Y).GetHue();
}
上图给了我们一个这样的色调列表:
20 32 41 50 58 72 133 163 170 177 183 190 197 206 269 288 307 324 334 346
我对它做了一些修改,也许是为了让它更好地与我的显示器配合使用:
List<int> hues = new List<int>
{ 20, 32, 41, 50, 58, 72, 133, 162, 180, 188, 195, 205, 215, 223, 246, 267, 288, 300, 320, 346 };
并将上面的代码(保持宽度= 20)更改为
HsvToRgb(hues[i],..
结果:
更新:我用一个大大简化的函数替换了 HsvToRgb
函数。
关于c# - 色表算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31612232/
我在业余时间慢慢学习javascript,但还没有完全掌握这一点。但一位 friend 要求我制作一个简单的机器人,它可以向每个加入服务器的新用户发送私信,询问他们希望用户名的颜色是什么,并将他们添加
抱歉,标题令人困惑,我会澄清一下。我正在尝试让机器人检查用户是否在他们的 quick.db 库存中具有特定 Angular 色,如果有,它就会装备该 Angular 色。我遇到的问题是,即使在 lis
所以我想做一个小的用户配置文件,但我希望它打印出用户 Angular 色。可能吗? case "Profile": var embed = new Discord.RichEmbed()
我有一个表单,其中包含三个不同的 data-role="page" 和三个不同的 data-url="abc"。 根据某些条件,单击第一页上的按钮后,我将在第二页上渲染/显示某些字段。 现在我正在获取
我有一行不和谐机器人的代码,用于删除特定的命名 Angular 色并添加一个名为“静音”的 Angular 色一段特定的时间。基本上,服务器只能有 3 个 Angular 色,一个可以发出命令,一个具
我想在编写函数时在编辑页面上显示文本的标题。 应用程序.html {{ text }} 应用程序.ts getRoleEdit
如果 s 是一个系列,我在运行以下命令时会收到一条错误消息: s.plot(style='k--', color='b') 错误消息说 [b] 不是可识别的颜色。 我正在使用 Pandas 0.11。
这是一个 fiddle http://jsfiddle.net/aLr2yx8d/ $('#inputButton').click(function() { var value = $(
所以,基本上。我想做的是创建一个单词解密器,您可以在其中输入一个打乱的单词并对其进行解密。它工作得很好,尽管我单独检查每个字符,但由于某种原因,额外的字符漏掉了。 我输入“olehl (hello)”
在尝试console.log字符串时,我遇到了一个相当烦人的问题。我将字符串 2^{\\frac{1}{2}}x=1 存储在 Node.js 数据库中,但输出时给出 2^{rac{1}{2 }}x=1
我想创建一个命令来查找用户在服务器中拥有的最高 Angular 色。 我已经知道Python中有一个discord.user.top_role。是否有相当于该功能的 Javascript? 我尝试将此
我对 Node.js 相当陌生,目前正在开发一个 Discord 机器人。我试图让我的机器人根据用户传递的参数分配服务器 Angular 色。我知道我可以找到特定 Angular 色的名称,然后根据他
我一直在尝试创建一个简单的命令,为在聊天中说话的人提供一个 Angular 色,假设他们说了一句脏话,它会给 message.author 静音 Angular 色。 client.on("messa
如何使用expressjs和passport在nodejs中实现基于 Angular 色的授权/访问控制以及如何完美设计 Angular 色中间件? 我有两种登录类型管理员和用户 以管理员和用户的名义
我在这里有一个键盘可访问的自定义下拉组件:https://codesandbox.io/s/31440w1vo6 但是,当我打开 NVDA 或 JAWS 时,激活“选择等位基因”后焦点不会再移动到选项
我正在为我的机器人创建 Angular 色分配命令,因此用户可以输入 h.addrole @user @role 我正在尝试执行此命令,如果用户拥有该 Angular 色,它会输出说 此用户已经拥有此
我想从数据库中获取用户的 Angular 色(组织或个人)。我有一个名为“Users”的表,另一个名为“Role_users”的表,其中有 user_id 和 role_id(1 代表个人,100 代
我有一个在 Vuejs 项目中导出一些函数的文件,我还需要在外部环境中使用它们..在 Component 中我知道我要使用哪个函数应该通过名称识别并与 .JSON 文件进行比较来使用,这在开发环境中很
我想将用户添加到我的 Parse.Role 但它不起作用。我看了很多例子,它们看起来都很简单,但我无法正确理解。这是我的代码: Parse.Cloud.define("activateVendor",
我克隆了一个 https://github.com/beeman/loopback-angular-admin我已经使用环回资源管理器创建了几个新 Angular 色,但是如何为我创建的用户分配 An
我是一名优秀的程序员,十分优秀!