Palette - 0.0 (All Chroma Scale) to 1.0 (All Saturation Scale)

- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.0

- Palette -
0.0
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.25

- Palette -
0.0
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.5

- Palette -
0.0
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.75

- Palette -
0.0
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
1.0

- Palette -
0.0
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.0

- Palette -
0.25
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.25

- Palette -
0.25
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.5

- Palette -
0.25
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.75

- Palette -
0.25
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
1.0

- Palette -
0.25
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.0

- Palette -
0.5
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.25

- Palette -
0.5
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.5

- Palette -
0.5
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.75

- Palette -
0.5
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
1.0

- Palette -
0.5
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.0

- Palette -
0.75
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.25

- Palette -
0.75
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.5

- Palette -
0.75
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.75

- Palette -
0.75
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
1.0

- Palette -
0.75
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.0

- Palette -
1.0
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.25

- Palette -
1.0
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.5

- Palette -
1.0
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
0.75

- Palette -
1.0
- Hue -
Horizontal
Left to Right
0.0 to 1.0
32 Steps

- Contrast -
Vertical
Top to Bottom
0.0 to 1.0
32 Steps

- Brightness -
1.0

- Palette -
1.0


                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                               


VB Code used in making the Color Table
__________

Function HCBPtoRGB(ByVal Hue As Double, ByVal Contrast As Double, ByVal Brightness As Double, ByVal Palette As Double) As Long
'Palette = 0.0 [All Chroma Palette] to Palette = 1.0 [All Saturation Palette]
'Hue, Contrast, Brightness = 0.0 to 1.0 Scale
HCBPtoRGB = RGB(Int(255 * HCBPtoR(Hue, Contrast, Brightness, Palette)), Int(255 * HCBPtoG(Hue, Contrast, Brightness, Palette)), Int(255 * HCBPtoB(Hue, Contrast, Brightness, Palette)))
End Function

Function HCBPtoR(ByVal Hue As Double, ByVal Contrast As Double, ByVal Brightness As Double, ByVal Palette As Double) As Double
'Palette = 0.0 [All Chroma], Palette = 1.0 [All Saturation]
Dim r0, g0, b0, h0, c0, m0, x0 As Double 'Chroma Scale
Dim r1, g1, b1, h1, c1, m1, x1 As Double 'Saturation Scale

c0 = Contrast
c1 = (1 - Abs(2 * Brightness - 1)) * Contrast
h0 = Hue - Int(Hue)
h1 = Hue - Int(Hue)
x0 = c0 * (1 - Abs(Modulus((6 * h0), 2) - 1))
x1 = c1 * (1 - Abs(Modulus((6 * h1), 2) - 1))

If (((0 / 6) <= h0) And (h0 < (1 / 6))) Then
r0 = c0: g0 = x0: b0 = 0
ElseIf ((1 / 6) <= h0) And (h0 < (2 / 6)) Then
r0 = x0: g0 = c0: b0 = 0
ElseIf ((2 / 6) <= h0) And (h0 < (3 / 6)) Then
r0 = 0: g0 = c0: b0 = x0
ElseIf ((3 / 6) <= h0) And (h0 < (4 / 6)) Then
r0 = 0: g0 = x0: b0 = c0
ElseIf ((4 / 6) <= h0) And (h0 < (5 / 6)) Then
r0 = x0: g0 = 0: b0 = c0
ElseIf ((5 / 6) <= h0) And (h0 < (6 / 6)) Then
r0 = c0: g0 = 0: b0 = x0
End If

If (((0 / 6) <= h1) And (h1 < (1 / 6))) Then
r1 = c1: g1 = x1: b1 = 0
ElseIf ((1 / 6) <= h1) And (h1 < (2 / 6)) Then
r1 = x1: g1 = c1: b1 = 0
ElseIf ((2 / 6) <= h1) And (h1 < (3 / 6)) Then
r1 = 0: g1 = c1: b1 = x1
ElseIf ((3 / 6) <= h1) And (h1 < (4 / 6)) Then
r1 = 0: g1 = x1: b1 = c1
ElseIf ((4 / 6) <= h1) And (h1 < (5 / 6)) Then
r1 = x1: g1 = 0: b1 = c1
ElseIf ((5 / 6) <= h1) And (h1 < (6 / 6)) Then
r1 = c1: g1 = 0: b1 = x1
End If

