20250112
This commit is contained in:
+108
-156
@@ -32,29 +32,24 @@
|
||||
|
||||
// The width of the fading effect is loaded from the settings.
|
||||
|
||||
uniform bool uParticles;
|
||||
uniform float uParticleSize;
|
||||
uniform float uParticleSpeed;
|
||||
uniform float uParticleColorRandom;
|
||||
uniform float uParticleColorSpeed;
|
||||
uniform float uSparkCount;
|
||||
uniform vec2 uSparkStartEnd;
|
||||
uniform vec2 uSparkStartEnd;
|
||||
uniform float uSparkOffset;
|
||||
uniform float uStarCount;
|
||||
uniform float uStarRot;
|
||||
uniform float uStarSize;
|
||||
uniform vec2 uStarStartEnd;
|
||||
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;
|
||||
uniform vec4 uSparkColor0;
|
||||
uniform vec4 uSparkColor1;
|
||||
uniform vec4 uSparkColor2;
|
||||
uniform vec4 uSparkColor3;
|
||||
uniform vec4 uSparkColor4;
|
||||
uniform vec4 uSparkColor5;
|
||||
|
||||
//star colors
|
||||
uniform vec4 uStarColor0;
|
||||
@@ -65,47 +60,6 @@ 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 uStarCount = 5.0;
|
||||
float uStarRot = 1.0;
|
||||
float uStarSize = 0.1;
|
||||
vec2 uStarStartEnd = vec2(0.0,0.66);
|
||||
|
||||
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);
|
||||
vec4 uParticleColor1 = vec4(1.0, 1.0, 0.0, 0.0);
|
||||
vec4 uParticleColor2 = vec4(0.0, 1.0, 0.0, 0.0);
|
||||
vec4 uParticleColor3 = vec4(0.0, 0.0, 1.0, 0.0);
|
||||
vec4 uParticleColor4 = vec4(1.0, 0.0, 1.0, 0.0);
|
||||
vec4 uParticleColor5 = vec4(0.0, 1.0, 1.0, 0.0);
|
||||
|
||||
|
||||
vec4 uStarColor0 = vec4(1.0, 0.0, 0.0, 0.0);
|
||||
vec4 uStarColor1 = vec4(1.0, 1.0, 0.0, 0.0);
|
||||
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);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// Define a constant for 2 * PI (tau), which represents a full circle in radians.
|
||||
const float PI = 3.14159265359;
|
||||
const float tau = 6.28318530718;
|
||||
@@ -253,61 +207,9 @@ float FadeInOut(float t, float power)
|
||||
return s;
|
||||
}
|
||||
|
||||
float getSparks(float t)
|
||||
{
|
||||
|
||||
|
||||
//the UV for this function
|
||||
float aspect = uSize.x / uSize.y;
|
||||
vec2 uv = iTexCoord.st * vec2(aspect,1.0);
|
||||
|
||||
float result = 0.0;
|
||||
|
||||
|
||||
for (float i = 0.0; i < uSparkCount ; ++i)
|
||||
{
|
||||
|
||||
vec4 v4 = hash41( i * uSeed.x);
|
||||
|
||||
|
||||
// float speed = (1.0 - t) ;//* v4.y;
|
||||
|
||||
//the X and Y position ... at the end
|
||||
vec3 pos = getPosByAngle( (i/uSparkCount) * tau + (v4.x * 0.3) );
|
||||
|
||||
//the distance the spark will travel
|
||||
float d = mix(0.33,0.34,v4.z) ;
|
||||
d = mix(
|
||||
uSparkStartEnd.x + (v4.z * uSparkOffset),
|
||||
uSparkStartEnd.y - (v4.y * uSparkOffset),
|
||||
(1.0 - t)
|
||||
);
|
||||
|
||||
float s = getSpark(
|
||||
uv,
|
||||
vec2(0.5 * aspect,0.5) + ( pos.xy * d ), //position (x, y)
|
||||
FadeInOut(t,8.0) * 0.9 ,//Brightness
|
||||
FadeInOut(t,8.0) * (v4.w * 0.5) ,//Size
|
||||
0.0 //rotation
|
||||
);
|
||||
|
||||
result += s;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// result = pow(result,1.0);
|
||||
|
||||
result *= FadeInOut(iTexCoord.s,8.0);
|
||||
result *= FadeInOut(iTexCoord.t,8.0);
|
||||
|
||||
return clamp(result,0.0,1.0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//returns the particle's color
|
||||
vec4 getParticleColors(float v, float alpha) {
|
||||
//returns the Spark's color
|
||||
vec4 getSparkColors(float v, float alpha) {
|
||||
// Clamp v to ensure it's in [0.0, 1.0]
|
||||
v = clamp(v, 0.0, 1.0);
|
||||
|
||||
@@ -322,12 +224,12 @@ vec4 getParticleColors(float v, float alpha) {
|
||||
|
||||
// Define color values
|
||||
vec4 colors[6];
|
||||
colors[0] = uParticleColor0 ;
|
||||
colors[1] = uParticleColor1 ;
|
||||
colors[2] = uParticleColor2 ;
|
||||
colors[3] = uParticleColor3 ;
|
||||
colors[4] = uParticleColor4 ;
|
||||
colors[5] = uParticleColor5 ;
|
||||
colors[0] = uSparkColor0 ;
|
||||
colors[1] = uSparkColor1 ;
|
||||
colors[2] = uSparkColor2 ;
|
||||
colors[3] = uSparkColor3 ;
|
||||
colors[4] = uSparkColor4 ;
|
||||
colors[5] = uSparkColor5 ;
|
||||
|
||||
// Assign alpha values
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
@@ -355,6 +257,69 @@ vec4 getParticleColors(float v, float alpha) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
vec4 getSparks(float t)
|
||||
{
|
||||
|
||||
|
||||
//the UV for this function
|
||||
float aspect = uSize.x / uSize.y;
|
||||
vec2 uv = iTexCoord.st * vec2(aspect,1.0);
|
||||
|
||||
vec4 result = vec4(0.0);
|
||||
|
||||
//for each spark
|
||||
for (float i = 0.0; i < uSparkCount ; ++i)
|
||||
{
|
||||
//random values
|
||||
vec4 v4 = hash41( i * uSeed);
|
||||
|
||||
//the X and Y position ... at the end
|
||||
vec3 pos = getPosByAngle( (i/uSparkCount) * tau + (v4.x * 0.3) );
|
||||
|
||||
//the distance the spark will travel
|
||||
float d = mix(0.33,0.34,v4.z) ;
|
||||
d = mix(
|
||||
uSparkStartEnd.x + (v4.z * uSparkOffset),
|
||||
uSparkStartEnd.y - (v4.y * uSparkOffset),
|
||||
(1.0 - t)
|
||||
);
|
||||
|
||||
float s = getSpark(
|
||||
uv,
|
||||
vec2(0.5 * aspect,0.5) + ( pos.xy * d ), //position (x, y)
|
||||
FadeInOut(t,8.0) * 0.9 ,//Brightness
|
||||
FadeInOut(t,8.0) * (v4.w * 0.5) ,//Size
|
||||
0.0 //rotation
|
||||
);
|
||||
|
||||
|
||||
//set the color
|
||||
vec4 c = getSparkColors( hash11(v4.w) ,1.0);
|
||||
s = clamp(s*2.0,0.0,1.0);
|
||||
c.rgb *= s;
|
||||
c.a *= s;
|
||||
|
||||
result += c ;
|
||||
|
||||
}
|
||||
|
||||
//make it bright
|
||||
result.a = pow(result.a,2.0);
|
||||
|
||||
//fade at endges
|
||||
result.a *= FadeInOut(iTexCoord.s,4.0);
|
||||
result.a *= FadeInOut(iTexCoord.t,4.0);
|
||||
|
||||
return clamp(result,vec4(0.0),vec4(1.0));
|
||||
// return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec4 getStarColors(float v, float alpha) {
|
||||
// Clamp v to ensure it's in [0.0, 1.0]
|
||||
v = clamp(v, 0.0, 1.0);
|
||||
@@ -444,6 +409,7 @@ float getStar(vec2 uv, vec2 center, float npoints, float radiusRatio, float size
|
||||
}
|
||||
|
||||
|
||||
//convert the XY to angle
|
||||
float XYtoAngle(vec2 XY)
|
||||
{
|
||||
return atan(XY.y, XY.x);
|
||||
@@ -457,12 +423,13 @@ vec4 getStars(float t)
|
||||
float aspect = uSize.x / uSize.y;
|
||||
vec2 uv = iTexCoord.st * vec2(aspect,1.0);
|
||||
|
||||
float result = 0.0;
|
||||
|
||||
// float result = 0.0;
|
||||
vec4 result = vec4(0.0);
|
||||
|
||||
//loop for each star
|
||||
for (float i = 0.0; i < uStarCount ; ++i)
|
||||
{
|
||||
|
||||
//random values for this star
|
||||
vec4 v4 = hash41( i * uSeed);
|
||||
|
||||
//the X and Y position ... at the end
|
||||
@@ -486,41 +453,24 @@ vec4 getStars(float t)
|
||||
PI //rotation
|
||||
);
|
||||
|
||||
result += s;
|
||||
|
||||
s *= FadeInOut(iTexCoord.s,4.0);
|
||||
s *= FadeInOut(iTexCoord.t,4.0);
|
||||
s = clamp(s,0.0,1.0);
|
||||
|
||||
//the color is based on it's starting location
|
||||
vec4 color = getStarColors( i/uStarCount ,1.0);
|
||||
result += vec4(color.rgb * s,s * color.a);
|
||||
|
||||
}
|
||||
|
||||
result *= FadeInOut(iTexCoord.s,8.0);
|
||||
result *= FadeInOut(iTexCoord.t,8.0);
|
||||
result = clamp(result,0.0,1.0);
|
||||
|
||||
|
||||
vec4 color = getStarColors(
|
||||
(XYtoAngle(iTexCoord.st * 2.0 - 1.0) + PI) / tau
|
||||
, 1.0);
|
||||
|
||||
return vec4(color.rgb,result);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//gets the particles
|
||||
vec4 getParticles(float alpha)
|
||||
{
|
||||
vec2 uv = iTexCoord.st;
|
||||
|
||||
float particles = pow((simplex3D(vec3(uv * uParticleSize, uParticleSpeed * uProgress ))), 3.0);
|
||||
|
||||
float pc = simplex3D(vec3(uv * uParticleColorRandom, uParticleColorSpeed * uProgress ));
|
||||
vec4 particleColor = getParticleColors(pc,1.0);
|
||||
|
||||
particles *= alpha;
|
||||
|
||||
return vec4(particleColor.rgb,particles);
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
// Calculate the progression value based on the animation direction.
|
||||
// If opening, use uProgress as-is; if closing, invert the progression.
|
||||
@@ -537,32 +487,34 @@ void main() {
|
||||
//progress variants
|
||||
// float oExpo = easeOutExpo(progress);
|
||||
// float iExpo = easeInExpo(progress);
|
||||
// float oQuad = easeOutQuad(progress);
|
||||
float ioCubic = easeInOutCubic(progress);
|
||||
float ioSine = easeInOutSine(progress);
|
||||
|
||||
vec2 uv = iTexCoord.st;
|
||||
//center
|
||||
uv = uv * 2.0 - 1.0;
|
||||
//scale
|
||||
uv /= mix(vec2(0.5,0.5), vec2(0.0,0.0), ioCubic);
|
||||
// scale from center
|
||||
uv = uv * 0.5 + 0.5;
|
||||
|
||||
//get blured version of the window
|
||||
vec4 oColor = blur(iTexCoord.st, ztomo * 100.0,uBlurQuality);
|
||||
vec4 oColor = blur(uv, ioCubic * 200.0,uBlurQuality);
|
||||
|
||||
//apply mask
|
||||
oColor.a *= getMask(1.0 - ioSine);
|
||||
|
||||
//get and apply particles
|
||||
if (uParticles)
|
||||
{
|
||||
vec4 particles = getParticles(oColor.a);
|
||||
oColor = mix(oColor,particles,ztomo);
|
||||
}
|
||||
oColor.a *= (1.0 - ioSine);
|
||||
|
||||
//get and apply sparks
|
||||
if (uSparkCount > 0)
|
||||
{
|
||||
float sparks = getSparks(progress);
|
||||
oColor = alphaOver(oColor, vec4(1.0,1.0,1.0,sparks));
|
||||
vec4 sparks = getSparks(ioSine);
|
||||
oColor = alphaOver(oColor, sparks);
|
||||
}
|
||||
|
||||
//get and apply stars
|
||||
if (uStarCount > 0 )
|
||||
{
|
||||
oColor = alphaOver(oColor, getStars(mix(0.0001,0.999,progress)));
|
||||
oColor = alphaOver(oColor, getStars(mix(0.0001,0.999,ioSine)));
|
||||
}
|
||||
|
||||
setOutputColor(oColor);
|
||||
|
||||
@@ -48,157 +48,16 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</object>
|
||||
</child>
|
||||
|
||||
|
||||
|
||||
<!-- Switch for Enabling Particles -->
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Enable Particles</property>
|
||||
<property name="activatable-widget">unicorn-fart-particles-enable</property>
|
||||
|
||||
<property name="title" translatable="yes">Effect Presets</property>
|
||||
<property name="activatable-widget">unicorn-fart-preset-button</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkSwitch" id="unicorn-fart-particles-enable">
|
||||
<object class="GtkMenuButton" id="unicorn-fart-preset-button">
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-unicorn-fart-particles-enable">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Particle Size Adjustment -->
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Particle Size</property>
|
||||
<child>
|
||||
<object class="GtkScale">
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">2</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="unicorn-fart-particle-size">
|
||||
<property name="upper">100.0</property>
|
||||
<property name="lower">1.0</property>
|
||||
<property name="step-increment">1.0</property>
|
||||
<property name="page-increment">10.0</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-unicorn-fart-particle-size">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Particle Speed Adjustment -->
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Particle Speed</property>
|
||||
<child>
|
||||
<object class="GtkScale">
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">2</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="unicorn-fart-particle-speed">
|
||||
<property name="upper">50.0</property>
|
||||
<property name="lower">0.1</property>
|
||||
<property name="step-increment">0.1</property>
|
||||
<property name="page-increment">1.0</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-unicorn-fart-particle-speed">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Particle Color Random</property>
|
||||
<child>
|
||||
<object class="GtkScale">
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">2</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="unicorn-fart-particle-color-random">
|
||||
<property name="upper">100.0</property>
|
||||
<property name="lower">0.1</property>
|
||||
<property name="step-increment">0.1</property>
|
||||
<property name="page-increment">1.0</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-unicorn-fart-particle-color-random">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Particle Color Speed</property>
|
||||
<child>
|
||||
<object class="GtkScale">
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-value">1</property>
|
||||
<property name="digits">2</property>
|
||||
<property name="value-pos">left</property>
|
||||
<property name="width-request">300</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="unicorn-fart-particle-color-speed">
|
||||
<property name="upper">100.0</property>
|
||||
<property name="lower">0.1</property>
|
||||
<property name="step-increment">0.1</property>
|
||||
<property name="page-increment">1.0</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-unicorn-fart-particle-color-speed">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||
<property name="label" translatable="yes">Choose a Preset</property>
|
||||
<style>
|
||||
<class name="flat" />
|
||||
</style>
|
||||
@@ -351,7 +210,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<property name="width-request">300</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="unicorn-fart-star-count">
|
||||
<property name="upper">50</property>
|
||||
<property name="upper">25</property>
|
||||
<property name="lower">0</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">5</property>
|
||||
@@ -417,7 +276,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<property name="width-request">300</property>
|
||||
<property name="adjustment">
|
||||
<object class="GtkAdjustment" id="unicorn-fart-star-size">
|
||||
<property name="upper">1.0</property>
|
||||
<property name="upper">0.1</property>
|
||||
<property name="lower">0.0</property>
|
||||
<property name="step-increment">0.1</property>
|
||||
<property name="page-increment">0.5</property>
|
||||
@@ -548,42 +407,42 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<class name="linked" />
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkColorButton" id="unicorn-fart-particle-color-0">
|
||||
<object class="GtkColorButton" id="unicorn-fart-spark-color-0">
|
||||
<property name="use_alpha">1</property>
|
||||
<property name="show_editor">1</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColorButton" id="unicorn-fart-particle-color-1">
|
||||
<object class="GtkColorButton" id="unicorn-fart-spark-color-1">
|
||||
<property name="use_alpha">1</property>
|
||||
<property name="show_editor">1</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColorButton" id="unicorn-fart-particle-color-2">
|
||||
<object class="GtkColorButton" id="unicorn-fart-spark-color-2">
|
||||
<property name="use_alpha">1</property>
|
||||
<property name="show_editor">1</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColorButton" id="unicorn-fart-particle-color-3">
|
||||
<object class="GtkColorButton" id="unicorn-fart-spark-color-3">
|
||||
<property name="use_alpha">1</property>
|
||||
<property name="show_editor">1</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColorButton" id="unicorn-fart-particle-color-4">
|
||||
<object class="GtkColorButton" id="unicorn-fart-spark-color-4">
|
||||
<property name="use_alpha">1</property>
|
||||
<property name="show_editor">1</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColorButton" id="unicorn-fart-particle-color-5">
|
||||
<object class="GtkColorButton" id="unicorn-fart-spark-color-5">
|
||||
<property name="use_alpha">1</property>
|
||||
<property name="show_editor">1</property>
|
||||
<property name="valign">center</property>
|
||||
@@ -592,7 +451,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="reset-unicorn-fart-particle-colors">
|
||||
<object class="GtkButton" id="reset-unicorn-fart-spark-colors">
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="tooltip-text" translatable="yes">Reset to Default Values</property>
|
||||
|
||||
@@ -1149,36 +1149,6 @@ SPDX-License-Identifier: CC0-1.0
|
||||
<description>The time the Unicorn Fart effect takes.</description>
|
||||
</key>
|
||||
|
||||
<!-- particles -->
|
||||
<key name="unicorn-fart-particles-enable" type="b">
|
||||
<default>false</default>
|
||||
<summary>Enable Particles</summary>
|
||||
<description>Toggle whether particles are enabled in the effect.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-particle-size" type="d">
|
||||
<default>1.0</default>
|
||||
<summary>Particle Size</summary>
|
||||
<description>Set the size of the particles.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-particle-speed" type="d">
|
||||
<default>1.0</default>
|
||||
<summary>Particle Speed</summary>
|
||||
<description>Control the speed of the particles.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-particle-color-random" type="d">
|
||||
<default>0.0</default>
|
||||
<summary>Particle Color Randomness</summary>
|
||||
<description>Adjust the randomness of particle colors.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-particle-color-speed" type="d">
|
||||
<default>1.0</default>
|
||||
<summary>Particle Color Change Speed</summary>
|
||||
<description>Set the speed of particle color transitions.</description>
|
||||
</key>
|
||||
|
||||
<!-- sparks -->
|
||||
<key name="unicorn-fart-spark-count" type="i">
|
||||
@@ -1200,26 +1170,26 @@ SPDX-License-Identifier: CC0-1.0
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-spark-offset" type="d">
|
||||
<default>0.0</default>
|
||||
<default>0.5</default>
|
||||
<summary>Spark Offset</summary>
|
||||
<description>Set the positional offset for sparks.</description>
|
||||
</key>
|
||||
|
||||
<!-- stars -->
|
||||
<key name="unicorn-fart-star-count" type="i">
|
||||
<default>5</default>
|
||||
<default>6</default>
|
||||
<summary>Number of Stars</summary>
|
||||
<description>Set the total number of stars displayed.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-star-rotation" type="d">
|
||||
<default>0.0</default>
|
||||
<default>0.33</default>
|
||||
<summary>Star Rotation</summary>
|
||||
<description>Control the rotational angle of stars.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-star-size" type="d">
|
||||
<default>1.0</default>
|
||||
<default>0.1</default>
|
||||
<summary>Star Size</summary>
|
||||
<description>Set the size of the stars.</description>
|
||||
</key>
|
||||
@@ -1250,38 +1220,38 @@ SPDX-License-Identifier: CC0-1.0
|
||||
</key>
|
||||
|
||||
<!-- particle colors -->
|
||||
<key name="unicorn-fart-particle-color-0" type="s">
|
||||
<default>"rgba(255, 0, 0, 1.0)"</default>
|
||||
<key name="unicorn-fart-spark-color-0" type="s">
|
||||
<default>"rgba(255, 255, 255, 1.0)"</default>
|
||||
<summary>Primary Particle Color</summary>
|
||||
<description>Set the first color used for particles.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-particle-color-1" type="s">
|
||||
<default>"rgba(0, 255, 0, 1.0)"</default>
|
||||
<key name="unicorn-fart-spark-color-1" type="s">
|
||||
<default>"rgba(255, 255, 255, 1.0)"</default>
|
||||
<summary>Secondary Particle Color</summary>
|
||||
<description>Set the second color used for particles.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-particle-color-2" type="s">
|
||||
<default>"rgba(0, 0, 255, 1.0)"</default>
|
||||
<key name="unicorn-fart-spark-color-2" type="s">
|
||||
<default>"rgba(255, 255, 255, 1.0)"</default>
|
||||
<summary>Tertiary Particle Color</summary>
|
||||
<description>Set the third color used for particles.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-particle-color-3" type="s">
|
||||
<default>"rgba(255, 255, 0, 1.0)"</default>
|
||||
<key name="unicorn-fart-spark-color-3" type="s">
|
||||
<default>"rgba(255, 255, 255, 1.0)"</default>
|
||||
<summary>Quaternary Particle Color</summary>
|
||||
<description>Set the fourth color used for particles.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-particle-color-4" type="s">
|
||||
<default>"rgba(255, 0, 255, 1.0)"</default>
|
||||
<key name="unicorn-fart-spark-color-4" type="s">
|
||||
<default>"rgba(255, 255, 255, 1.0)"</default>
|
||||
<summary>Quinary Particle Color</summary>
|
||||
<description>Set the fifth color used for particles.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-particle-color-5" type="s">
|
||||
<default>"rgba(0, 255, 255, 1.0)"</default>
|
||||
<key name="unicorn-fart-spark-color-5" type="s">
|
||||
<default>"rgba(255, 255, 255, 1.0)"</default>
|
||||
<summary>Senary Particle Color</summary>
|
||||
<description>Set the sixth color used for particles.</description>
|
||||
</key>
|
||||
@@ -1294,31 +1264,31 @@ SPDX-License-Identifier: CC0-1.0
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-star-color-1" type="s">
|
||||
<default>"rgba(0, 255, 0, 1.0)"</default>
|
||||
<default>"rgba(255, 255, 0, 1.0)"</default>
|
||||
<summary>Secondary Star Color</summary>
|
||||
<description>Set the second color used for stars.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-star-color-2" type="s">
|
||||
<default>"rgba(0, 0, 255, 1.0)"</default>
|
||||
<default>"rgba(0, 255, 0, 1.0)"</default>
|
||||
<summary>Tertiary Star Color</summary>
|
||||
<description>Set the third color used for stars.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-star-color-3" type="s">
|
||||
<default>"rgba(255, 255, 0, 1.0)"</default>
|
||||
<default>"rgba(0, 255, 255, 1.0)"</default>
|
||||
<summary>Quaternary Star Color</summary>
|
||||
<description>Set the fourth color used for stars.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-star-color-4" type="s">
|
||||
<default>"rgba(255, 0, 255, 1.0)"</default>
|
||||
<default>"rgba(0, 0, 255, 1.0)"</default>
|
||||
<summary>Quinary Star Color</summary>
|
||||
<description>Set the fifth color used for stars.</description>
|
||||
</key>
|
||||
|
||||
<key name="unicorn-fart-star-color-5" type="s">
|
||||
<default>"rgba(0, 255, 255, 1.0)"</default>
|
||||
<default>"rgba(255, 0, 255, 1.0)"</default>
|
||||
<summary>Senary Star Color</summary>
|
||||
<description>Set the sixth color used for stars.</description>
|
||||
</key>
|
||||
|
||||
+7
-1
@@ -65,8 +65,10 @@ export var Shader = GObject.registerClass({
|
||||
// vfunc_build_pipeline()) from the resource file resources/shaders/<nick>.glsl
|
||||
// resolving any #includes in this file.
|
||||
_init(nick) {
|
||||
log(`Shader initialized with params: ${JSON.stringify(nick)}`);
|
||||
|
||||
this._nick = nick;
|
||||
|
||||
|
||||
// This will call vfunc_build_pipeline().
|
||||
super._init();
|
||||
|
||||
@@ -96,6 +98,7 @@ export var Shader = GObject.registerClass({
|
||||
|
||||
// Clean up if the animation finished or was interrupted.
|
||||
this._timeline.connect('stopped', (t, finished) => {
|
||||
// log(`Shader initialized with params: ${JSON.stringify(t)}`);
|
||||
this.endAnimation();
|
||||
});
|
||||
}
|
||||
@@ -151,6 +154,9 @@ export var Shader = GObject.registerClass({
|
||||
endAnimation() {
|
||||
// This will call endAnimation() again, so we can return for now.
|
||||
if (this._timeline.is_playing()) {
|
||||
// log(`Shader initialized with params:
|
||||
// ${JSON.stringify(this._timeline.is_playing())}`);
|
||||
|
||||
this._timeline.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
+279
-89
@@ -32,7 +32,9 @@ 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!
|
||||
// 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
|
||||
@@ -47,24 +49,25 @@ export default class Effect {
|
||||
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._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._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._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._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._uSeed = shader.get_uniform_location('uSeed');
|
||||
|
||||
shader._uStarColors = [
|
||||
shader.get_uniform_location('uStarColor0'),
|
||||
@@ -76,80 +79,59 @@ export default class Effect {
|
||||
];
|
||||
|
||||
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.get_uniform_location('uSparkColor0'),
|
||||
shader.get_uniform_location('uSparkColor1'),
|
||||
shader.get_uniform_location('uSparkColor2'),
|
||||
shader.get_uniform_location('uSparkColor3'),
|
||||
shader.get_uniform_location('uSparkColor4'),
|
||||
shader.get_uniform_location('uSparkColor5'),
|
||||
];
|
||||
|
||||
|
||||
// shader._uFadeWidth = shader.get_uniform_location('uFadeWidth');
|
||||
|
||||
// Write all uniform values at the start of each animation.
|
||||
shader.connect('begin-animation',
|
||||
(shader, settings) => {
|
||||
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._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-spark-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._uSparkCount, 1,
|
||||
[settings.get_int('unicorn-fart-spark-count')]);
|
||||
|
||||
shader.set_uniform_float(shader._uParticleSize, 1,
|
||||
[settings.get_double('unicorn-fart-particle-size')]);
|
||||
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._uParticleSpeed, 1,
|
||||
[settings.get_double('unicorn-fart-particle-speed')]);
|
||||
shader.set_uniform_float(shader._uSparkOffset, 1,
|
||||
[settings.get_double('unicorn-fart-spark-offset')]);
|
||||
|
||||
shader.set_uniform_float(shader._uParticleColorRandom, 1,
|
||||
[settings.get_double('unicorn-fart-particle-color-random')]);
|
||||
shader.set_uniform_float(shader._uStarCount, 1,
|
||||
[settings.get_int('unicorn-fart-star-count')]);
|
||||
|
||||
shader.set_uniform_float(shader._uParticleColorSpeed, 1,
|
||||
[settings.get_double('unicorn-fart-particle-color-speed')]);
|
||||
shader.set_uniform_float(shader._uStarRot, 1,
|
||||
[settings.get_double('unicorn-fart-star-rotation')]);
|
||||
|
||||
shader.set_uniform_float(shader._uSparkCount, 1,
|
||||
[settings.get_int('unicorn-fart-spark-count')]);
|
||||
shader.set_uniform_float(shader._uStarSize, 1,
|
||||
[settings.get_double('unicorn-fart-star-size')]);
|
||||
|
||||
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._uStarStartEnd, 2, [
|
||||
settings.get_double('unicorn-fart-star-start'),
|
||||
settings.get_double('unicorn-fart-star-end')
|
||||
]);
|
||||
|
||||
shader.set_uniform_float(shader._uSparkOffset, 1,
|
||||
[settings.get_double('unicorn-fart-spark-offset')]);
|
||||
shader.set_uniform_float(shader._uBlurQuality, 1,
|
||||
[settings.get_double('unicorn-fart-blur-quality')]);
|
||||
|
||||
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()]);
|
||||
|
||||
});
|
||||
shader.set_uniform_float(shader._uSeed, 1, [Math.random()]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -184,12 +166,6 @@ export default class Effect {
|
||||
|
||||
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');
|
||||
@@ -202,10 +178,10 @@ export default class Effect {
|
||||
dialog.bindAdjustment('unicorn-fart-star-end');
|
||||
dialog.bindAdjustment('unicorn-fart-blur-quality');
|
||||
|
||||
//switches
|
||||
// switches
|
||||
dialog.bindSwitch('unicorn-fart-particles-enable');
|
||||
|
||||
//star-color
|
||||
// star-color
|
||||
dialog.bindColorButton('unicorn-fart-star-color-0');
|
||||
dialog.bindColorButton('unicorn-fart-star-color-1');
|
||||
dialog.bindColorButton('unicorn-fart-star-color-2');
|
||||
@@ -213,14 +189,51 @@ export default class Effect {
|
||||
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');
|
||||
// particle-colors
|
||||
dialog.bindColorButton('unicorn-fart-spark-color-0');
|
||||
dialog.bindColorButton('unicorn-fart-spark-color-1');
|
||||
dialog.bindColorButton('unicorn-fart-spark-color-2');
|
||||
dialog.bindColorButton('unicorn-fart-spark-color-3');
|
||||
dialog.bindColorButton('unicorn-fart-spark-color-4');
|
||||
dialog.bindColorButton('unicorn-fart-spark-color-5');
|
||||
|
||||
|
||||
|
||||
// Ensure the button connections and other bindings happen only once,
|
||||
// even if the bindPreferences function is called multiple times.
|
||||
if (!Effect._isConnected) {
|
||||
Effect._isConnected = true;
|
||||
|
||||
// Bind the "reset-unicorn-fart-spark-colors" button to reset all star colors to
|
||||
// their default values.
|
||||
dialog.getBuilder()
|
||||
.get_object('reset-unicorn-fart-spark-colors')
|
||||
.connect('clicked', () => {
|
||||
// Reset each mushroom star color setting.
|
||||
dialog.getProfileSettings().reset('unicorn-fart-spark-color-0');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-spark-color-1');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-spark-color-2');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-spark-color-3');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-spark-color-4');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-spark-color-5');
|
||||
});
|
||||
|
||||
dialog.getBuilder()
|
||||
.get_object('reset-unicorn-fart-star-colors')
|
||||
.connect('clicked', () => {
|
||||
// Reset each mushroom star color setting.
|
||||
dialog.getProfileSettings().reset('unicorn-fart-star-color-0');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-star-color-1');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-star-color-2');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-star-color-3');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-star-color-4');
|
||||
dialog.getProfileSettings().reset('unicorn-fart-star-color-5');
|
||||
});
|
||||
|
||||
|
||||
// Initialize the preset dropdown menu for mushroom star colors.
|
||||
Effect._createUnicornFartPresets(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- API for extension.js
|
||||
@@ -229,6 +242,183 @@ export default class Effect {
|
||||
// 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};
|
||||
return {x: 2.0, y: 2.0};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- Presets
|
||||
|
||||
// This function initializes the preset dropdown menu for configuring fire options.
|
||||
// It defines multiple color presets for the "mushroom star" effect and sets up
|
||||
// the logic to apply these presets when selected.
|
||||
|
||||
static _createUnicornFartPresets(dialog) {
|
||||
// Retrieve the builder object for the dialog and connect to the "realize" event of
|
||||
// the button.
|
||||
dialog.getBuilder()
|
||||
.get_object('unicorn-fart-preset-button')
|
||||
.connect('realize', (widget) => {
|
||||
// Define an array of color presets, each with a name and six color values (RGBA
|
||||
// format).
|
||||
const presets = [
|
||||
{
|
||||
name: _('Unicorn Fart (Default)'),
|
||||
SparkCount: 25,
|
||||
SparkStart: 0.0,
|
||||
SparkEnd: 1.0,
|
||||
SparkOffset: 1.0,
|
||||
|
||||
StarCount: 6,
|
||||
StarRot: 0.33,
|
||||
StarSize: 0.10,
|
||||
StarStart: 0.0,
|
||||
StarEnd: 1.0,
|
||||
|
||||
BlurQuality:5.0,
|
||||
|
||||
Sparkcolor0: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor1: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor2: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor3: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor4: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor5: 'rgba(255,255,255,1.0)',
|
||||
|
||||
|
||||
Starcolor0: 'rgba(255,0,0,1.0)',
|
||||
Starcolor1: 'rgba(255,255,0,1.0)',
|
||||
Starcolor2: 'rgba(0,255,0,1.0)',
|
||||
Starcolor3: 'rgba(0,255,255,1.0)',
|
||||
Starcolor4: 'rgba(0,0,255,1.0)',
|
||||
Starcolor5: 'rgba(255,0,255,1.0)',
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
name: _('Fairy🧚'),
|
||||
SparkCount: 100,
|
||||
SparkStart: 0.0,
|
||||
SparkEnd: 1.0,
|
||||
SparkOffset: 1.0,
|
||||
|
||||
StarCount: 0,
|
||||
StarRot: 0.33,
|
||||
StarSize: 0.10,
|
||||
StarStart: 0.0,
|
||||
StarEnd: 1.0,
|
||||
|
||||
BlurQuality:5.0,
|
||||
|
||||
Sparkcolor0: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor1: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor2: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor3: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor4: 'rgba(255,255,255,1.0)',
|
||||
Sparkcolor5: 'rgba(255,255,255,1.0)',
|
||||
|
||||
|
||||
Starcolor0: 'rgba(255,0,0,1.0)',
|
||||
Starcolor1: 'rgba(255,255,0,1.0)',
|
||||
Starcolor2: 'rgba(0,255,0,1.0)',
|
||||
Starcolor3: 'rgba(0,255,255,1.0)',
|
||||
Starcolor4: 'rgba(0,0,255,1.0)',
|
||||
Starcolor5: 'rgba(255,0,255,1.0)',
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
name: _('Ring of Fire ❤️🔥'),
|
||||
SparkCount: 100,
|
||||
SparkStart: 0.0,
|
||||
SparkEnd: 1.0,
|
||||
SparkOffset: 1.0,
|
||||
|
||||
StarCount: 25,
|
||||
StarRot: 3.0,
|
||||
StarSize: 0.10,
|
||||
StarStart: 0.0,
|
||||
StarEnd: 1.0,
|
||||
|
||||
BlurQuality:5.0,
|
||||
|
||||
Sparkcolor0: 'rgba(255,0,0,1.0)', // Deep red
|
||||
Sparkcolor1: 'rgba(255,69,0,1.0)', // Fiery orange-red
|
||||
Sparkcolor2: 'rgba(255,140,0,1.0)', // Orange
|
||||
Sparkcolor3: 'rgba(255,215,0,1.0)', // Bright yellow
|
||||
Sparkcolor4: 'rgba(255,255,102,1.0)', // Light yellow
|
||||
Sparkcolor5: 'rgba(255,255,255,1.0)', // White (hottest point)
|
||||
|
||||
Starcolor0: 'rgba(255,0,0,1.0)', // Deep red
|
||||
Starcolor1: 'rgba(255,69,0,1.0)', // Fiery orange-red
|
||||
Starcolor2: 'rgba(255,140,0,1.0)', // Orange
|
||||
Starcolor3: 'rgba(255,215,0,1.0)', // Bright yellow
|
||||
Starcolor4: 'rgba(255,255,102,1.0)', // Light yellow
|
||||
Starcolor5: 'rgba(255,255,255,1.0)', // White (hottest point)
|
||||
|
||||
|
||||
|
||||
},
|
||||
];
|
||||
|
||||
// Create a new menu model to hold the presets and an action group for handling
|
||||
// selections.
|
||||
const menu = Gio.Menu.new();
|
||||
const group = Gio.SimpleActionGroup.new();
|
||||
const groupName = 'presets';
|
||||
|
||||
// Iterate over the presets to populate the menu.
|
||||
presets.forEach((preset, i) => {
|
||||
// Define an action name based on the preset index.
|
||||
const actionName = 'unicorn-fart' + i;
|
||||
|
||||
// Append the preset name to the menu.
|
||||
menu.append(preset.name, groupName + '.' + actionName);
|
||||
|
||||
// Create a new action for the preset.
|
||||
let action = Gio.SimpleAction.new(actionName, null);
|
||||
|
||||
// Connect the action to a function that loads the preset colors into the
|
||||
// dialog.
|
||||
action.connect('activate', () => {
|
||||
dialog.getProfileSettings().set_int('unicorn-fart-spark-count',preset.SparkCount);
|
||||
dialog.getProfileSettings().set_double('unicorn-fart-spark-start',preset.SparkStart);
|
||||
dialog.getProfileSettings().set_double('unicorn-fart-spark-end',preset.SparkEnd);
|
||||
dialog.getProfileSettings().set_double('unicorn-fart-spark-offset',preset.SparkOffset);
|
||||
|
||||
dialog.getProfileSettings().set_int('unicorn-fart-star-count',preset.StarCount);
|
||||
dialog.getProfileSettings().set_double('unicorn-fart-star-rotation',preset.StarRot);
|
||||
dialog.getProfileSettings().set_double('unicorn-fart-star-size',preset.StarSize);
|
||||
dialog.getProfileSettings().set_double('unicorn-fart-star-start',preset.StarStart);
|
||||
dialog.getProfileSettings().set_double('unicorn-fart-star-end',preset.StarEnd);
|
||||
|
||||
dialog.getProfileSettings().set_double('unicorn-fart-blur-quality',preset.BlurQuality);
|
||||
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-spark-color-0',preset.Sparkcolor0);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-spark-color-1',preset.Sparkcolor1);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-spark-color-2',preset.Sparkcolor2);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-spark-color-3',preset.Sparkcolor3);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-spark-color-4',preset.Sparkcolor4);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-spark-color-5',preset.Sparkcolor5);
|
||||
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-star-color-0',preset.Starcolor0);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-star-color-1',preset.Starcolor1);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-star-color-2',preset.Starcolor2);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-star-color-3',preset.Starcolor3);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-star-color-4',preset.Starcolor4);
|
||||
dialog.getProfileSettings().set_string('unicorn-fart-star-color-5',preset.Starcolor5);
|
||||
|
||||
});
|
||||
|
||||
// Add the action to the action group.
|
||||
group.add_action(action);
|
||||
});
|
||||
|
||||
// Assign the populated menu to the preset button.
|
||||
dialog.getBuilder()
|
||||
.get_object('unicorn-fart-preset-button')
|
||||
.set_menu_model(menu);
|
||||
|
||||
// Insert the action group into the root widget for handling the presets.
|
||||
const root = widget.get_root();
|
||||
root.insert_action_group(groupName, group);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user