Android Question Set color picker to hsb

B4XColorTemplate (XUI Views) is based on the HSV space.

There is a ColorToHSV method that converts a ARGB color to HSV array.
Thank you. It took a while to find B4XColorTemplate. I expected it to be in designer customview:)
HSV color picker:
Private Sub btn_color_Click
    'example of changing the buttons order and position
    Dim rs As ResumableSub = dialog.ShowTemplate(colorDia, "OK", "", "CANCEL")
    Dim ok As B4XView = dialog.GetButton(xui.DialogResponse_Positive)
    Dim cancel As B4XView = dialog.GetButton(xui.DialogResponse_Cancel)
    cancel.SetLayoutAnimated(0, 2dip, cancel.Top, cancel.Parent.Width / 2 - 4dip, cancel.Height)
    ok.SetLayoutAnimated(0, ok.Parent.Width / 2 + 2dip, ok.Top, ok.Parent.Width / 2 - 4dip, ok.Height)
    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then   
        Dim col() As Object  = colorDia.SelectedHSVColor
        Dim hue As Float = col(0) ' Hue
        Dim saturation As Float = col(1) ' Saturation
        Dim value As Float = col(2) ' Value
        Dim alpha As Float = col(3) ' Alpha
        Log($"The color values are ${hue}/${saturation}/${value}/ and ${alpha}"$)
    End If
End Sub
Upvote 0