m0 = Brightness - (0.3 * r0 + 0.59 * g0 + 0.11 * b0)
m1 = Brightness - (c1 / 2)

If ((1 - Palette) * (r0 + m0) + Palette * (r1 + m1) > 1) Then
HCBPtoR = 1
ElseIf ((1 - Palette) * (r0 + m0) + Palette * (r1 + m1) < 0) Then
HCBPtoR = 0
Else
HCBPtoR = (1 - Palette) * (r0 + m0) + Palette * (r1 + m1)
End If

End Function

Function HCBPtoG(ByVal Hue As Double, ByVal Contrast As Double, ByVal Brightness As Double, ByVal Palette As Double) As Double
'Palette = 0.0 [All Chroma], Palette = 1.0 [All Saturation]
Dim r0, g0, b0, h0, c0, m0, x0 As Double 'Chroma Scale
Dim r1, g1, b1, h1, c1, m1, x1 As Double 'Saturation Scale

c0 = Contrast
c1 = (1 - Abs(2 * Brightness - 1)) * Contrast
h0 = Hue - Int(Hue)
h1 = Hue - Int(Hue)
x0 = c0 * (1 - Abs(Modulus((6 * h0), 2) - 1))
x1 = c1 * (1 - Abs(Modulus((6 * h1), 2) - 1))

If (((0 / 6) <= h0) And (h0 < (1 / 6))) Then
r0 = c0: g0 = x0: b0 = 0
ElseIf ((1 / 6) <= h0) And (h0 < (2 / 6)) Then
r0 = x0: g0 = c0: b0 = 0
ElseIf ((2 / 6) <= h0) And (h0 < (3 / 6)) Then
r0 = 0: g0 = c0: b0 = x0
ElseIf ((3 / 6) <= h0) And (h0 < (4 / 6)) Then
r0 = 0: g0 = x0: b0 = c0
ElseIf ((4 / 6) <= h0) And (h0 < (5 / 6)) Then
r0 = x0: g0 = 0: b0 = c0
ElseIf ((5 / 6) <= h0) And (h0 < (6 / 6)) Then
r0 = c0: g0 = 0: b0 = x0
End If

If (((0 / 6) <= h1) And (h1 < (1 / 6))) Then
r1 = c1: g1 = x1: b1 = 0
ElseIf ((1 / 6) <= h1) And (h1 < (2 / 6)) Then
r1 = x1: g1 = c1: b1 = 0
ElseIf ((2 / 6) <= h1) And (h1 < (3 / 6)) Then
r1 = 0: g1 = c1: b1 = x1
ElseIf ((3 / 6) <= h1) And (h1 < (4 / 6)) Then
r1 = 0: g1 = x1: b1 = c1
ElseIf ((4 / 6) <= h1) And (h1 < (5 / 6)) Then
r1 = x1: g1 = 0: b1 = c1
ElseIf ((5 / 6) <= h1) And (h1 < (6 / 6)) Then
r1 = c1: g1 = 0: b1 = x1
End If

m0 = Brightness - (0.3 * r0 + 0.59 * g0 + 0.11 * b0)
m1 = Brightness - (c1 / 2)

If ((1 - Palette) * (g0 + m0) + Palette * (g1 + m1) > 1) Then
HCBPtoG = 1
ElseIf ((1 - Palette) * (g0 + m0) + Palette * (g1 + m1) < 0) Then
HCBPtoG = 0
Else
HCBPtoG = (1 - Palette) * (g0 + m0) + Palette * (g1 + m1)
End If

End Function

Function HCBPtoB(ByVal Hue As Double, ByVal Contrast As Double, ByVal Brightness As Double, ByVal Palette As Double) As Double
'Palette = 0.0 [All Chroma], Palette = 1.0 [All Saturation]
Dim r0, g0, b0, h0, c0, m0, x0 As Double 'Chroma Scale
Dim r1, g1, b1, h1, c1, m1, x1 As Double 'Saturation Scale

c0 = Contrast
c1 = (1 - Abs(2 * Brightness - 1)) * Contrast
h0 = Hue - Int(Hue)
h1 = Hue - Int(Hue)
x0 = c0 * (1 - Abs(Modulus((6 * h0), 2) - 1))
x1 = c1 * (1 - Abs(Modulus((6 * h1), 2) - 1))

