The code I had write :
@import Qt 4.7
Item
{
width: 256
height: 256
function updateSelectedColor()
{
ColorPickerContext.selected_red =
(1 - (cursor.y / height)) *
(1 + (cursor.x / width) * (main_red - 1))
ColorPickerContext.selected_green =
(1 - (cursor.y / height)) *
(1 + (cursor.x / width) * (main_green - 1))
ColorPickerContext.selected_blue =
(1 - (cursor.y / height)) *
(1 + (cursor.x / width) * (main_blue - 1))
}
Rectangle
{
width: parent.height
height: parent.width
transform: Rotation { angle: 90}
x: parent.width
y: 0
gradient: Gradient
{
GradientStop { position: 0.0; color:
Qt.rgba(main_red, main_green, main_blue, 1)}
GradientStop { position: 1.0; color: "white" }
}
}
Rectangle
{
anchors.fill: parent
gradient: Gradient
{
GradientStop { position: 0.0; color: Qt.rgba(0, 0, 0, 0) }
GradientStop { position: 1.0; color: Qt.rgba(0, 0, 0, 1) }
}
}
Image
{
id: cursor
x: width/2
y: height/2
source: "cursor.png"
}
MouseArea
{
acceptedButtons: Qt.LeftButton
anchors.fill: parent
onPressed:
{
cursor.x = mouseX - 4
cursor.y = mouseY - 4
updateSelectedColor()
}
onPositionChanged:
{
cursor.x = mouseX - 4
cursor.y = mouseY - 4
updateSelectedColor()
}
}
}@
I'm not expert in QML, so if someone have critics, I'm interessed.