Reply
Thread Tools
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:
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#2
color = Qt.darker(oldColor) ?
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following 2 Users Say Thank You to coderus For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#3
Originally Posted by coderus View Post
color = Qt.darker(oldColor) ?
Coderus thanks, but I don't understand where to put this line inside the code above...
I tried different variations, but nothing work... Of course I do something wrong...
Please, can you edit the code above ?
Thanks
 

The Following User Says Thank You to Schturman For This Useful Post:
Posts: 62 | Thanked: 319 times | Joined on Jan 2013 @ Grenoble, France
#4
Have you tried to play with the lightness value ? I guess a value of 0. should make all the range black, while a value of 1. will make the range white.

The saturation will make the colour be less coloured… I mean with a value of 0 and a lightness at 0.5, all the range will be grey.

(I did try but I guess so)
 

The Following User Says Thank You to dcaliste For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#5
Originally Posted by dcaliste View Post
Have you tried to play with the lightness value ? I guess a value of 0. should make all the range black, while a value of 1. will make the range white.

The saturation will make the colour be less coloured… I mean with a value of 0 and a lightness at 0.5, all the range will be grey.

(I did try but I guess so)
Yes, I tried to play with this values, but I didn't get the desired result...
 

The Following User Says Thank You to Schturman For This Useful Post:
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#6
Originally Posted by Schturman View Post
Coderus thanks, but I don't understand where to put this line inside the code above...
I tried different variations, but nothing work... Of course I do something wrong...
Please, can you edit the code above ?
Thanks
customFASTdialicon.framecolor = Qt.darker(value)
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

The Following User Says Thank You to coderus For This Useful Post:
Schturman's Avatar
Posts: 5,339 | Thanked: 4,133 times | Joined on Jan 2010 @ Israel
#7
Originally Posted by coderus View Post
customFASTdialicon.framecolor = Qt.darker(value)
Ohhh, I got it, thanks ! But not where you put it. It should be like this:
Qt.darker(Color.toHighlight(Color.fromHsva(customF ASTdialicon.framecolor/100, 1.0, 0.5, 1.0)))

Now I see visual darker effect on the rectangle color and can get the darker color code (for next usage), but I still can't see the darker rainbow above the slider itself.
It also ok if it not possible
 

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

Thread Tools

 
Forum Jump


All times are GMT. The time now is 13:29.