If (((0 / 6) <= h0) And (h0 < (1 / 6))) Then
r0 = c0: g0 = x0: b0 = 0
ElseIf ((1 / 6) <= h0) And (h0 < (2 / 6)) Then
r0 = x0: g0 = c0: b0 = 0
ElseIf ((2 / 6) <= h0) And (h0 < (3 / 6)) Then
r0 = 0: g0 = c0: b0 = x0
ElseIf ((3 / 6) <= h0) And (h0 < (4 / 6)) Then
r0 = 0: g0 = x0: b0 = c0
ElseIf ((4 / 6) <= h0) And (h0 < (5 / 6)) Then
r0 = x0: g0 = 0: b0 = c0
ElseIf ((5 / 6) <= h0) And (h0 < (6 / 6)) Then
r0 = c0: g0 = 0: b0 = x0
End If

If (((0 / 6) <= h1) And (h1 < (1 / 6))) Then
r1 = c1: g1 = x1: b1 = 0
ElseIf ((1 / 6) <= h1) And (h1 < (2 / 6)) Then
r1 = x1: g1 = c1: b1 = 0
ElseIf ((2 / 6) <= h1) And (h1 < (3 / 6)) Then
r1 = 0: g1 = c1: b1 = x1
ElseIf ((3 / 6) <= h1) And (h1 < (4 / 6)) Then
r1 = 0: g1 = x1: b1 = c1
ElseIf ((4 / 6) <= h1) And (h1 < (5 / 6)) Then
r1 = x1: g1 = 0: b1 = c1
ElseIf ((5 / 6) <= h1) And (h1 < (6 / 6)) Then
r1 = c1: g1 = 0: b1 = x1
End If

m0 = Brightness - (0.3 * r0 + 0.59 * g0 + 0.11 * b0)
m1 = Brightness - (c1 / 2)

If ((1 - Palette) * (b0 + m0) + Palette * (b1 + m1) > 1) Then
HCBPtoB = 1
ElseIf ((1 - Palette) * (b0 + m0) + Palette * (b1 + m1) < 0) Then
HCBPtoB = 0
Else
HCBPtoB = (1 - Palette) * (b0 + m0) + Palette * (b1 + m1)
End If

End Function

Function Modulus(ByVal a As Double, ByVal n As Integer) As Double
Modulus = a - (n * Int(a / n))
End Function


__________


C# Translation
__________

