on xenial help sign in
More declarative luminance.
commit693ae8910bbfb6bf39ec8c46bf3bb9caf6029d9b authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 6 Mar 2014, 17:06 (13 years ago) parent9963fab
1 file changed+3−11
qml/Dash/Card.qml+3−11
qml/Dash/Card.qml+3−11
@@ -44,6 +44,8 @@ Item {
4444 anchors.fill: parent
4545 image: backgroundImage.source ? backgroundImage : null
4646
47+ property real luminance: 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b
48+
4749 property Image backgroundImage: Image {
4850 objectName: "backgroundImage"
4951 source: {
@@ -186,17 +188,7 @@ Item {
186188 text: cardData && cardData["summary"] || ""
187189 height: text ? implicitHeight : 0
188190 fontSize: "small"
189− color: getFontColor(background.color)
190−
191− function getLuminance(color) {
192− return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
193− }
194−
195191 // TODO karni: Change "grey" to Ubuntu.Components.Palette color once updated.
196− function getFontColor(backgroundColor) {
197− if (backgroundColor === undefined) return "grey";
198− var luminance = getLuminance(backgroundColor);
199− return luminance < 0.7 ? "white" : "grey"
200− }
192+ color: background.visible && background.luminance < 0.7 ? "white" : "grey"
201193 }
202194}