Option Explicit
Private Declare Function ColorHLSToRGB Lib "shlwapi" (ByVal wHue As Integer, ByVal wLuminance As Integer, ByVal wSaturation As Integer) As Long
Private Hue As Integer, Saturation As Integer
Private Sub Form_Load()
Width = 256 * Screen.TwipsPerPixelX + (Width - ScaleWidth)
Height = 256 * Screen.TwipsPerPixelY + (Height - ScaleHeight)
AutoRedraw = True: ScaleMode = vbPixels
For Hue = 0 To 239
For Saturation = 0 To 239
PSet (Hue, 239 - Saturation), ColorHLSToRGB(Hue, 120, Saturation)
Next
Next
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Y < 240 Then
If X < 240 Then
Hue = X
Saturation = 239 - Y
Dim Luminance As Integer
For Luminance = 0 To 239
Line (240, 239 - Luminance)-(255, 239 - Luminance), ColorHLSToRGB(Hue, Luminance, Saturation)
Next
ElseIf Y < 256 Then
Line (0, 240)-(255, 255), ColorHLSToRGB(Hue, Y, Saturation), BF
End If
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then Form_MouseDown Button, Shift, X, Y
End Sub
BV писал(а):Цвет можно брать и с GetPixel.
Line (0, 240)-(255, 255), ColorHLSToRGB(Hue, Y, Saturation), BF
Option Explicit
Private Declare Function ColorHLSToRGB Lib "shlwapi" (ByVal wHue As Integer, ByVal wLuminance As Integer, ByVal wSaturation As Integer) As Long
Private Sub Form_Load()
Width = 256 * Screen.TwipsPerPixelX + (Width - ScaleWidth)
Height = 256 * Screen.TwipsPerPixelY + (Height - ScaleHeight)
AutoRedraw = True: ScaleMode = vbPixels
Dim Hue As Integer, Saturation As Integer
For Hue = 0 To 239
For Saturation = 1 To 239
PSet (Hue, 239 - Saturation), ColorHLSToRGB(Hue, 120, Saturation)
Next
Next
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Y < 240 Then
If X < 240 Then
Dim Luminance As Integer
For Luminance = 1 To 239
Line (240, 239 - Luminance)-(255, 239 - Luminance), ColorHLSToRGB(X, Luminance, 239 - Y)
Next
ElseIf Y < 256 Then
Line (0, 240)-(255, 255), Point(X, Y), BF
End If
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then Form_MouseDown Button, Shift, X, Y
End Sub
Cryonyx писал(а):Слушайте, а почему все значения HLS колеблются в диапазоне [0;239], а не [0;255]
tyomitch писал(а):Почему в часе 60 минут, а не 80? Потому же: кому-то так захотелось.
Cryonyx писал(а):Слушайте, а почему все значения HLS колеблются в диапазоне [0;239], а не [0;255]
Сейчас этот форум просматривают: Google-бот, Yandex-бот и гости: 33