【问题标题】:Colour help, code snippet needs explaining颜色帮助,代码片段需要解释
【发布时间】:2013-12-10 15:23:28
【问题描述】:

基本上我正在研究渲染 sprtiesheets,这个人提供了一个教程,其中恶意表使用 4 种颜色:黑色、深灰色、浅灰色和白色。

这些然后通过一种方法对应不同的颜色。例如。黑色是绿色,白色是红色等。

无论如何,我想使用 5 种颜色而不是 4 种颜色,但我想理解这一点,但没有解释。

代码:

    public class Colours {


    public static int get(int colour1, int colour2, int colour3, int colour4, int colour5)      {
    return (get(colour4) << 24) + (get(colour3) << 16) + (get(colour2) << 8) + (get(colour1));
}

    private static int get(int colour)  {
        if(colour < 0)
            return 255;
    int r = colour / 100 % 10;
    int g = colour / 10 % 10;
    int b = colour % 10;
    return r * 36 + g * 6 + b;
}

static {
    Colours.get(555, 543, 542, 123);
}

有人告诉我这与基数有关,基本上我需要知道代码的含义以及如何获得这些颜色数字,例如542 = 一种颜色。虽然是什么颜色

谢谢

【问题讨论】:

  • 问问是谁给你这个代码sn-p的人。
  • 他处于不活动状态,大约 3 个月

标签: java colors rgb code-snippets


【解决方案1】:

get(int color) 将十进制数解释为以 6 为底并返回相应的整数,其中每个数字似乎代表 0..5 范围内的颜色分量。

000 似乎代表黑色,555 代表白色,500 代表红色,50 代表绿色,5 代表蓝色等等。

get(int color1...) 将其中的四个打包成一个 32 位整数。不能将超过 4 x 8 位打包成 32 位整数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-27
    • 1970-01-01
    • 2022-06-15
    • 1970-01-01
    相关资源
    最近更新 更多