Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean merge ... #479

Closed
wants to merge 12 commits into from
20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,22 @@
/resources/burn-my-windows.gresource
/resources/burn-my-windows.gresource.xml
kwin/_build
kwin/*.tar.gz
kwin/*.tar.gz
.VSCodeCounter/2024-12-01_14-24-39/results.txt
.VSCodeCounter/2024-12-01_14-24-39/results.md
.VSCodeCounter/2024-12-01_14-24-39/results.json
.VSCodeCounter/2024-12-01_14-24-39/results.csv
.VSCodeCounter/2024-12-01_14-24-39/diff.txt
.VSCodeCounter/2024-12-01_14-24-39/diff.md
.VSCodeCounter/2024-12-01_14-24-39/diff.csv
.VSCodeCounter/2024-12-01_14-24-39/diff-details.md
.VSCodeCounter/2024-12-01_14-24-39/details.md
.VSCodeCounter/2024-12-01_14-22-46/results.txt
.VSCodeCounter/2024-12-01_14-22-46/results.md
.VSCodeCounter/2024-12-01_14-22-46/results.json
.VSCodeCounter/2024-12-01_14-22-46/results.csv
.VSCodeCounter/2024-12-01_14-22-46/diff.txt
.VSCodeCounter/2024-12-01_14-22-46/diff.md
.VSCodeCounter/2024-12-01_14-22-46/diff.csv
.VSCodeCounter/2024-12-01_14-22-46/diff-details.md
.VSCodeCounter/2024-12-01_14-22-46/details.md
Comment on lines +15 to +32
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this? I think it's very specific to you 😄

Suggested change
.VSCodeCounter/2024-12-01_14-24-39/results.txt
.VSCodeCounter/2024-12-01_14-24-39/results.md
.VSCodeCounter/2024-12-01_14-24-39/results.json
.VSCodeCounter/2024-12-01_14-24-39/results.csv
.VSCodeCounter/2024-12-01_14-24-39/diff.txt
.VSCodeCounter/2024-12-01_14-24-39/diff.md
.VSCodeCounter/2024-12-01_14-24-39/diff.csv
.VSCodeCounter/2024-12-01_14-24-39/diff-details.md
.VSCodeCounter/2024-12-01_14-24-39/details.md
.VSCodeCounter/2024-12-01_14-22-46/results.txt
.VSCodeCounter/2024-12-01_14-22-46/results.md
.VSCodeCounter/2024-12-01_14-22-46/results.json
.VSCodeCounter/2024-12-01_14-22-46/results.csv
.VSCodeCounter/2024-12-01_14-22-46/diff.txt
.VSCodeCounter/2024-12-01_14-22-46/diff.md
.VSCodeCounter/2024-12-01_14-22-46/diff.csv
.VSCodeCounter/2024-12-01_14-22-46/diff-details.md
.VSCodeCounter/2024-12-01_14-22-46/details.md

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ This extension is not only more useless than the cube, but it is also much more
| **Hexagon** <br> With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi. | <img src ="docs/pics/hexagon.gif" /> |
| **Incinerate** <br> A less snappy but definitely more fancy take on the fire effect. | <img src ="docs/pics/incinerate.gif" /> |
| **Matrix** <br> Turn your windows into a shower of green letters! The color is actually configurable. | <img src ="docs/pics/matrix.gif" /> |
| **Mushroom** <br> Inspired by your favorite italian plumber! | <img src ="docs/pics/mushroom.gif" /> |
| **Paint Brush** <br> Paint or erase your windows with a thick paint brush. | <img src ="docs/pics/paint-brush.gif" /> |
| **Pixelate** <br> Pixelate your windows and randomly hide pixels until the entire window is gone. | <img src ="docs/pics/pixelate.gif" /> |
| **Pixel Wheel** <br> This simple effect pixelates the window and hides the pixels in a wheel-like fashion. | <img src ="docs/pics/pixel-wheel.gif" /> |
Expand Down Expand Up @@ -77,6 +78,7 @@ Below is a table which summarizes the current availability for all effects.
<tr><td>Hexagon</td> <td>✅</td> <td>✅</td> <td>✅</td> <td>✅</td> </tr>
<tr><td>Incinerate</td> <td>✅</td> <td>✅</td> <td>✅</td> <td>✅</td> </tr>
<tr><td>Matrix</td> <td> </td> <td> </td> <td>✅</td> <td> </td> </tr>
<tr><td>Mushroom</td> <td>✅</td> <td>✅</td> <td>✅</td> <td>✅</td>✅</tr>
<tr><td>Paint Brush</td> <td> </td> <td> </td> <td>✅</td> <td> </td> </tr>
<tr><td>Pixelate</td> <td>✅</td> <td>✅</td> <td>✅</td> <td>✅</td> </tr>
<tr><td>Pixel Wheel</td> <td>✅</td> <td>✅</td> <td>✅</td> <td>✅</td> </tr>
Expand Down
Binary file added docs/pics/mushroom.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import TRexAttack from './src/effects/TRexAttack.js';
import TVEffect from './src/effects/TVEffect.js';
import TVGlitch from './src/effects/TVGlitch.js';
import Wisps from './src/effects/Wisps.js';

import Mushroom from './src/effects/Mushroom.js';

import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import {Workspace} from 'resource:///org/gnome/shell/ui/workspace.js';
Expand Down Expand Up @@ -78,7 +78,7 @@ export default class BurnMyWindows extends Extension {
new PaintBrush(), new Pixelate(), new PixelWheel(),
new PixelWipe(), new Portal(), new SnapOfDisintegration(),
new TRexAttack(), new TVEffect(), new TVGlitch(),
new Wisps(),
new Wisps(), new Mushroom(),
];

// Load all of our resources.
Expand Down
28 changes: 24 additions & 4 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Glitch from './src/effects/Glitch.js';
import Hexagon from './src/effects/Hexagon.js';
import Incinerate from './src/effects/Incinerate.js';
import Matrix from './src/effects/Matrix.js';
import Mushroom from './src/effects/Mushroom.js';
import PaintBrush from './src/effects/PaintBrush.js';
import Pixelate from './src/effects/Pixelate.js';
import PixelWheel from './src/effects/PixelWheel.js';
Expand Down Expand Up @@ -71,10 +72,29 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences {

// New effects must be registered here and in extension.js.
this._ALL_EFFECTS = [
Apparition, BrokenGlass, Doom, EnergizeA, EnergizeB, Fire,
Focus, Glide, Glitch, Hexagon, Incinerate, Matrix,
PaintBrush, Pixelate, PixelWheel, PixelWipe, Portal, SnapOfDisintegration,
TRexAttack, TVEffect, TVGlitch, Wisps,
Apparition,
BrokenGlass,
Doom,
EnergizeA,
EnergizeB,
Fire,
Focus,
Glide,
Glitch,
Hexagon,
Incinerate,
Matrix,
Mushroom,
PaintBrush,
Pixelate,
PixelWheel,
PixelWipe,
Portal,
SnapOfDisintegration,
TRexAttack,
TVEffect,
TVGlitch,
Wisps,
];


Expand Down
163 changes: 163 additions & 0 deletions resources/shaders/common.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,119 @@ float easeOutBack(float x, float e) {
return p * p * ((e + 1.0) * p + e) + 1.0;
}


// https://easings.net/
/*
Easing functions define the rate of change of a parameter over time, commonly used in animations, UI transitions, and game development. They provide a way to make movements more natural or visually appealing rather than linear and mechanical. Popular categories of easing functions include:

Linear: Constant speed from start to finish.
Quadratic (Ease In, Ease Out, Ease In Out): Changes at varying rates, with smoother starts or stops.
Cubic: Similar to quadratic but allows for even more nuanced transitions.
Exponential: Drastic changes at the start or end, often used for dramatic effects.
Bounce: Mimics a bouncing object with oscillations.
Elastic: Simulates the behavior of a spring, with overshooting and oscillations.
Below are text-based "graphs" of some easing functions, where the horizontal axis represents time and the vertical axis represents progress.
*/


// Quadratic Easing
// Smooth acceleration and deceleration using quadratic (t^2) curves.

float easeInOutQuad(float t) {
// Accelerates for the first half, decelerates for the second half.
return t < 0.5 ? 2.0 * t * t : -1.0 + (4.0 - 2.0 * t) * t;
}

// Cubic Easing
// Smoother transitions compared to quadratic easing using cubic (t^3) curves.

float easeInCubic(float t) {
// Starts slow and accelerates as t increases.
return t * t * t;
}

float easeOutCubic(float t) {
// Starts fast and decelerates as t approaches 1.0.
float f = t - 1.0;
return f * f * f + 1.0;
}

float easeInOutCubic(float t) {
// Combines easeIn and easeOut cubic behavior for smooth transitions.
return t < 0.5 ? 4.0 * t * t * t : (t - 1.0) * (2.0 * t - 2.0) * (2.0 * t - 2.0) + 1.0;
}

// Quartic Easing
// Even smoother transitions than cubic, using quartic (t^4) curves.

float easeInQuart(float t) {
// Starts very slow and accelerates steeply.
return t * t * t * t;
}

float easeOutQuart(float t) {
// Starts steeply and slows down dramatically.
float f = t - 1.0;
return 1.0 - f * f * f * f;
}

float easeInOutQuart(float t) {
// Combines easeIn and easeOut quartic behavior for very smooth transitions.
return t < 0.5 ? 8.0 * t * t * t * t : 1.0 - 8.0 * (t - 1.0) * (t - 1.0) * (t - 1.0) * (t - 1.0);
}

// Sine Easing
// Smooth, wave-like acceleration and deceleration using sine curves.

float easeInSine(float t) {
// Starts very slow, following a sine wave curve.
return 1.0 - cos((t * 3.141592653589793) / 2.0);
}

float easeOutSine(float t) {
// Starts fast and slows down following a sine wave curve.
return sin((t * 3.141592653589793) / 2.0);
}

float easeInOutSine(float t) {
// Smooth start and end, mimicking half a sine wave.
return -0.5 * (cos(3.141592653589793 * t) - 1.0);
}

// Exponential Easing
// Sharp transitions with rapid acceleration and deceleration.

float easeInExpo(float t) {
// Very slow start, accelerates exponentially.
return t == 0.0 ? 0.0 : pow(2.0, 10.0 * (t - 1.0));
}

float easeOutExpo(float t) {
// Starts fast and slows down exponentially.
return t == 1.0 ? 1.0 : 1.0 - pow(2.0, -10.0 * t);
}

float easeInOutExpo(float t) {
// Combines easeIn and easeOut exponential for sharp transitions.
if (t == 0.0) return 0.0;
if (t == 1.0) return 1.0;
return t < 0.5 ? 0.5 * pow(2.0, 20.0 * t - 10.0) : 1.0 - 0.5 * pow(2.0, -20.0 * t + 10.0);
}

// Back Easing
// Creates an overshooting effect for more dynamic animations.

float easeInOutBack(float t) {
// Uses constants to define the overshooting magnitude.
const float c1 = 1.70158;
const float c2 = c1 * 1.525;
return t < 0.5
? (pow(2.0 * t, 2.0) * ((c2 + 1.0) * 2.0 * t - c2)) / 2.0
: (pow(2.0 * t - 2.0, 2.0) * ((c2 + 1.0) * (t * 2.0 - 2.0) + c2) + 2.0) / 2.0;
}



// --------------------------------------------------------------------- edge mask helpers

// This method returns a mask which smoothly transitions towards zero when approaching
Expand Down Expand Up @@ -470,3 +583,53 @@ float simplex3DFractal(vec3 m) {
return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +
0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);
}


// --------------------------------------------------------------------------------- remap


/*
These functions remap a given value from one range to another.
The remap operation is particularly useful in shader programming
to scale or normalize data, ensuring compatibility across various
input ranges. Each version of the remap function supports a
different data type:

1. float: Remap a single scalar value.
2. vec2: Remap a 2D vector.
3. vec3: Remap a 3D vector.
4. vec4: Remap a 4D vector.

The general formula used is:
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin)

This ensures a linear transformation from the old range to the new range.
*/

