Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
Description
QTBUG-14731 provided support for accessing red, green and blue values of color type, but overall the QML color API is still pretty static.
Color is a fundamental property of visual interfaces. When developing interactive, real-time graphical systems procedural handling of the core types is often necessary when highlighting items with accented colors, pulsating colors to indicate an operation is ongoing, adding gradients and shadows to emphasise (e.g. top of visual stack) or deemphasize (e.g. disabled, secondary) items, transitioning between visual UI states, and so on. You can do a lot with shaders, but is often too laborous route for performing simple color operations.
As many modern UI toolkits are a mixture of QML and shaders would be nice to align the color type operations as much as possible between QML and shader languages like GLSL.
Some examples:
Making a color semi-transparent by overriding alpha channel:
colorB = Qt.color(colorA.rgb, opacity)
Accessing hue, saturation, value, e.g. increase saturation by 20%:
color.s = color.s * 1.2
Scalar multiplication
darkGray = 0.5 * gray
Mixing colors:
color = mix(colorA, colorB, 0.5) // Qt.tint is horrible API
Producing colors as combination from other colors:
colorX = Qt.color(colorA.rg, colorB.b, colorC.a)
Swizzling:
colorA.rgb = colorB.bgr
Attachments
Issue Links
- relates to
-
QTBUG-79330 Improve handling of Q_GADGETs in QML
- Open
Gerrit Reviews
For Gerrit Dashboard: QTBUG-77635 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
284680,4 | Modify Qt.rgba() to make colors with custom alpha values trivial | 5.15 | qt/qtdeclarative | Status: ABANDONED | -1 | 0 |
295378,3 | Implement modifying colors using methods | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
296654,8 | Implement Qt.alpha() | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |