View Single Post
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#1
Hi to all.
I use this slider (thanks to Ancelad) to get color code (see image below) and for visual effects in the setting. And I want to change this color gamma to darker colors. This code I use, maybe someone can help me and edit this code (if it possible at all) ?
Thanks

Code:
            Slider {
                id: slider
                Rectangle {
            id: background
            x: slider.leftMargin
            z: -1
            width: slider._grooveWidth
            height: Theme.paddingMedium
            anchors.top: parent.verticalCenter
            anchors.topMargin: -Theme.paddingLarge*2
            
                    ShaderEffect {
                        id: rainbow
                        property variant src: background
                        property real saturation: 1.0
                        property real lightness: 0.5
                        property real alpha: 1.0
            
                        width: parent.width
                        height: parent.height
            
                        // Fragment shader to create hue color wheel background
                        fragmentShader: "
                            varying highp vec2 coord;
                            varying highp vec2 qt_TexCoord0;
                            uniform sampler2D src;
                            uniform lowp float qt_Opacity;
                            uniform lowp float saturation;
                            uniform lowp float lightness;
                            uniform lowp float alpha;
            
                            void main() {
                                float r, g, b;
            
                                float h = qt_TexCoord0.x * 360.0;
                                float s = saturation;
                                float l = lightness;
            
                                float c = (1.0 - abs(2.0 * l - 1.0)) * s;
                                float hh = h / 60.0;
                                float x = c * (1.0 - abs(mod(hh, 2.0) - 1.0));
            
                                int i = int( hh );
            
                                if (i == 0) {
                                    r = c; g = x; b = 0.0;
                                } else if (i == 1) {
                                    r = x; g = c; b = 0.0;
                                } else if (i == 2) {
                                    r = 0.0; g = c; b = x;
                                } else if (i == 3) {
                                    r = 0.0; g = x; b = c;
                                } else if (i == 4) {
                                    r = x; g = 0.0; b = c;
                                } else if (i == 5) {
                                    r = c; g = 0.0; b = x;
                                } else {
                                    r = 0.0; g = 0.0; b = 0.0;
                                }
            
                                float m = l - 0.5 * c;
            
                                lowp vec4 tex = texture2D(src, qt_TexCoord0);
                                gl_FragColor = vec4(r+m,g+m,b+m,alpha) * qt_Opacity;
                            }"
                    }
                }    
                
                width: parent.width
                minimumValue: 0
                maximumValue: 100
                stepSize: 1
                value: customFASTdialicon.framecolor
                valueText: "◭"
                onValueChanged: customFASTdialicon.framecolor = value
                onPressAndHold: cancel()

        Label {
                    width: parent.width
                    wrapMode: Text.Wrap
                    font.pixelSize: Theme.fontSizeSmall
                    horizontalAlignment: Text.AlignHCenter
                    anchors.top: parent.verticalCenter
                    anchors.topMargin: Theme.paddingMedium*2.8
                    //color: Color.toHighlight(Color.fromHsva(customFASTdialicon.framecolor/100, 1.0, 0.5, 1.0))
                    text: qsTr("Choose frame color")
                }                        
            }
Attached Images
 
 

The Following User Says Thank You to Schturman For This Useful Post: