通过 jquery 将 HSL 或 HSV 转换为 RGB

发布于 2024-08-21 01:09:24 字数 514 浏览 6 评论 0原文

我希望使用 jquery 生成随机“相似”颜色。

据我了解,解决此问题的最佳方法是使用 HSL 或 HSV,根据 < a href="https://stackoverflow.com/questions/1586147/how-to-generate-random-greenish-colors">这个问题。

问题是我似乎不知道如何…

  1. 使用 HSL 或 HSV 与 jquery;或
  2. 通过 jquery 将 HSL 或 HSV 转换为 RBG

我找到了 这个 颜色库,但是如果可能的话我想避免使用插件。有什么想法吗?

I'm looking to generate random "similar" colors using jquery.

It is my understanding that the best way to approach this is using HSL or HSV, according to this question.

The issue is I can't seem to figure out how to either…

  1. Use HSL or HSV with jquery; or
  2. Convert HSL or HSV to RBG via jquery

I found this color library, but i'd like to avoid plugins if at all possible. Any idea's?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不奢求什么 2024-08-28 01:09:24

最好的主意:DIY :)

编写一个简单的转换函数。这将是 4 行数学运算,

从这里开始:
http://en.wikipedia.org/wiki/HSL_and_HSV

并在 CSS 中使用颜色,如下所示

color: rgb(255, 255, 255);

并用字符串函数将其剪切。

仍然不确定该怎么做?在评论中询问详细信息;)

Best idea ever: DIY :)

Write a simple conversion function. It'd be 4 lines of math

Look here for start:
http://en.wikipedia.org/wiki/HSL_and_HSV

And use colors in CSS as follows

color: rgb(255, 255, 255);

And cut it up with string functions.

Still not sure what to do? Ask for details in comments ;)

陌路终见情 2024-08-28 01:09:24

看这里,这看起来可以做所有事情:
https://www.adaptavist.com/display/jQuery/Colour+Library

See here, this looks like it would do everything:
https://www.adaptavist.com/display/jQuery/Colour+Library

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文