PHP 颜色操作

发布于 2024-08-28 19:11:38 字数 177 浏览 3 评论 0原文

我目前正在研究颜色操作/选择等,并遇到了以下代码。我想知道有人可以告诉我下面的代码是做什么的,并为我分解它,谢谢!

$newVal = round(round(($rgb['red'] / 0x33)) * 0x33);

特别是 0x33 是什么

提前致谢

I am currently looking into color manipulation / selection etc and have come across the following piece of code. I was wondering of someone could tell me what the following piece of code is doing and break it down for me thanks!

$newVal = round(round(($rgb['red'] / 0x33)) * 0x33);

In particluar what is the 0x33

Thanks in adavnce

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

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

发布评论

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

评论(4

秋叶绚丽 2024-09-04 19:11:38

它似乎正在将 $rgb['red'] 转换为最接近的 0x33 倍数。

它可能会这样做,因此颜色最终会出现在所谓的“网络安全”调色板上,该调色板(如果我没记错的话)由 RGB 值是 0x33 倍数的颜色组成。

0x33 是 51(十进制)的以 16 为基数(十六进制)表示。

It seems to be converting $rgb['red'] the nearest multiple of 0x33.

It's probably doing that so the color will end up on the so-called "web safe" color palette, which (if I recall correctly) consists of colors who's rgb values are multiples of 0x33.

0x33 is the base-16 (hex) representation of 51 (decimal).

请持续率性 2024-09-04 19:11:38

0x33 是 51,因此它将单个字节的 0-255 值缩放为 0-5,然后再缩放回来。这会导致该值被下限为低于该值 51 的最高倍数。

0x33 is 51, so it scales the 0-255 value of a single byte to 0-5, and then scales it back out. This results in the value being floored to the highest multiple of 51 lower than the value.

浅语花开 2024-09-04 19:11:38

0x33 只是 33 的十六进制值。

我不太确定发生了什么,但我猜测它会计算任何颜色的网络安全十六进制。或者类似的东西。

0x33 is just hex value for 33.

I'm not really sure what is happening, but my guess would be it calculates a web safe hex of any color. Or something along these lines.

私藏温柔 2024-09-04 19:11:38

正如@Seth 所指出的,它将颜色舍入到最接近的“网络安全”颜色。这是一个古老的想法,可以追溯到大多数彩色显示器都是 8 位的时候。 Visibone 是使其流行的人之一,因为他们的“网络安全色卡”是他们的第一个产品。

有关详细信息,请参阅网页颜色

As @Seth indicated, it's rounding colours to the nearest 'web-safe' colour. It's an old idea, dating from back when most colour displays were 8-bit. One of the people to make it popular was Visibone as their 'websafe colour chart' was their first product.

See Web Colours for more information.

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