'RGB 中有 1,530 种色调(256,256,256),这真的很简单。'这有效地揭示了 RGB 的“分辨率”,因为要成为一种独特的色调,一个 rgb 必须是 255,另一个必须是 0,第三个有 256 个值要递增,在极端情况下重复更少。其他一切都是色调、色调或阴影。所以,让我们把它们加到 0 和 255 的六种组合中,然后把它们也算作我,边走边说:
Dim I As Integer
Dim R, G, B As Byte
Dim Spectrum(0 to 1529) as Long
I = -1 'Incremented before each use
R = 255: B = 0 'G inc RED
For G = 0 To 255 '256
I = I + 1: Spectrum(I) = RGB(R, G, B)
Next
G = 255: B = 0 'R dec YELLOW
For R = 254 To 0 Step -1 '255
I = I + 1: Spectrum(I) = RGB(R, G, B)
Next
R = 0: G = 255 'B inc GREEN
For B = 1 To 255 '255
I = I + 1: Spectrum(I) = RGB(R, G, B)
Next
R = 0: B = 255 'G dec CYAN
For G = 254 To 0 Step -1 '255
I = I + 1: Spectrum(I) = RGB(R, G, B)
Next
G = 0: B = 255 'R inc BLUE
For R = 1 To 255 '255
I = I + 1: Spectrum(I) = RGB(R, G, B)
Next
R = 255: G = 0 'B dec MAGENTA
For B = 254 To 1 Step -1 '254
I = I + 1: Spectrum(I) = RGB(R, G, B)
Next
'I = 1,529 = 256+255+255+255+255+254 No duplicates
'Hue = I * 0.23529411764705882353°
'0° is Red at I = 0, so I=0 counts as 1 so, 1 + 1,529 = 1530