Aggiornamento gradazione rettangolo colore
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports System.Drawing.Configuration
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Public Class EgtColorPickerV
|
||||
@@ -62,7 +63,7 @@ Public Class EgtColorPickerV
|
||||
Dim ton As Double = dY / MyCanvas.ActualHeight
|
||||
Dim lum As Double = dL / MyCanvasL.ActualHeight
|
||||
|
||||
Dim r, g, b As Integer
|
||||
'Dim r, g, b As Integer
|
||||
|
||||
If dX > 0 AndAlso dX < MyCanvas.ActualWidth And dY > 0 AndAlso dY < MyCanvas.ActualHeight Then
|
||||
Ellipse.Visibility = Visibility.Visible
|
||||
@@ -75,9 +76,12 @@ Public Class EgtColorPickerV
|
||||
Ellipse.Visibility = Visibility.Collapsed
|
||||
End If
|
||||
|
||||
HlsToRgb(sat, lum, 1 - ton, r, g, b)
|
||||
'HlsToRgb(sat, lum, 1 - ton, r, g, b)
|
||||
|
||||
Dim col As Color = Media.Color.FromRgb(r, g, b)
|
||||
Dim colargb As System.Drawing.Color = ColorFromHSV(sat, ton, lum)
|
||||
|
||||
Dim col As Color = Media.Color.FromRgb(colargb.R, colargb.G, colargb.B)
|
||||
'Dim col As Color = Media.Color.FromRgb(r, g, b)
|
||||
m_EgtColorPickerVM.SetCurrColorFill(col)
|
||||
End Sub
|
||||
|
||||
@@ -109,11 +113,13 @@ Public Class EgtColorPickerV
|
||||
Dim ton As Double = dY / MyCanvas.ActualHeight
|
||||
Dim lum As Double = dL / MyCanvasL.ActualHeight
|
||||
|
||||
Dim r, g, b As Integer
|
||||
'Dim r, g, b As Integer
|
||||
|
||||
HlsToRgb(sat, 1 - lum, 1 - ton, r, g, b)
|
||||
'HlsToRgb(sat, 1 - lum, 1 - ton, r, g, b)
|
||||
|
||||
Dim col As Color = Media.Color.FromRgb(r, g, b)
|
||||
Dim colargb As System.Drawing.Color = ColorFromHSV(sat, ton, 1 - lum)
|
||||
|
||||
Dim col As Color = Media.Color.FromRgb(colargb.R, colargb.G, colargb.B)
|
||||
m_EgtColorPickerVM.SetLuminosityColorFill(col)
|
||||
End Sub
|
||||
#End Region
|
||||
@@ -133,12 +139,12 @@ Public Class EgtColorPickerV
|
||||
Dim p2 As Double
|
||||
|
||||
If l <= 0.5 Then
|
||||
p2 = l * (1 + s)
|
||||
p2 = l * (1.0 + s)
|
||||
Else
|
||||
p2 = l + s - l * s
|
||||
End If
|
||||
|
||||
Dim p1 As Double = 2 * l - p2
|
||||
Dim p1 As Double = 2.0 * l - p2
|
||||
Dim double_r, double_g, double_b As Double
|
||||
|
||||
If s = 0 Then
|
||||
@@ -169,6 +175,30 @@ Public Class EgtColorPickerV
|
||||
Return q1
|
||||
End Function
|
||||
|
||||
Public Shared Function ColorFromHSV(ByVal hue As Double, ByVal saturation As Double, ByVal value As Double) As System.Drawing.Color
|
||||
Dim hi As Integer = Convert.ToInt32(Math.Floor(hue / 60)) Mod 6
|
||||
Dim f As Double = hue / 60 - Math.Floor(hue / 60)
|
||||
value *= 255
|
||||
Dim v As Integer = Convert.ToInt32(value)
|
||||
Dim p As Integer = Convert.ToInt32(value * (1 - saturation))
|
||||
Dim q As Integer = Convert.ToInt32(value * (1 - f * saturation))
|
||||
Dim t As Integer = Convert.ToInt32(value * (1 - (1 - f) * saturation))
|
||||
|
||||
If hi = 0 Then
|
||||
Return System.Drawing.Color.FromArgb(255, v, t, p)
|
||||
ElseIf hi = 1 Then
|
||||
Return System.Drawing.Color.FromArgb(255, q, v, p)
|
||||
ElseIf hi = 2 Then
|
||||
Return System.Drawing.Color.FromArgb(255, p, v, t)
|
||||
ElseIf hi = 3 Then
|
||||
Return System.Drawing.Color.FromArgb(255, p, q, v)
|
||||
ElseIf hi = 4 Then
|
||||
Return System.Drawing.Color.FromArgb(255, t, p, v)
|
||||
Else
|
||||
Return System.Drawing.Color.FromArgb(255, v, p, q)
|
||||
End If
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Apre una finestra EgtColorPicker
|
||||
''' </summary>
|
||||
|
||||
@@ -46,7 +46,7 @@ Public Class EgtColorPickerVM
|
||||
For i As Integer = 0 To value.Length - 1
|
||||
coloraRGB = System.Drawing.Color.FromArgb(value(i).ToString)
|
||||
colorRGB = Color.FromRgb(coloraRGB.R, coloraRGB.G, coloraRGB.B)
|
||||
m_CustomColors.Insert(0, New EgtColorPicker(New SolidColorBrush(colorRGB)))
|
||||
m_CustomColors.Insert(i, New EgtColorPicker(New SolidColorBrush(colorRGB)))
|
||||
m_CustomColors.RemoveAt(m_CustomColors.Count - 1)
|
||||
Next
|
||||
m_CustomColors.Reverse()
|
||||
|
||||
Reference in New Issue
Block a user