From e3d8992a35fbf852fc63369b3d71e899966a5697 Mon Sep 17 00:00:00 2001 From: Firemark Date: Fri, 1 Aug 2014 00:04:59 +0200 Subject: [PATCH] Add two settings to change colors. --- app/ApplicationSettings.qml | 9 +++++++- app/SettingsTerminalTab.qml | 42 ++++++++++++++++++++++++------------- app/ShaderTerminal.qml | 21 +++++++++++++++---- 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/app/ApplicationSettings.qml b/app/ApplicationSettings.qml index 9daf9b2..d6e9a58 100644 --- a/app/ApplicationSettings.qml +++ b/app/ApplicationSettings.qml @@ -67,6 +67,9 @@ Item{ property real motion_blur: 0.40 property real bloom_strength: 0.65 + property real chroma_color: 0.0 + property real saturation_color: 0.0 + property real jitter: 0.18 property real horizontal_sincronization: 0.08 @@ -171,6 +174,8 @@ Item{ brightness_flickering: brightness_flickering, horizontal_sincronization: horizontal_sincronization, noise_strength: noise_strength, + chroma_color: chroma_color, + saturation_color: saturation_color, screen_distortion: screen_distortion, glowing_line_strength: glowing_line_strength, frames_index: frames_index, @@ -234,6 +239,8 @@ Item{ horizontal_sincronization = settings.horizontal_sincronization !== undefined ? settings.horizontal_sincronization : horizontal_sincronization brightness_flickering = settings.brightness_flickering !== undefined ? settings.brightness_flickering : brightness_flickering; noise_strength = settings.noise_strength !== undefined ? settings.noise_strength : noise_strength; + chroma_color = settings.chroma_color !== undefined ? settings.chroma_color : chroma_color; + saturation_color = settings.saturation_color !== undefined ? settings.saturation_color : saturation_color; screen_distortion = settings.screen_distortion !== undefined ? settings.screen_distortion : screen_distortion; glowing_line_strength = settings.glowing_line_strength !== undefined ? settings.glowing_line_strength : glowing_line_strength; @@ -333,7 +340,7 @@ Item{ } ListElement{ text: "IBM Dos" - obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.07,"contrast":0.85,"fontIndex":7,"font_color":"#ffffff","frames_index":1,"glowing_line_strength":0.13,"horizontal_sincronization":0,"jitter":0.08,"motion_blur":0.3,"noise_strength":0.03,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1}' + obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.4,"brightness":0.5,"brightness_flickering":0.07,"contrast":0.85,"fontIndex":7,"font_color":"#ffffff","frames_index":1,"glowing_line_strength":0.13,"horizontal_sincronization":0,"jitter":0.08,"motion_blur":0.3,"noise_strength":0.03,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":1}' builtin: true } ListElement{ diff --git a/app/SettingsTerminalTab.qml b/app/SettingsTerminalTab.qml index 04e473f..07f5ba6 100644 --- a/app/SettingsTerminalTab.qml +++ b/app/SettingsTerminalTab.qml @@ -92,21 +92,35 @@ Tab{ GroupBox{ title: qsTr("Colors") Layout.fillWidth: true - RowLayout{ - anchors.fill: parent - ColorButton{ - name: qsTr("Font") - height: 50 - Layout.fillWidth: true - onColorSelected: shadersettings._font_color = color; - button_color: shadersettings._font_color + ColumnLayout{ + RowLayout{ + anchors.fill: parent + ColorButton{ + name: qsTr("Font") + height: 50 + Layout.fillWidth: true + onColorSelected: shadersettings._font_color = color; + button_color: shadersettings._font_color + } + ColorButton{ + name: qsTr("Background") + height: 50 + Layout.fillWidth: true + onColorSelected: shadersettings._background_color = color; + button_color: shadersettings._background_color + } } - ColorButton{ - name: qsTr("Background") - height: 50 - Layout.fillWidth: true - onColorSelected: shadersettings._background_color = color; - button_color: shadersettings._background_color + ColumnLayout{ + CheckableSlider{ + name: qsTr("Chroma Color") + onValueChanged: shadersettings.chroma_color = value + _value: shadersettings.chroma_color + } + CheckableSlider{ + name: qsTr("Saturation Color") + onValueChanged: shadersettings.saturation_color = value + _value: shadersettings.saturation_color + } } } } diff --git a/app/ShaderTerminal.qml b/app/ShaderTerminal.qml index 26a9729..9a411d5 100644 --- a/app/ShaderTerminal.qml +++ b/app/ShaderTerminal.qml @@ -39,6 +39,9 @@ ShaderEffect { property real screen_distorsion: shadersettings.screen_distortion property real glowing_line_strength: shadersettings.glowing_line_strength + property real chroma_color: shadersettings.chroma_color; + property real saturation_color: shadersettings.saturation_color; + property real brightness_flickering: shadersettings.brightness_flickering property real horizontal_sincronization: shadersettings.horizontal_sincronization @@ -184,10 +187,20 @@ ShaderEffect { (glowing_line_strength !== 0 ? " color += randomPass(coords) * glowing_line_strength;" : "") + - "vec4 realBackColor = texture2D(source, txt_coords);" + - "vec4 mixedColor = mix(realBackColor * font_color, font_color, 0.0);" + - "vec4 finalBackColor = mix(background_color, mixedColor, realBackColor.a);" + - "vec3 finalColor = mix(finalBackColor, font_color, color).rgb;" + + (chroma_color !== 0 ? + "vec4 realBackColor = texture2D(source, txt_coords);" + + (saturation_color !== 0 ? + "vec4 satured_font_color = mix(font_color, vec4(1) , "+ str(saturation_color) + ");" + + "vec4 mixedColor = mix(font_color, realBackColor * satured_font_color, "+ str(chroma_color) +");": + "vec4 mixedColor = mix(font_color, realBackColor * font_color, "+ str(chroma_color) +");" + ) + + + "vec4 finalBackColor = mix(background_color, mixedColor, realBackColor.a);" + + "vec3 finalColor = mix(finalBackColor, font_color, color).rgb;" : + "color += texture2D(source, txt_coords).a;" + + "vec3 finalColor = mix(background_color, font_color, color).rgb;" + ) + + "finalColor *= texture2D(rasterizationSource, coords).a;" + (bloom !== 0 ? "