vbAccelerator - Contents of code file: cCMY.cls

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "cCMY"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

'
' vbAccelerator.com
' VB CMY (Cyan, Magenta, Yellow) subtractive colour model.
' Copyright  2003 Steve McMahon for vbAccelerator.com
'

' http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html

'    RGB -> CMY              | CMY -> RGB
'    Red   = 1-Cyan  (0<=Cyan<=1)    | Cyan    = 1-Red (0<=Red<=1)
'    Green = 1-Magenta   (0<=Magenta<=1) | Magenta = 1-Green (0<=Green<=1)
'    Blue  = 1-Yellow    (0<=Yellow<=1)  | Yellow  = 1-Blue (0<=Blue<=1)


Private m_lR As Long
Private m_lG As Long
Private m_lB As Long

Private m_lC As Long
Private m_lM As Long
Private m_lY As Long

Public Property Get RGB() As Long
    RGB = (m_lR And &HFF&) + (m_lG And &HFF&) * &H100& + (m_lB And &HFF&) *
     &H10000
End Property
Public Property Let RGB(ByVal value As Long)
    R = value And &HFF&
    G = (value And &HFF00&) \ &H100&
    B = (value And &HFF0000) \ &H10000
End Property

Public Property Get R() As Long
    R = m_lR
End Property
Public Property Get G() As Long
    G = m_lG
End Property
Public Property Get B() As Long
    B = m_lB
End Property

Public Property Let R(ByVal value As Long)
    m_lR = value And &HFF&
    m_lC = &HFF& - m_lR
End Property
Public Property Let G(ByVal value As Long)
    m_lG = value And &HFF&
    m_lM = &HFF& - m_lG
End Property
Public Property Let B(ByVal value As Long)
    m_lB = value And &HFF&
    m_lY = &HFF& - m_lB
End Property

Public Property Get C() As Long
    C = m_lC
End Property
Public Property Get M() As Long
    M = m_lM
End Property
Public Property Get y() As Long
    y = m_lY
End Property

Public Property Let C(ByVal value As Long)
    m_lC = value And &HFF&
    m_lR = &HFF& - m_lC
End Property
Public Property Let M(ByVal value As Long)
    m_lM = value And &HFF&
    m_lG = &HFF& - m_lM
End Property
Public Property Let y(ByVal value As Long)
    m_lY = value And &HFF&
    m_lB = &HFF& - m_lY
End Property

Public Sub FromCMY(ByVal cValue As Long, ByVal mValue As Long, ByVal yValue As
 Long)
    m_lC = cValue And &HFF&
    m_lM = mValue And &HFF&
    m_lY = yValue And &HFF&
    m_lR = &HFF& - m_lC
    m_lG = &HFF& - m_lM
    m_lB = &HFF& - m_lY
End Sub