How to get color value at Click position?
-
Hi everyone!
I have Rectangle with gradient and ColorAnimation
I want to send signal on click with selected color. But I can’t know color of pixel at given position.
Have you ideas to do this ?
Thanks! -
My code Rectangle
@import QtQuick 2.0Rectangle{
id:rect
width:300
height:300
rotation:-90
property color colorValue: rect.color
gradient: Gradient {
GradientStop {
position: 0.0
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
ColorAnimation { from: "black"; to: "green"; duration: 2000 }
}
}
GradientStop {
position: 0.16
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
ColorAnimation { from: "black"; to: "green"; duration: 2000 }
ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
}
}
GradientStop {
position: 0.33
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
ColorAnimation { from: "black"; to: "green"; duration: 2000 }
ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
}
}
GradientStop {
position: 0.5
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
ColorAnimation { from: "black"; to: "green"; duration: 2000 }
ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
}
}
GradientStop {
position: 0.76
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
ColorAnimation { from: "black"; to: "green"; duration: 2000 }
ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
}
}
GradientStop {
position: 0.85
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
ColorAnimation { from: "black"; to: "green"; duration: 2000 }
ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
}
}
GradientStop {
position: 1.0
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "black"; to: "green"; duration: 2000 }
ColorAnimation { from: "green"; to: "blue"; duration: 2000 }
ColorAnimation { from: "blue"; to: "white"; duration: 2000 }
ColorAnimation { from: "white"; to: "purple"; duration: 2000 }
ColorAnimation { from: "purple"; to: "red"; duration: 2000 }
ColorAnimation { from: "red"; to: "yellow"; duration: 2000 }
ColorAnimation { from: "yellow"; to: "black"; duration: 2000 }
ColorAnimation { from: "black"; to: "green"; duration: 2000 }
}
}
}}
@