Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Gets the similarity in Float from 0 to 1 - outdated
- Public Function getColorSimilarity(a As Integer, b As Integer) As Float
- Dim Ra As Integer = Lsr(a, 16) And &HFF
- Dim Ga As Integer = Lsr(a, 8) And &HFF
- Dim Ba As Integer = a And &HFF
- Dim Rb As Integer = Lsr(b, 16) And &HFF
- Dim Gb As Integer = Lsr(b, 8) And &HFF
- Dim Bb As Integer = b And &HFF
- 'Message(CStr(Ra) & "#" & CStr(Ga) & "#" & CStr(Ba), "OH NO!")
- Dim RProb As Integer = 255 - CInt(BigNum(Ra, Rb) - LittleNum(Ra, Rb))
- Dim GProb As Integer = 255 - CInt(BigNum(Ga, Gb) - LittleNum(Ga, Gb))
- Dim BProb As Integer = 255 - CInt(BigNum(Ba, Bb) - LittleNum(Ba, Bb))
- Dim outa As Float = CFloat(RProb + GProb + BProb) / CFloat(255 * 3)
- 'Message(CStr(RProb) & "#" & CStr(GProb) & "#" & CStr(BProb), "OK")
- Return outa
- End
- Public Function LittleNum(a As Integer, b As Integer) As Integer
- If a > b Then
- Return b
- End If
- If a < b Then
- Return a
- End If
- If a = b Then
- Return a
- End If
- End
- Public Function BigNum(a As Integer, b As Integer) As Integer
- If a > b Then
- Return a
- End If
- If a < b Then
- Return b
- End If
- If a = b Then
- Return a
- End If
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement