mirror of https://github.com/status-im/StatusQ.git
feat(StatusLetterIdenticon): use luminance to determine letter color
This commit is contained in:
parent
1cda85fc0e
commit
1e5d389b53
|
@ -29,7 +29,7 @@ Rectangle {
|
|||
|
||||
font.weight: Font.Bold
|
||||
font.pixelSize: root.letterSize
|
||||
color: Qt.rgba(255, 255, 255, 0.7)
|
||||
color: d.luminance(root.color) > 0.5 ? Qt.rgba(0, 0, 0, 0.5) : Qt.rgba(255, 255, 255, 0.7)
|
||||
|
||||
text: {
|
||||
if (emoji) {
|
||||
|
@ -45,5 +45,15 @@ Rectangle {
|
|||
return root.name.substring(shift, shift + charactersLen).toUpperCase()
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
function luminance(color) {
|
||||
let r = Math.pow(color.r, 2.2) * 0.2126
|
||||
let g = Math.pow(color.g, 2.2) * 0.7151
|
||||
let b = Math.pow(color.b, 2.2) * 0.0721
|
||||
return r + g + b
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,6 @@ Loader {
|
|||
emoji: statusSmartIdenticon.icon.emoji
|
||||
emojiSize: statusSmartIdenticon.icon.emojiSize
|
||||
letterSize: statusSmartIdenticon.icon.letterSize
|
||||
identiconText.color: statusSmartIdenticon.icon.textColor
|
||||
charactersLen: statusSmartIdenticon.icon.charactersLen
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ QtObject {
|
|||
property real width
|
||||
property real height
|
||||
property color color
|
||||
property color textColor: Qt.rgba(255, 255, 255, 0.7)
|
||||
property color disabledColor
|
||||
property url source
|
||||
property int rotation
|
||||
|
|
Loading…
Reference in New Issue