Skip to content

Commit 845c765

Browse files
committed
resync and updated
1 parent db955d5 commit 845c765

File tree

6 files changed

+124
-6
lines changed

6 files changed

+124
-6
lines changed

resources/shaders/fire.frag

+57-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ uniform vec4 uGradient3;
2323
uniform vec4 uGradient4;
2424
uniform vec4 uGradient5;
2525

26+
//new
27+
uniform bool uRandomColor;
28+
uniform float uSeed;
29+
2630
// These may be configurable in the future.
2731
const float EDGE_FADE = 70.0;
2832
const float FADE_WIDTH = 0.1;
@@ -58,6 +62,36 @@ vec4 getFireColor(float v) {
5862
return colors[4];
5963
}
6064

65+
vec4 getFireColorV2(float v, vec4 c0, vec4 c1, vec4 c2, vec4 c3, vec4 c4)
66+
{
67+
float steps[5];
68+
steps[0] = 0.0;
69+
steps[1] = 0.2;
70+
steps[2] = 0.35;
71+
steps[3] = 0.5;
72+
steps[4] = 0.8;
73+
74+
vec4 colors[5];
75+
colors[0] = c0;
76+
colors[1] = c1;
77+
colors[2] = c2;
78+
colors[3] = c3;
79+
colors[4] = c4;
80+
81+
if (v < steps[0]) {
82+
return colors[0];
83+
}
84+
85+
for (int i = 0; i < 4; ++i) {
86+
if (v <= steps[i + 1]) {
87+
return mix(colors[i], colors[i + 1],
88+
vec4(v - steps[i]) / (steps[i + 1] - steps[i]));
89+
}
90+
}
91+
92+
return colors[4];
93+
}
94+
6195
// This method requires the uniforms from standardUniforms() to be available.
6296
// It returns two values: The first is an alpha value which can be used for the window
6397
// texture. This gradually dissolves the window from top to bottom. The second can be used
@@ -114,7 +148,28 @@ void main() {
114148
noise *= effectMask.y;
115149

116150
// Map noise value to color.
117-
vec4 fire = getFireColor(noise);
151+
vec4 fire = vec4(0.0);
152+
153+
if (uRandomColor)
154+
{
155+
vec3 baseColor0 = offsetHue(vec3(1.0,0.0,0.0), hash11(uSeed));
156+
vec3 baseColor1 = offsetHue(baseColor0, 0.1);
157+
vec3 baseColor2 = offsetHue(baseColor1, 0.1);
158+
159+
//hardcoding alpha values
160+
vec4 c0 = vec4(baseColor0,0.0);
161+
vec4 c1 = vec4(baseColor0,0.3);
162+
vec4 c2 = vec4(baseColor1,0.6);
163+
vec4 c3 = vec4(baseColor1,0.9);
164+
vec4 c4 = vec4(baseColor2,1.0);
165+
166+
167+
fire = getFireColorV2(noise,c0,c1,c2,c3,c4);
168+
}
169+
else
170+
{
171+
fire = getFireColor(noise);
172+
}
118173

119174
// Get the window texture.
120175
vec4 oColor = getInputColor(iTexCoord.st);
@@ -131,4 +186,4 @@ void main() {
131186
// oColor = vec4(vec3(effectMask.y), 1);
132187

133188
setOutputColor(oColor);
134-
}
189+
}

resources/ui/adw/fire.ui

+23-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,28 @@ SPDX-License-Identifier: GPL-3.0-or-later
147147
</object>
148148
</child>
149149

150+
<child>
151+
<object class="AdwActionRow">
152+
<property name="title" translatable="yes">Use Random Color</property>
153+
<property name="activatable-widget">fire-random-color</property>
154+
<child>
155+
<object class="GtkSwitch" id="fire-random-color">
156+
<property name="valign">center</property>
157+
</object>
158+
</child>
159+
<child>
160+
<object class="GtkButton" id="reset-fire-random-color">
161+
<property name="icon-name">edit-clear-symbolic</property>
162+
<property name="valign">center</property>
163+
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
164+
<style>
165+
<class name="flat" />
166+
</style>
167+
</object>
168+
</child>
169+
</object>
170+
</child>
171+
150172
<child>
151173
<object class="AdwActionRow">
152174
<property name="title" translatable="yes">Gradient</property>
@@ -206,4 +228,4 @@ SPDX-License-Identifier: GPL-3.0-or-later
206228
</child>
207229
</object>
208230

209-
</interface>
231+
</interface>

schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ SPDX-License-Identifier: CC0-1.0
242242
<description>The size of the fire.</description>
243243
</key>
244244

