From fc6aa44204adfdfafdf4266759e086b46915b604 Mon Sep 17 00:00:00 2001 From: Justin Garza Date: Sun, 5 Jan 2025 14:28:56 -0500 Subject: [PATCH] 20250105 --- extension.js | 4 +- prefs.js | 4 +- .../{simple-fade.frag => unicorn-fart.frag} | 106 ++- resources/ui/adw/unicorn-fart.ui | 676 ++++++++++++++++++ ...nsions.burn-my-windows-profile.gschema.xml | 194 ++++- src/Shader.js | 2 +- src/effects/SimpleFade.js | 94 --- src/effects/UnicornFart.js | 234 ++++++ 8 files changed, 1165 insertions(+), 149 deletions(-) rename resources/shaders/{simple-fade.frag => unicorn-fart.frag} (88%) create mode 100644 resources/ui/adw/unicorn-fart.ui delete mode 100644 src/effects/SimpleFade.js create mode 100644 src/effects/UnicornFart.js diff --git a/extension.js b/extension.js index 479e4d5..7ca02cc 100644 --- a/extension.js +++ b/extension.js @@ -49,7 +49,7 @@ import TVGlitch from './src/effects/TVGlitch.js'; import Wisps from './src/effects/Wisps.js'; import Mushroom from './src/effects/Mushroom.js'; -import SimpleFade from './src/effects/SimpleFade.js'; +import UnicornFart from './src/effects/UnicornFart.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; @@ -83,7 +83,7 @@ export default class BurnMyWindows extends Extension { new Matrix(), new PaintBrush(), new Pixelate(), new PixelWheel(), new PixelWipe(), new Portal(), new RGBWarp(), new SnapOfDisintegration(), new TeamRocket(), new TRexAttack(), new TVEffect(), new TVGlitch(), - new Wisps(), new Mushroom(), new SimpleFade(), + new Wisps(), new Mushroom(), new UnicornFart(), ]; diff --git a/prefs.js b/prefs.js index 6e14c8c..ea60c03 100644 --- a/prefs.js +++ b/prefs.js @@ -50,7 +50,7 @@ import TVEffect from './src/effects/TVEffect.js'; import TVGlitch from './src/effects/TVGlitch.js'; import Wisps from './src/effects/Wisps.js'; -import SimpleFade from './src/effects/SimpleFade.js'; +import UnicornFart from './src/effects/UnicornFart.js'; import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; @@ -84,7 +84,7 @@ export default class BurnMyWindowsPreferences extends ExtensionPreferences { Pixelate, PixelWheel, PixelWipe, Portal, RGBWarp, SnapOfDisintegration, TeamRocket, TRexAttack, TVEffect, - TVGlitch, Wisps, SimpleFade, + TVGlitch, Wisps, UnicornFart, ]; diff --git a/resources/shaders/simple-fade.frag b/resources/shaders/unicorn-fart.frag similarity index 88% rename from resources/shaders/simple-fade.frag rename to resources/shaders/unicorn-fart.frag index 686bca7..9ba9729 100644 --- a/resources/shaders/simple-fade.frag +++ b/resources/shaders/unicorn-fart.frag @@ -31,27 +31,60 @@ // void setOutputColor(vec4 outColor) // The width of the fading effect is loaded from the settings. -// uniform float uFadeWidth; + +uniform bool uParticles; +uniform float uParticleSize; +uniform float uParticleSpeed; +uniform float uParticleColorRandom; +uniform float uParticleColorSpeed; +uniform float uSparkCount; +uniform vec2 uSparkStartEnd; +uniform float uSparkOffset; +uniform float uStarCount; +uniform float uStarRot; +uniform float uStarSize; +uniform vec2 uStarStartEnd; +uniform float uBlurQuality; +uniform float uSeed; + + +//particle colors +uniform vec4 uParticleColor0; +uniform vec4 uParticleColor1; +uniform vec4 uParticleColor2; +uniform vec4 uParticleColor3; +uniform vec4 uParticleColor4; +uniform vec4 uParticleColor5; + +//star colors +uniform vec4 uStarColor0; +uniform vec4 uStarColor1; +uniform vec4 uStarColor2; +uniform vec4 uStarColor3; +uniform vec4 uStarColor4; +uniform vec4 uStarColor5; + + + +/* +bool uParticles = True; +float uParticleSize = 100.0; +float uParticleSpeed = 10.0; +float uParticleColorRandom = 1.0; +float uParticleColorSpeed = 1.0; float uSparkCount = 50.0; vec2 uSparkStartEnd = vec2(0.1,0.75); float uSparkOffset = 0.25; -float uBlurQuality = 5.0; -vec4 uSeed = vec4(1.0,0.1,0.5,1.0); - float uStarCount = 5.0; float uStarRot = 1.0; float uStarSize = 0.1; vec2 uStarStartEnd = vec2(0.0,0.66); -//pastel -// vec4 uParticleColor0 = vec4(1.0, 0.8, 0.8, 1.0); -// vec4 uParticleColor1 = vec4(1.0, 1.0, 0.8, 1.0); -// vec4 uParticleColor2 = vec4(0.8, 1.0, 0.8, 1.0); -// vec4 uParticleColor3 = vec4(0.8, 0.8, 1.0, 1.0); -// vec4 uParticleColor4 = vec4(1.0, 0.8, 1.0, 1.0); -// vec4 uParticleColor5 = vec4(0.8, 1.0, 1.0, 1.0); +float uBlurQuality = 5.0; +vec4 uSeed = vec4(1.0,0.1,0.5,1.0); + //bold colors vec4 uParticleColor0 = vec4(1.0, 0.0, 0.0, 0.0); @@ -68,7 +101,7 @@ vec4 uStarColor2 = vec4(0.0, 1.0, 0.0, 0.0); vec4 uStarColor3 = vec4(0.0, 0.0, 1.0, 0.0); vec4 uStarColor4 = vec4(1.0, 0.0, 1.0, 0.0); vec4 uStarColor5 = vec4(1.0, 0.0, 0.0, 0.0); - +*/ @@ -430,7 +463,7 @@ vec4 getStars(float t) for (float i = 0.0; i < uStarCount ; ++i) { - vec4 v4 = hash41( i * uSeed.x); + vec4 v4 = hash41( i * uSeed); //the X and Y position ... at the end vec3 pos = getPosByAngle( (i/uStarCount) * tau + (uStarRot * tau * t) ); @@ -477,12 +510,11 @@ vec4 getParticles(float alpha) { vec2 uv = iTexCoord.st; - float particles = pow((simplex3D(vec3(uv * 50.0, 10.0 * uProgress ))), 3.0); + float particles = pow((simplex3D(vec3(uv * uParticleSize, uParticleSpeed * uProgress ))), 3.0); - float pc = pow((simplex3D(vec3(uv * 50, 10.0 * uProgress ))), 1.0); + float pc = simplex3D(vec3(uv * uParticleColorRandom, uParticleColorSpeed * uProgress )); vec4 particleColor = getParticleColors(pc,1.0); - particles *= alpha; return vec4(particleColor.rgb,particles); @@ -502,36 +534,36 @@ void main() { ); ztomo = easeInOutSine(ztomo); - //out Expo - float oExpo = easeOutExpo(progress); - float iExpo = easeInExpo(progress); + //progress variants + // float oExpo = easeOutExpo(progress); + // float iExpo = easeInExpo(progress); float ioSine = easeInOutSine(progress); - float ioSine_r = 1.0 - ioSine; - vec2 uv = iTexCoord.st; + //get blured version of the window + vec4 oColor = blur(iTexCoord.st, ztomo * 100.0,uBlurQuality); - // // change the center - // uv = uv * 2.0 - 1.0; - // //scale - // uv /= ioSine_r; - // //re-center - // uv = uv * 0.5 + 0.5; - - //get color - vec4 oColor = blur(uv, ztomo * 100.0,uBlurQuality); + //apply mask oColor.a *= getMask(1.0 - ioSine); //get and apply particles - vec4 particles = getParticles(oColor.a); - oColor = mix(oColor,particles,ztomo); + if (uParticles) + { + vec4 particles = getParticles(oColor.a); + oColor = mix(oColor,particles,ztomo); + } //get and apply sparks - float sparks = getSparks(progress); - oColor = alphaOver(oColor, vec4(1.0,1.0,1.0,sparks)); - - - oColor = alphaOver(oColor, getStars(mix(0.0001,0.999,progress))); + if (uSparkCount > 0) + { + float sparks = getSparks(progress); + oColor = alphaOver(oColor, vec4(1.0,1.0,1.0,sparks)); + } + //get and apply stars + if (uStarCount > 0 ) + { + oColor = alphaOver(oColor, getStars(mix(0.0001,0.999,progress))); + } setOutputColor(oColor); } \ No newline at end of file diff --git a/resources/ui/adw/unicorn-fart.ui b/resources/ui/adw/unicorn-fart.ui new file mode 100644 index 0000000..07d9417 --- /dev/null +++ b/resources/ui/adw/unicorn-fart.ui @@ -0,0 +1,676 @@ + + + + + + + + + + + + + + Animation Time [ms] + + + + center + 1 + 0 + left + 300 + + + + 5000 + 100 + 10 + 100 + + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + + + + Enable Particles + unicorn-fart-particles-enable + + + center + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + + Particle Size + + + center + 1 + 2 + left + 300 + + + 100.0 + 1.0 + 1.0 + 10.0 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + + Particle Speed + + + center + 1 + 2 + left + 300 + + + 50.0 + 0.1 + 0.1 + 1.0 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Particle Color Random + + + center + 1 + 2 + left + 300 + + + 100.0 + 0.1 + 0.1 + 1.0 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Particle Color Speed + + + center + 1 + 2 + left + 300 + + + 100.0 + 0.1 + 0.1 + 1.0 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Spark Count + + + center + 1 + 0 + left + 300 + + + 100 + 0 + 1 + 10 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Spark Start + + + center + 1 + 2 + left + 300 + + + 0.5 + 0.0 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Spark End + + + center + 1 + 2 + left + 300 + + + 1.0 + 0.5 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Spark offset + + + center + 1 + 2 + left + 300 + + + 0.5 + 0.0 + 0.1 + 0.25 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Star Count + + + center + 1 + 0 + left + 300 + + + 50 + 0 + 1 + 5 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Star Rotation + + + center + 1 + 2 + left + 300 + + + 3.0 + -3.0 + 0.1 + 0.5 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Star Size + + + center + 1 + 2 + left + 300 + + + 1.0 + 0.0 + 0.1 + 0.5 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Star Start + + + center + 1 + 2 + left + 300 + + + 0.5 + 0.0 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Star End + + + center + 1 + 2 + left + 300 + + + 1.0 + 0.5 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + Blur Quality + + + center + 1 + 2 + left + 300 + + + 10.0 + 0.0 + 0.01 + 0.1 + + + + + + + edit-clear-symbolic + center + Reset to Default Value + + + + + + + + + + + Particle Colors + + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + + + edit-clear-symbolic + center + Reset to Default Values + + + + + + + + + + Star Colors + + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + 1 + 1 + center + + + + + + + edit-clear-symbolic + center + Reset to Default Values + + + + + + + + + + diff --git a/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml b/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml index 20bcd75..7c3c44d 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows-profile.gschema.xml @@ -1119,7 +1119,7 @@ SPDX-License-Identifier: CC0-1.0 Rotate the Window Rotate the Window - + 0.33 Sparkle Rotation @@ -1134,25 +1134,193 @@ SPDX-License-Identifier: CC0-1.0 - + - + false - Simple Fade Enable Effect - Use the Simple Fade effect. + Unicorn Fart Enable Effect + Use the Unicorn Fart effect. - - 3000 - Simple Fade Animation Time - The time the Simple Fade effect takes. + + 1500 + Unicorn Fart Animation Time + The time the Unicorn Fart effect takes. - - 0.1 - Simple Fade Width - Width of the fading effect. + + + false + Enable Particles + Toggle whether particles are enabled in the effect. + + + + 1.0 + Particle Size + Set the size of the particles. + + + + 1.0 + Particle Speed + Control the speed of the particles. + + + + 0.0 + Particle Color Randomness + Adjust the randomness of particle colors. + + + + 1.0 + Particle Color Change Speed + Set the speed of particle color transitions. + + + + + 25 + Number of Sparks + Set the total number of sparks generated. + + + + 0.0 + Spark Start Point + Define the starting position for sparks. + + + + 1.0 + Spark End Point + Define the ending position for sparks. + + + + 0.0 + Spark Offset + Set the positional offset for sparks. + + + + + 5 + Number of Stars + Set the total number of stars displayed. + + + + 0.0 + Star Rotation + Control the rotational angle of stars. + + + + 1.0 + Star Size + Set the size of the stars. + + + + 0.0 + Star Start Point + Define the starting position for stars. + + + + 1.0 + Star End Point + Define the ending position for stars. + + + + + 5.0 + Blur Quality + Set the quality level for the blur effect. + + + + 1.0 + Random Seed + Define the seed value for random effects. + + + + + "rgba(255, 0, 0, 1.0)" + Primary Particle Color + Set the first color used for particles. + + + + "rgba(0, 255, 0, 1.0)" + Secondary Particle Color + Set the second color used for particles. + + + + "rgba(0, 0, 255, 1.0)" + Tertiary Particle Color + Set the third color used for particles. + + + + "rgba(255, 255, 0, 1.0)" + Quaternary Particle Color + Set the fourth color used for particles. + + + + "rgba(255, 0, 255, 1.0)" + Quinary Particle Color + Set the fifth color used for particles. + + + + "rgba(0, 255, 255, 1.0)" + Senary Particle Color + Set the sixth color used for particles. + + + + + "rgba(255, 0, 0, 1.0)" + Primary Star Color + Set the first color used for stars. + + + + "rgba(0, 255, 0, 1.0)" + Secondary Star Color + Set the second color used for stars. + + + + "rgba(0, 0, 255, 1.0)" + Tertiary Star Color + Set the third color used for stars. + + + + "rgba(255, 255, 0, 1.0)" + Quaternary Star Color + Set the fourth color used for stars. + + + + "rgba(255, 0, 255, 1.0)" + Quinary Star Color + Set the fifth color used for stars. + + + + "rgba(0, 255, 255, 1.0)" + Senary Star Color + Set the sixth color used for stars. diff --git a/src/Shader.js b/src/Shader.js index f115f75..f0b36d5 100644 --- a/src/Shader.js +++ b/src/Shader.js @@ -66,7 +66,7 @@ export var Shader = GObject.registerClass({ // resolving any #includes in this file. _init(nick) { this._nick = nick; - + // This will call vfunc_build_pipeline(). super._init(); diff --git a/src/effects/SimpleFade.js b/src/effects/SimpleFade.js deleted file mode 100644 index f4abb4b..0000000 --- a/src/effects/SimpleFade.js +++ /dev/null @@ -1,94 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////// -// ) ( // -// ( /( ( ( ) ( ( ( ( )\ ) ( ( // -// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( // -// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ // -// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) // -// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< // -// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ // -// |__/ // -////////////////////////////////////////////////////////////////////////////////////////// - -// SPDX-FileCopyrightText: Justin Garza JGarza9788@gmail.com -// SPDX-License-Identifier: GPL-3.0-or-later - -'use strict'; - -import * as utils from '../utils.js'; - -// We import the ShaderFactory only in the Shell process as it is not required in the -// preferences process. The preferences process does not create any shader instances, it -// only uses the static metadata of the effect. -const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js'); - -const _ = await utils.importGettext(); - -////////////////////////////////////////////////////////////////////////////////////////// -// This effect ... // -// <- Please add a description of your effect here -> // -////////////////////////////////////////////////////////////////////////////////////////// - -// The effect class can be used to get some metadata (like the effect's name or supported -// GNOME Shell versions), to initialize the respective page of the settings dialog, as -// well as to create the actual shader for the effect. -export default class Effect { - // The constructor creates a ShaderFactory which will be used by extension.js to create - // shader instances for this effect. The shaders will be automagically created using the - // GLSL file in resources/shaders/.glsl. The callback will be called for each - // newly created shader instance. - constructor() { - this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => { - // Store uniform locations of newly created shaders. - // shader._uFadeWidth = shader.get_uniform_location('uFadeWidth'); - - // Write all uniform values at the start of each animation. - shader.connect('begin-animation', - (shader, settings) => { - - // shader.set_uniform_float(shader._uFadeWidth, 1, [ - // settings.get_double('simple-fade-width'), - // ]); - - }); - }); - } - - // ---------------------------------------------------------------------------- metadata - - // The effect is available on all GNOME Shell versions supported by this extension. - static getMinShellVersion() { - return [3, 36]; - } - - // This will be called in various places where a unique identifier for this effect is - // required. It should match the prefix of the settings keys which store whether the - // effect is enabled currently (e.g. '*-enable-effect'), and its animation time - // (e.g. '*-animation-time'). Also, the shader file and the settings UI files should be - // named likes this. - static getNick() { - return 'simple-fade'; - } - - // This will be shown in the sidebar of the preferences dialog as well as in the - // drop-down menus where the user can choose the effect. - static getLabel() { - return _('Simple Fade Effect'); - } - - // -------------------------------------------------------------------- API for prefs.js - - // This is called by the preferences dialog whenever a new effect profile is loaded. It - // binds all user interface elements to the respective settings keys of the profile. - static bindPreferences(dialog) { - // Empty for now... Code is added here later in the tutorial! - } - - // ---------------------------------------------------------------- API for extension.js - - // The getActorScale() is called from extension.js to adjust the actor's size during the - // animation. This is useful if the effect requires drawing something beyond the usual - // bounds of the actor. This only works for GNOME 3.38+. - static getActorScale(settings, forOpening, actor) { - return {x: 1.0, y: 1.0}; - } -} \ No newline at end of file diff --git a/src/effects/UnicornFart.js b/src/effects/UnicornFart.js new file mode 100644 index 0000000..99e3d28 --- /dev/null +++ b/src/effects/UnicornFart.js @@ -0,0 +1,234 @@ +////////////////////////////////////////////////////////////////////////////////////////// +// ) ( // +// ( /( ( ( ) ( ( ( ( )\ ) ( ( // +// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( // +// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ // +// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) // +// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< // +// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ // +// |__/ // +////////////////////////////////////////////////////////////////////////////////////////// + +// SPDX-FileCopyrightText: Justin Garza JGarza9788@gmail.com +// SPDX-License-Identifier: GPL-3.0-or-later + +'use strict'; + +// Import the Gio module from the GNOME platform (GObject Introspection). +// This module provides APIs for I/O operations, settings management, and other core +// features. +import Gio from 'gi://Gio'; + +// Import utility functions from the local utils.js file. +// These utilities likely contain helper functions or shared logic used across the +// application. +import * as utils from '../utils.js'; + +// We import the ShaderFactory only in the Shell process as it is not required in the +// preferences process. The preferences process does not create any shader instances, it +// only uses the static metadata of the effect. +const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js'); + +const _ = await utils.importGettext(); + +////////////////////////////////////////////////////////////////////////////////////////// +// I thought to myself, i said "self what would a unicorn fart look like" and then i came up with this, and i don't care that i'm out of the box, i think outside of the box, yeah f*ck that box! +////////////////////////////////////////////////////////////////////////////////////////// + +// The effect class can be used to get some metadata (like the effect's name or supported +// GNOME Shell versions), to initialize the respective page of the settings dialog, as +// well as to create the actual shader for the effect. +export default class Effect { + // The constructor creates a ShaderFactory which will be used by extension.js to create + // shader instances for this effect. The shaders will be automagically created using the + // GLSL file in resources/shaders/.glsl. The callback will be called for each + // newly created shader instance. + constructor() { + this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => { + // Store uniform locations of newly created shaders. + + shader._uParticles = shader.get_uniform_location('uParticles'); + shader._uParticleSize = shader.get_uniform_location('uParticleSize'); + shader._uParticleSpeed = shader.get_uniform_location('uParticleSpeed'); + shader._uParticleColorRandom = shader.get_uniform_location('uParticleColorRandom'); + shader._uParticleColorSpeed = shader.get_uniform_location('uParticleColorSpeed'); + + shader._uSparkCount = shader.get_uniform_location('uSparkCount'); + shader._uSparkStartEnd = shader.get_uniform_location('uSparkStartEnd'); + shader._uSparkOffset = shader.get_uniform_location('uSparkOffset'); + shader._uSparkCount = shader.get_uniform_location('uSparkCount'); + + shader._uStarCount = shader.get_uniform_location('uStarCount'); + shader._uStarRot = shader.get_uniform_location('uStarRot'); + shader._uStarSize = shader.get_uniform_location('uStarSize'); + shader._uStarStartEnd = shader.get_uniform_location('uStarStartEnd'); + + shader._uBlurQuality = shader.get_uniform_location('uBlurQuality'); + shader._uSeed = shader.get_uniform_location('uSeed'); + + shader._uStarColors = [ + shader.get_uniform_location('uStarColor0'), + shader.get_uniform_location('uStarColor1'), + shader.get_uniform_location('uStarColor2'), + shader.get_uniform_location('uStarColor3'), + shader.get_uniform_location('uStarColor4'), + shader.get_uniform_location('uStarColor5'), + ]; + + shader._uParticleColors = [ + shader.get_uniform_location('uParticlesColor0'), + shader.get_uniform_location('uParticlesColor1'), + shader.get_uniform_location('uParticlesColor2'), + shader.get_uniform_location('uParticlesColor3'), + shader.get_uniform_location('uParticlesColor4'), + shader.get_uniform_location('uParticlesColor5'), + ]; + + + // shader._uFadeWidth = shader.get_uniform_location('uFadeWidth'); + + // Write all uniform values at the start of each animation. + shader.connect('begin-animation', + (shader, settings) => { + + for (let i = 0; i <= 5; i++) { + shader.set_uniform_float( + shader._uStarColors[i], 4, + utils.parseColor(settings.get_string('unicorn-fart-star-color-' + i))); + } + + for (let i = 0; i <= 5; i++) { + shader.set_uniform_float( + shader._uParticleColors[i], 4, + utils.parseColor(settings.get_string('unicorn-fart-particle-color-' + i))); + } + + shader.set_uniform_float(shader._uParticles, 1, + [settings.get_boolean('unicorn-fart-particles-enable')]); + + shader.set_uniform_float(shader._uParticleSize, 1, + [settings.get_double('unicorn-fart-particle-size')]); + + shader.set_uniform_float(shader._uParticleSpeed, 1, + [settings.get_double('unicorn-fart-particle-speed')]); + + shader.set_uniform_float(shader._uParticleColorRandom, 1, + [settings.get_double('unicorn-fart-particle-color-random')]); + + shader.set_uniform_float(shader._uParticleColorSpeed, 1, + [settings.get_double('unicorn-fart-particle-color-speed')]); + + shader.set_uniform_float(shader._uSparkCount, 1, + [settings.get_int('unicorn-fart-spark-count')]); + + shader.set_uniform_float(shader._uSparkStartEnd, 2, + [settings.get_double('unicorn-fart-spark-start'), + settings.get_double('unicorn-fart-spark-end')] + ); + + shader.set_uniform_float(shader._uSparkOffset, 1, + [settings.get_double('unicorn-fart-spark-offset')]); + + shader.set_uniform_float(shader._uStarCount, 1, + [settings.get_int('unicorn-fart-star-count')]); + + shader.set_uniform_float(shader._uStarRot, 1, + [settings.get_double('unicorn-fart-star-rotation')]); + + shader.set_uniform_float(shader._uStarSize, 1, + [settings.get_double('unicorn-fart-star-size')]); + + shader.set_uniform_float(shader._uStarStartEnd, 2, + [settings.get_double('unicorn-fart-star-start'), + settings.get_double('unicorn-fart-star-end')] + ); + + shader.set_uniform_float(shader._uBlurQuality, 1, + [settings.get_double('unicorn-fart-blur-quality')]); + + shader.set_uniform_float(shader._uSeed, 1, + [Math.random()]); + + }); + }); + } + + // ---------------------------------------------------------------------------- metadata + + // The effect is available on all GNOME Shell versions supported by this extension. + static getMinShellVersion() { + return [3, 36]; + } + + // This will be called in various places where a unique identifier for this effect is + // required. It should match the prefix of the settings keys which store whether the + // effect is enabled currently (e.g. '*-enable-effect'), and its animation time + // (e.g. '*-animation-time'). Also, the shader file and the settings UI files should be + // named likes this. + static getNick() { + return 'unicorn-fart'; + } + + // This will be shown in the sidebar of the preferences dialog as well as in the + // drop-down menus where the user can choose the effect. + static getLabel() { + return _('UnicornFart'); + } + + // -------------------------------------------------------------------- API for prefs.js + + // This is called by the preferences dialog whenever a new effect profile is loaded. It + // binds all user interface elements to the respective settings keys of the profile. + static bindPreferences(dialog) { + // Empty for now... Code is added here later in the tutorial! + + dialog.bindAdjustment('unicorn-fart-animation-time'); + + //ints and floats + dialog.bindAdjustment('unicorn-fart-particle-size'); + dialog.bindAdjustment('unicorn-fart-particle-speed'); + dialog.bindAdjustment('unicorn-fart-particle-color-random'); + dialog.bindAdjustment('unicorn-fart-particle-color-speed'); + + dialog.bindAdjustment('unicorn-fart-spark-count'); + dialog.bindAdjustment('unicorn-fart-spark-start'); + dialog.bindAdjustment('unicorn-fart-spark-end'); + dialog.bindAdjustment('unicorn-fart-spark-offset'); + + dialog.bindAdjustment('unicorn-fart-star-count'); + dialog.bindAdjustment('unicorn-fart-star-rotation'); + dialog.bindAdjustment('unicorn-fart-star-size'); + dialog.bindAdjustment('unicorn-fart-star-start'); + dialog.bindAdjustment('unicorn-fart-star-end'); + dialog.bindAdjustment('unicorn-fart-blur-quality'); + + //switches + dialog.bindSwitch('unicorn-fart-particles-enable'); + + //star-color + dialog.bindColorButton('unicorn-fart-star-color-0'); + dialog.bindColorButton('unicorn-fart-star-color-1'); + dialog.bindColorButton('unicorn-fart-star-color-2'); + dialog.bindColorButton('unicorn-fart-star-color-3'); + dialog.bindColorButton('unicorn-fart-star-color-4'); + dialog.bindColorButton('unicorn-fart-star-color-5'); + + //particle-colors + dialog.bindColorButton('unicorn-fart-particle-color-0'); + dialog.bindColorButton('unicorn-fart-particle-color-1'); + dialog.bindColorButton('unicorn-fart-particle-color-2'); + dialog.bindColorButton('unicorn-fart-particle-color-3'); + dialog.bindColorButton('unicorn-fart-particle-color-4'); + dialog.bindColorButton('unicorn-fart-particle-color-5'); + + } + + // ---------------------------------------------------------------- API for extension.js + + // The getActorScale() is called from extension.js to adjust the actor's size during the + // animation. This is useful if the effect requires drawing something beyond the usual + // bounds of the actor. This only works for GNOME 3.38+. + static getActorScale(settings, forOpening, actor) { + return {x: 1.0, y: 1.0}; + } +} \ No newline at end of file