public class Class1
{
public static Brush HCBPAtoARGB(double Hue, double Contrast, double Brightness, double Palette, double Transparency)
{
//Palette = 0.0 [All Chroma Palette] to Palette = 1.0 [All Saturation Palette]
//Hue, Contrast, Brightness = 0.0 to 1.0 Scale
double A = Transparency;

if (A > 1f) A = 1f;

if (A < 0f) A = 0f;

Brush brushColor = new SolidColorBrush(Color.FromArgb((byte)(255f * A), (byte)(255f * HCBPtoR(Hue, Contrast, Brightness, Palette)), (byte)(255f * HCBPtoG(Hue, Contrast, Brightness, Palette)), (byte)(255f * HCBPtoB(Hue, Contrast, Brightness, Palette))));

return brushColor;
}


public static double HCBPtoR(double Hue, double Contrast, double Brightness, double Palette)
{
double R = 0f;
//Palette = 0.0 [All Chroma], Palette = 1.0 [All Saturation]
//Chroma Scale
double r0 = 0f;
double g0 = 0f;
double b0 = 0f;
double h0 = 0f;
double c0 = 0f;
double m0 = 0f;
double x0 = 0f;
//Saturation Scale
double r1 = 0f;
double g1 = 0f;
double b1 = 0f;
double h1 = 0f;
double c1 = 0f;
double m1 = 0f;
double x1 = 0f;


c0 = Contrast;
c1 = (1f - Math.Abs(2f * Brightness - 1f)) * Contrast;
h0 = Hue - IntPart(Hue);
h1 = Hue - IntPart(Hue);
x0 = c0 * (1f - Math.Abs(Modulus((6f * h0), 2f) - 1f));
x1 = c1 * (1f - Math.Abs(Modulus((6f * h1), 2f) - 1f));

if ((((0f / 6f) <= h0) & (h0 < (1f / 6f))))
{
r0 = c0;
g0 = x0;
b0 = 0f;
}
else if (((1f / 6f) <= h0) & (h0 < (2f / 6f)))
{
r0 = x0;
g0 = c0;
b0 = 0f;
}
else if (((2f / 6f) <= h0) & (h0 < (3f / 6f)))
{
r0 = 0f;
g0 = c0;
b0 = x0;
}
else if (((3f / 6f) <= h0) & (h0 < (4f / 6f)))
{
r0 = 0f;
g0 = x0;
b0 = c0;
}
else if (((4f / 6f) <= h0) & (h0 < (5f / 6f)))
{
r0 = x0;
g0 = 0f;
b0 = c0;
}
else if (((5f / 6f) <= h0) & (h0 < (6f / 6f)))
{
r0 = c0;
g0 = 0f;
b0 = x0;
}

if ((((0f / 6f) <= h1) & (h1 < (1f / 6f))))
{
r1 = c1;
g1 = x1;
b1 = 0f;
}
else if (((1f / 6f) <= h1) & (h1 < (2f / 6f)))
{
r1 = x1;
g1 = c1;
b1 = 0f;
}
else if (((2f / 6f) <= h1) & (h1 < (3f / 6f)))
{
r1 = 0f;
g1 = c1;
b1 = x1;
}
else if (((3f / 6f) <= h1) & (h1 < (4f / 6f)))
{
r1 = 0f;
g1 = x1;
b1 = c1;
}
else if (((4f / 6f) <= h1) & (h1 < (5f / 6f)))
{
r1 = x1;
g1 = 0f;
b1 = c1;
}
else if (((5f / 6f) <= h1) & (h1 < (6f / 6f)))
{
r1 = c1;
g1 = 0f;
b1 = x1;
}

m0 = Brightness - (0.3f * r0 + 0.59f * g0 + 0.11f * b0);
m1 = Brightness - (c1 / 2f);

R = (1f - Palette) * (r0 + m0) + Palette * (r1 + m1);

if (R > 1f) R = 1f;

if (R < 0f) R = 0f;

return R;
}

public static double HCBPtoG(double Hue, double Contrast, double Brightness, double Palette)
{
double G = 0f;
//Palette = 0.0 [All Chroma], Palette = 1.0 [All Saturation]
//Chroma Scale
double r0 = 0f;
double g0 = 0f;
double b0 = 0f;
double h0 = 0f;
double c0 = 0f;
double m0 = 0f;
double x0 = 0f;
//Saturation Scale
double r1 = 0f;
double g1 = 0f;
double b1 = 0f;
double h1 = 0f;
double c1 = 0f;
double m1 = 0f;
double x1 = 0f;


c0 = Contrast;
c1 = (1f - Math.Abs(2f * Brightness - 1f)) * Contrast;
h0 = Hue - IntPart(Hue);
h1 = Hue - IntPart(Hue);
x0 = c0 * (1f - Math.Abs(Modulus((6f * h0), 2f) - 1f));
x1 = c1 * (1f - Math.Abs(Modulus((6f * h1), 2f) - 1f));

if ((((0f / 6f) <= h0) & (h0 < (1f / 6f))))
{
r0 = c0;
g0 = x0;
b0 = 0f;
}
else if (((1f / 6f) <= h0) & (h0 < (2f / 6f)))
{
r0 = x0;
g0 = c0;
b0 = 0f;
}
else if (((2f / 6f) <= h0) & (h0 < (3f / 6f)))
{
r0 = 0f;
g0 = c0;
b0 = x0;
}
else if (((3f / 6f) <= h0) & (h0 < (4f / 6f)))
{
r0 = 0f;
g0 = x0;
b0 = c0;
}
else if (((4f / 6f) <= h0) & (h0 < (5f / 6f)))
{
r0 = x0;
g0 = 0f;
b0 = c0;
}
else if (((5f / 6f) <= h0) & (h0 < (6f / 6f)))
{
r0 = c0;
g0 = 0f;
b0 = x0;
}

if ((((0f / 6f) <= h1) & (h1 < (1f / 6f))))
{
r1 = c1;
g1 = x1;
b1 = 0f;
}
else if (((1f / 6f) <= h1) & (h1 < (2f / 6f)))
{
r1 = x1;
g1 = c1;
b1 = 0f;
}
else if (((2f / 6f) <= h1) & (h1 < (3f / 6f)))
{
r1 = 0f;
g1 = c1;
b1 = x1;
}
else if (((3f / 6f) <= h1) & (h1 < (4f / 6f)))
{
r1 = 0f;
g1 = x1;
b1 = c1;
}
else if (((4f / 6f) <= h1) & (h1 < (5f / 6f)))
{
r1 = x1;
g1 = 0f;
b1 = c1;
}
else if (((5f / 6f) <= h1) & (h1 < (6f / 6f)))
{
r1 = c1;
g1 = 0f;
b1 = x1;
}

m0 = Brightness - (0.3f * r0 + 0.59f * g0 + 0.11f * b0);
m1 = Brightness - (c1 / 2f);

G = (1f - Palette) * (g0 + m0) + Palette * (g1 + m1);

if (G > 1f) G = 1f;

if (G < 0f) G = 0f;

return G;
}

public static double HCBPtoB(double Hue, double Contrast, double Brightness, double Palette)
{
double B = 0f;
//Palette = 0.0 [All Chroma], Palette = 1.0 [All Saturation]
//Chroma Scale
double r0 = 0f;
double g0 = 0f;
double b0 = 0f;
double h0 = 0f;
double c0 = 0f;
double m0 = 0f;
double x0 = 0f;
//Saturation Scale
double r1 = 0f;
double g1 = 0f;
double b1 = 0f;
double h1 = 0f;
double c1 = 0f;
double m1 = 0f;
double x1 = 0f;


c0 = Contrast;
c1 = (1f - Math.Abs(2f * Brightness - 1f)) * Contrast;
h0 = Hue - IntPart(Hue);
h1 = Hue - IntPart(Hue);
x0 = c0 * (1f - Math.Abs(Modulus((6f * h0), 2f) - 1f));
x1 = c1 * (1f - Math.Abs(Modulus((6f * h1), 2f) - 1f));

if ((((0f / 6f) <= h0) & (h0 < (1f / 6f))))
{
r0 = c0;
g0 = x0;
b0 = 0f;
}
else if (((1f / 6f) <= h0) & (h0 < (2f / 6f)))
{
r0 = x0;
g0 = c0;
b0 = 0f;
}
else if (((2f / 6f) <= h0) & (h0 < (3f / 6f)))
{
r0 = 0f;
g0 = c0;
b0 = x0;
}
else if (((3f / 6f) <= h0) & (h0 < (4f / 6f)))
{
r0 = 0f;
g0 = x0;
b0 = c0;
}
else if (((4f / 6f) <= h0) & (h0 < (5f / 6f)))
{
r0 = x0;
g0 = 0f;
b0 = c0;
}
else if (((5f / 6f) <= h0) & (h0 < (6f / 6f)))
{
r0 = c0;
g0 = 0f;
b0 = x0;
}

if ((((0f / 6f) <= h1) & (h1 < (1f / 6f))))
{
r1 = c1;
g1 = x1;
b1 = 0f;
}
else if (((1f / 6f) <= h1) & (h1 < (2f / 6f)))
{
r1 = x1;
g1 = c1;
b1 = 0f;
}
else if (((2f / 6f) <= h1) & (h1 < (3f / 6f)))
{
r1 = 0f;
g1 = c1;
b1 = x1;
}
else if (((3f / 6f) <= h1) & (h1 < (4f / 6f)))
{
r1 = 0f;
g1 = x1;
b1 = c1;
}
else if (((4f / 6f) <= h1) & (h1 < (5f / 6f)))
{
r1 = x1;
g1 = 0f;
b1 = c1;
}
else if (((5f / 6f) <= h1) & (h1 < (6f / 6f)))
{
r1 = c1;
g1 = 0f;
b1 = x1;
}

m0 = Brightness - (0.3f * r0 + 0.59f * g0 + 0.11f * b0);
m1 = Brightness - (c1 / 2f);

B = (1f - Palette) * (b0 + m0) + Palette * (b1 + m1);

if (B > 1f) B = 1f;

if (B < 0f) B = 0f;

return B;
}

public static double Modulus(double a, double n)
{
return (a - (n * IntPart(a / n)));
}

public static double IntPart(double n)
{
double I = Math.Floor(n);
if (Math.Sign(n) == -1) I = Math.Ceiling(n);
if (Math.Sign(n) == 0) I = 0;
return I;
}
}

__________