// Remap for float
// Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].
// This is useful for normalizing or scaling scalar values to fit within a desired range.
float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
}

// Remap for vec2
// Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin, newMax].
// Each component of the vec2 is individually scaled and transformed.
vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
}

// Remap for vec3
// Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin, newMax].
// Each component of the vec3 is individually scaled and transformed.
vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
}

// Remap for vec4
// Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin, newMax].
// Each component of the vec4 is individually scaled and transformed.
vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
}
52 changes: 32 additions & 20 deletions resources/shaders/focus.frag
Original file line number Diff line number Diff line change
Expand Up @@ -30,57 +30,69 @@
// vec4 getInputColor(vec2 coords)
// void setOutputColor(vec4 outColor)


// Ease-in-out cubic for alpha
float easeInOutCubic(float x) {
return x < 0.5 ? 4.0 * x * x * x : 1.0 - pow(-2.0 * x + 2.0, 3.0) / 2.0;
}

// Ease-in-out sine for blur
float easeInOutSine(float x) {
return -(cos(3.14159265 * x) - 1.0) / 2.0;
}

// A simple blur function
vec4 blur(vec2 uv, float radius, float samples) {
// Initialize the color accumulator to zero.
vec4 color = vec4(0.0);

const float tau = 6.28318530718;
// Define a constant for 2 * PI (tau), which represents a full circle in radians.
const float tau = 6.28318530718;

// Number of directions for sampling around the circle.
const float directions = 15.0;

// Outer loop iterates over multiple directions evenly spaced around a circle.
for (float d = 0.0; d < tau; d += tau / directions) {
// Inner loop samples along each direction, with decreasing intensity.
for (float s = 0.0; s < 1.0; s += 1.0 / samples) {
// Calculate the offset for this sample based on direction, radius, and step.
// The (1.0 - s) term ensures more sampling occurs closer to the center.
vec2 offset = vec2(cos(d), sin(d)) * radius * (1.0 - s) / uSize;

// Add the sampled color at the offset position to the accumulator.
color += getInputColor(uv + offset);
}
}

// Normalize the accumulated color by dividing by the total number of samples
// and directions to ensure the result is averaged.
return color / samples / directions;
}



// The width of the fading effect is loaded from the settings.
uniform float uBlurAmount;
uniform float uBlurQuality;

void main() {

// Calculate the progression value based on the animation direction.
// If opening, use uProgress as-is; if closing, invert the progression.
float progl = uForOpening ? uProgress : 1.0 - uProgress;

float easedProgressBlur = easeInOutSine(progl); // Blur easing
float easedProgressAlpha = easeInOutCubic(progl); // Alpha easing
// Apply easing functions to the progression value:
// - easedProgressBlur: Used for controlling the blur effect smoothly.
// - easedProgressAlpha: Used for controlling the alpha (opacity) transition.
float easedProgressBlur = easeInOutSine(progl); // Sine-based smooth easing for blur.
float easedProgressAlpha = easeInOutCubic(progl); // Cubic-based smooth easing for alpha.

// Control blur amount using easedProgressBlur
// Calculate the blur amount by interpolating (mixing) between the maximum blur (uBlurAmount)
// and zero blur based on the eased progression value.
float blurAmount = mix(uBlurAmount, 0.0, easedProgressBlur);

// Apply blur
vec4 texColor = blur( iTexCoord.st, blurAmount, uBlurQuality);
// Apply the calculated blur effect to the texture at the current texture coordinates.
// The blur function uses the blur amount and quality (uBlurQuality) for sampling.
vec4 texColor = blur(iTexCoord.st, blurAmount, uBlurQuality);

// Control alpha using easedProgressAlpha
// Calculate the alpha value for the transition using eased progress.
// This determines how transparent the final color will appear.
float alpha = easedProgressAlpha;

// Set final color with alpha transition
// Apply the alpha transition to the final texture color.
// Multiply the texture's alpha channel by the computed alpha value.
texColor.a *= alpha;

// Output the final color with the applied blur and alpha transition.
setOutputColor(texColor);
}
}
Loading