245+
<key name="fire-random-color" type="b">
246+
<default>false</default>
247+
<summary>use a random color for the fire</summary>
248+
<description>use a random color of the fire</description>
249+
</key>
250+
245251
<key name="fire-3d-noise" type="b">
246252
<default>false</default>
247253
<summary>Fire 3D Noise</summary>
@@ -1110,4 +1116,4 @@ SPDX-License-Identifier: CC0-1.0
11101116

11111117
</schema>
11121118

1113-
</schemalist>
1119+
</schemalist>

src/Shader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export var Shader = GObject.registerClass({
6161
}
6262
},
6363

64-
class Shader extends Shell.GLSLEffect {
64+
class Shader extends Shell.GLSLEffect{
6565
// --------------------------------------------
6666
// The constructor automagically loads the shader's source code (in
6767
// vfunc_build_pipeline()) from the resource file resources/shaders/<nick>.glsl

src/ShaderFactory.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default class ShaderFactory {
6161
// Only try to register the new type once.
6262
if (GObject.type_from_name(typeName) == null) {
6363
const outerThis = this;
64-
GObject.registerClass({GTypeName: typeName}, class ShaderImp extends Shader {
64+
GObject.registerClass({GTypeName: typeName}, class ShaderImp extends Shader{
6565
// This will actually load the GLSL source code from the resources.
6666
_init() {
6767
super._init(outerThis._nick);

src/effects/Fire.js

+35
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// SPDX-FileCopyrightText: Simon Schneegans <[email protected]>
1313
// SPDX-License-Identifier: GPL-3.0-or-later
1414

15+
// modified by Justin Garza <[email protected]>
16+
1517
'use strict';
1618

1719
import Gio from 'gi://Gio';
@@ -58,6 +60,9 @@ export default class Effect {
5860
shader._uScale = shader.get_uniform_location('uScale');
5961
shader._uMovementSpeed = shader.get_uniform_location('uMovementSpeed');
6062

63+
shader._uRandomColor = shader.get_uniform_location('uRandomColor');
64+
shader._uSeed = shader.get_uniform_location('uSeed');
65+
6166
// And update all uniforms at the start of each animation.
6267
shader.connect('begin-animation', (shader, settings) => {
6368
for (let i = 1; i <= 5; i++) {
@@ -68,6 +73,8 @@ export default class Effect {
6873

6974
// clang-format off
7075
shader.set_uniform_float(shader._u3DNoise, 1, [settings.get_boolean('fire-3d-noise')]);
76+
shader.set_uniform_float(shader._uRandomColor, 1, [settings.get_boolean('fire-random-color')]);
77+
shader.set_uniform_float(shader._uSeed, 1, [Math.random()]);
7178
shader.set_uniform_float(shader._uScale, 1, [settings.get_double('fire-scale')]);
7279
shader.set_uniform_float(shader._uMovementSpeed, 1, [settings.get_double('fire-movement-speed')]);
7380
// clang-format on
@@ -107,6 +114,7 @@ export default class Effect {
107114
dialog.bindAdjustment('fire-movement-speed');
108115
dialog.bindAdjustment('fire-scale');
109116
dialog.bindSwitch('fire-3d-noise');
117+
dialog.bindSwitch('fire-random-color');
110118
dialog.bindColorButton('fire-color-1');
111119
dialog.bindColorButton('fire-color-2');
112120
dialog.bindColorButton('fire-color-3');
@@ -129,6 +137,33 @@ export default class Effect {
129137
// Initialize the fire-preset dropdown.
130138
Effect._createFirePresets(dialog);
131139
}
140+
141+
// enables and disables the color buttons
142+
function EnableDisableColorButtons(dialog, state) {
143+
144+
for (let i = 1; i <= 5; i++) {
145+
dialog.getBuilder().get_object('fire-color-' + i).set_sensitive(!state);
146+
}
147+
}
148+
149+
const switchWidget = dialog.getBuilder().get_object('fire-random-color');
150+
if (switchWidget) {
151+
// Connect to the "state-set" signal to update preferences dynamically based on
152+
// the switch state.
153+
switchWidget.connect('state-set', (widget, state) => {
154+
EnableDisableColorButtons(dialog,
155+
state); // Update sensitivity when the state changes.
156+
});
157+
158+
// Manually call the update function on startup, using the initial state of the
159+
// switch.
160+
const initialState =
161+
switchWidget.get_active(); // Get the current state of the switch.
162+
EnableDisableColorButtons(dialog, initialState);
163+
} else {
164+
// Log an error if the switch widget is not found in the UI.
165+
log('Error: \'fire-random-color\' switch widget not found.');
166+
}
132167
}
133168

134169
// ---------------------------------------------------------------- API for extension.js

0 commit comments

Comments
 (0)