added muchroom and more

This commit is contained in:
Justin Garza
2024-12-12 21:40:59 -05:00
parent fa4d4eeaff
commit 48eb33eacf
6 changed files with 466 additions and 634 deletions
+4 -1
View File
@@ -379,7 +379,10 @@ float getWinding(vec2 a, vec2 b) { return cross(vec3(a, 0.0), vec3(b, 0.0)).z; }
// Rotates the given 2D vector a clockwise by the angle alpha (given in radians). // Rotates the given 2D vector a clockwise by the angle alpha (given in radians).
vec2 rotate(vec2 a, float angle) { vec2 rotate(vec2 a, float angle) {
return vec2(a.x * cos(angle) - a.y * sin(angle), a.x * sin(angle) + a.y * cos(angle)); return vec2(
a.x * cos(angle) - a.y * sin(angle),
a.x * sin(angle) + a.y * cos(angle)
);
} }
// --------------------------------------------------------------------------------- noise // --------------------------------------------------------------------------------- noise
+152 -137
View File
@@ -32,24 +32,22 @@
// The width of the fading effect is loaded from the settings. // The width of the fading effect is loaded from the settings.
// use 8BitStyle or not // use 8BitStyle or not (sliding scale)
uniform bool u8BitStyle; uniform float uScaleStyle;
//these are for the 4 point stars (or sparks) //these are for the sparks
uniform bool uEnable4PStars; uniform float uSparkCount;
uniform float u4PStars; uniform vec4 uSparkColor;
uniform vec4 u4PSColor; uniform float uSparkRotation;
uniform float u4PSRotation;
//these are for the Rays //these are for the Rays
uniform bool uEnableRays;
uniform vec4 uRaysColor; uniform vec4 uRaysColor;
//these are for the 5 pointed stars //these are for the stars
uniform bool uEnable5pStars; uniform float uRingCount;
uniform float uRings;
uniform float uRingRotation; uniform float uRingRotation;
uniform float uStarPerRing; uniform float uStarCount;
// and the colors they change over time // and the colors they change over time
uniform vec4 uStarColor0; uniform vec4 uStarColor0;
uniform vec4 uStarColor1; uniform vec4 uStarColor1;
@@ -58,6 +56,9 @@ uniform vec4 uStarColor3;
uniform vec4 uStarColor4; uniform vec4 uStarColor4;
uniform vec4 uStarColor5; uniform vec4 uStarColor5;
//seed
uniform vec2 uSeed;
//helps to find the angle //helps to find the angle
vec3 getPosByAngle(float angle) vec3 getPosByAngle(float angle)
{ {
@@ -65,6 +66,7 @@ vec3 getPosByAngle(float angle)
} }
//gets the mask of a Star
float getStar(vec2 uv, vec2 center, float npoints, float radiusRatio, float size, float rotation) float getStar(vec2 uv, vec2 center, float npoints, float radiusRatio, float size, float rotation)
{ {
@@ -104,56 +106,65 @@ float getStar(vec2 uv, vec2 center, float npoints, float radiusRatio, float size
} }
float getStarWithFade(vec2 uv, vec2 center, float npoints, float radiusRatio, float size, float rotation) //use to scale the window
vec2 scaleUV(vec2 uv, vec2 scale)
{ {
float radiusMax = 1.0; // Put texture coordinate origin to center of window.
float radiusMin = radiusMax * radiusRatio; uv = uv * 2.0 - 1.0;
float PI = 3.1415926;
float starangle = 2.0 * PI / npoints; // Angle between points on the star
// Offset rotation to ensure one point is always up when rotation = 0 //scale
rotation += PI / 2.0 - starangle / 1.0; uv /= mix(vec2(1.0,1.0), vec2(0.0,0.0), scale);
// Define the positions for the outer and inner points of the star's initial angle, rotated by `rotation` // scale from center
vec3 p0 = (radiusMax * size) * getPosByAngle(rotation); // Outer point, rotated by `rotation` uv = uv * 0.5 + 0.5;
vec3 p1 = (radiusMin * size) * getPosByAngle(starangle + rotation); // Inner point, also rotated
// Calculate the position of the current fragment relative to the star's center return uv;
vec2 curPosuv = (uv - center); // Center UV coordinates, then scale to fit the star size }
float curRadius = length(curPosuv); // Radius from center, no need to scale further
float curPosAngle = atan(curPosuv.y, curPosuv.x) - rotation; // Calculate angle and adjust by `rotation`
// Determine the fractional position within the current star segment //rotates the UV
float a = fract(curPosAngle / starangle); // Fractional angle position within one segment //needs to use this once since it rotates around the middle (i.e. 0.5)
if (a >= 0.5) vec2 rotateUV(vec2 uv, float rotation)
a = 1.0 - a; // Ensure we are within the first half of the segment (symmetry) {
float mid = 0.5;
// Calculate the current point on the star segment, applying rotation return vec2(
a = a * starangle; // Actual angle for this position on the segment cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,
vec3 curPos = curRadius * getPosByAngle(a + rotation); // Final position, rotated cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid
// Calculate directions for edge detection using cross product
vec3 dir0 = p1 - p0; // Vector from outer to inner point
vec3 dir1 = curPos - p0; // Vector from outer point to current position
float crossZ = dir0.x * dir1.y - dir0.y * dir1.x;
float result = remap(
crossZ,
0.0,0.03,//0.0275,
0.0,1.0 //hardness [1.0,100]
); );
}
//brightness
result = result * 7.0; //this returns the Spark
result = clamp(result,0.0,1.0); float getSpark(vec2 uv, vec2 center, float brightness, float size, float rotation)
result = easeInSine(result); {
brightness = clamp(brightness,0.001,1.0);
return result; size = clamp(size,0.001,1.0);
float bn = mix(0.0,0.07,brightness); //recalculate size
uv = (uv + vec2(0.5)) ;
uv = (uv - center) ;//Center UV coordinates, then scale to fit the star size
uv = scaleUV(uv, vec2(1.0 - size));
uv = rotateUV(uv, rotation); //rotate the UV
//this is basically the brightness
float p = mix(-1.0,1000.0,easeInExpo(bn));
float m = mix(
0.0,
1.0,
clamp(
pow(abs(uv.x-0.5)*2.0,p) + pow(abs(uv.y-0.5)*2.0,p),0.0,1.0
)
);
float mask = easeInSine(1.0 - (m - bn)) - 0.004 ;
mask = clamp(mask,0.0,1.0);
return mask;
} }
//returns the star's color
vec4 getStarColor(float v, float alpha) { vec4 getStarColor(float v, float alpha) {
// Clamp v to ensure it's in [0.0, 1.0] // Clamp v to ensure it's in [0.0, 1.0]
v = clamp(v, 0.0, 1.0); v = clamp(v, 0.0, 1.0);
@@ -201,8 +212,8 @@ vec4 getStarColor(float v, float alpha) {
return vec4(0.0, 0.0, 0.0, 1.0); return vec4(0.0, 0.0, 0.0, 1.0);
} }
float zeroStartEnd(float t, float max_size, float power)
{
// 1| __________ // 1| __________
// | / \ // | / \
// | / \ // | / \
@@ -214,11 +225,11 @@ graph above ... where t is close to 0, or 1 the result will fade to zero
i.e. this is just the function of power(x,p) shifted i.e. this is just the function of power(x,p) shifted
where x is time, and p is 2.0,4.0,8.0,10.0 ... or any positive even number where x is time, and p is 2.0,4.0,8.0,10.0 ... or any positive even number
*/ */
float zeroStartEnd(float t, float max_size, float power)
{
float s = -1.0 * pow((t-0.5)/(0.5),power)+1.0; float s = -1.0 * pow((t-0.5)/(0.5),power)+1.0;
s = clamp(s,0.0,1.0) * max_size; s = clamp(s,0.0,1.0) * max_size;
return s; return s;
} }
//this gives us the jerky 8bit growth effect. //this gives us the jerky 8bit growth effect.
@@ -264,48 +275,50 @@ float eightBitScale(float progress)
return scale; return scale;
} }
//use to scale the window
vec2 scaleUV(vec2 uv, vec2 scale) //gets all the sparks
vec4 getSparks(float progress)
{ {
// Put texture coordinate origin to center of window. //the UV for this function
uv = uv * 2.0 - 1.0; float aspect = uSize.x / uSize.y;
vec2 uv = iTexCoord.st * vec2(aspect,1.0);
//scale
uv /= mix(vec2(1.0,1.0), vec2(0.0,0.0), scale);
// scale from center
uv = uv * 0.5 + 0.5;
return uv;
}
vec4 get4pStars(vec2 starUV, float progress)
{
//this will be the result to return //this will be the result to return
vec4 result = vec4(0.0); vec4 result = vec4(0.0);
vec2 h = vec2(0.0); // 0 at the edges
float xEdge = -1.0 * pow((uv.x-(aspect*0.5))/(aspect*0.5),8.0)+1.0;
xEdge = clamp(xEdge,0.0,1.0);
//declare some variables before the loop
vec2 h = vec2(0.0);
float y = 0.0; float y = 0.0;
float x = 0.0;
for (float x = 0.0; x < u4PStars; ++x) //loop for each spart
for (float xusp = 0.0; xusp < uSparkCount; ++xusp)
{ {
h = hash21(x); //calculate some variables
y = mix( 0.0 - h.y , 1.0+(1.0-h.y) , (1.0 - progress)); h = hash21(xusp + uSeed.x);
y = mix( 0.0 - h.y , 1.0+(1.0-h.y) , progress);
y = clamp(y,0.0,1.0);
float a4ps = getStarWithFade( x = 0.66 * sin(h.x * 6.28) ;
starUV, x += 0.5 * aspect;
vec2( sin(h.x * 6.28 ) * 0.66, y), //position (x, y)
4.0, //nPoints //here we get the mask for the spark
0.33, //radiusRatio float a4ps = getSpark(
zeroStartEnd(y,0.1 ,4.0), //Size uv,
progress * 6.28 * float(u4PSRotation) //rotation vec2( x , y), //position (x, y)
zeroStartEnd(y,1.0 ,4.0) * xEdge ,//Brightness
zeroStartEnd(y,0.5 ,4.0) * xEdge,//Size
progress * 6.28 * float(uSparkRotation) //rotation
); );
//set it to the results
result = alphaOver( result = alphaOver(
result, result,
vec4(u4PSColor.r,u4PSColor.g,u4PSColor.b,u4PSColor.a * a4ps) vec4(uSparkColor.r,uSparkColor.g,uSparkColor.b,uSparkColor.a * a4ps)
); );
} }
@@ -313,17 +326,24 @@ vec4 get4pStars(vec2 starUV, float progress)
return result; return result;
} }
//gets the Rays
vec4 getRays(float progress) vec4 getRays(float progress)
{ {
//create the UV for it
vec2 rayUV = iTexCoord.st; vec2 rayUV = iTexCoord.st;
rayUV *= vec2(10.0,0.5); rayUV *= vec2(10.0,0.5);
rayUV.y += progress * -1.0; rayUV.y += progress * -1.0;
rayUV.x += uSeed.y;
//gets the ray
float ray = simplex2D(rayUV); float ray = simplex2D(rayUV);
//0 around the edges
ray *= zeroStartEnd(iTexCoord.t,1.0,8.0); ray *= zeroStartEnd(iTexCoord.t,1.0,8.0);
ray *= zeroStartEnd(iTexCoord.s,1.0,8.0);
// 0 at the begining and end of the animation
ray *= zeroStartEnd(progress,1.0,8.0); ray *= zeroStartEnd(progress,1.0,8.0);
//adjust the numbers and clamp
ray = remap( ray = remap(
ray * 1.10, ray * 1.10,
0.0,1.0, 0.0,1.0,
@@ -331,11 +351,13 @@ vec4 getRays(float progress)
); );
ray = clamp(ray,0.0,1.0); ray = clamp(ray,0.0,1.0);
//return
return vec4(uRaysColor.r,uRaysColor.g,uRaysColor.b,uRaysColor.a * ray); return vec4(uRaysColor.r,uRaysColor.g,uRaysColor.b,uRaysColor.a * ray);
} }
vec4 get5PStars(vec2 starUV, float aspect, float progress, float oColorAlpha) //returns the stars
vec4 getStars(vec2 starUV, float aspect, float progress, float oColorAlpha)
{ {
//this will be the result to return //this will be the result to return
vec4 result = vec4(0.0); vec4 result = vec4(0.0);
@@ -344,19 +366,19 @@ vec4 get5PStars(vec2 starUV, float aspect, float progress, float oColorAlpha)
float y = 0.0; float y = 0.0;
//for each ring //for each ring
for (float r = 0.0; r < uRings; ++r) for (float r = 0.0; r < uRingCount; ++r)
{ {
float spread = r*(1.0/uRings); float spread = r*(1.0/uRingCount);
y = mix( 0.0 - spread , 1.0+(1.0-spread) , 1.0 - progress); y = mix( 0.0 - spread , 1.0+(1.0-spread) , 1.0 - progress);
y = clamp(y,0.00001,0.99999); y = clamp(y,0.00001,0.99999);
//each star in each ring //each star in each ring
for (float s = 0.0; s < uStarPerRing; ++s) for (float s = 0.0; s < uStarCount; ++s)
{ {
float a5ps = getStar( float a5ps = getStar(
starUV, starUV,
vec2( sin(progress * uRingRotation * 6.28 + (s*(6.28/uStarPerRing))) * aspect * 0.33 , y), //position (x, y) vec2( sin(progress * uRingRotation * 6.28 + (s*(6.28/uStarCount))) * aspect * 0.33 , y), //position (x, y)
5.0, //nPoints 5.0, //nPoints
0.5, //radiusRatio 0.5, //radiusRatio
zeroStartEnd(y,0.1,2.0), //Size zeroStartEnd(y,0.1,2.0), //Size
@@ -365,7 +387,7 @@ vec4 get5PStars(vec2 starUV, float aspect, float progress, float oColorAlpha)
a5ps = clamp(a5ps,0.0,1.0); a5ps = clamp(a5ps,0.0,1.0);
// //put the star in back or the front of the window // //put the star in back or the front of the window
float depth = cos(progress * uRingRotation * 6.28 + (s*(6.28/uStarPerRing)) ); float depth = cos(progress * uRingRotation * 6.28 + (s*(6.28/uStarCount)) );
if (depth < 0.0) if (depth < 0.0)
{ {
result = alphaOver(result,getStarColor(y,a5ps)); result = alphaOver(result,getStarColor(y,a5ps));
@@ -395,55 +417,48 @@ void main() {
// Initialize the output color to fully transparent black // Initialize the output color to fully transparent black
vec4 oColor = vec4(0.0, 0.0, 0.0, 0.0); vec4 oColor = vec4(0.0, 0.0, 0.0, 0.0);
// Check if the 8-bit style is enabled
if (u8BitStyle) //get scales
float scale8bit = eightBitScale(progress);
vec2 scaleV2 = vec2(easeInOutSine(progress), easeInQuad(progress));
vec2 fscale = mix(vec2(scale8bit),scaleV2,uScaleStyle);
// Fetch the color based on the scaled texture coordinates
oColor = getInputColor(
scaleUV(iTexCoord.st, fscale)
);
// Store the alpha value of the fetched color for later use
float oColorAlpha = oColor.a;
// Calculate the aspect ratio of the render area
float aspect = uSize.x / uSize.y;
// Transform UV coordinates for star effects
// starUV.x [-0.5 , 0.5]
// starUV.y [1.0 , 0.0]
vec2 starUV = vec2(iTexCoord.s - 0.5, 1.0 - iTexCoord.t) * vec2(aspect, 1.0);
// If four-point stars are enabled, overlay them on the current color
if (uSparkCount > 0.0)
{ {
// Scale UV coordinates using a custom 8-bit scaling function oColor = alphaOver(oColor, getSparks(progress));
float scale8bit = eightBitScale(progress);
// Fetch the color based on the scaled texture coordinates
oColor = getInputColor(
scaleUV(iTexCoord.st, vec2(scale8bit, scale8bit))
);
} }
else
// If rays are enabled, overlay them on the current color
if (uRaysColor.a > 0.0)
{ {
// Non-8-bit style: Calculate scaling factors using easing functions oColor = alphaOver(oColor, getRays(progress));
vec2 scaleV2 = vec2(easeInOutSine(progress), easeInQuad(progress));
// Fetch the color based on the scaled texture coordinates
oColor = getInputColor(
scaleUV(iTexCoord.st, scaleV2)
);
// Store the alpha value of the fetched color for later use
float oColorAlpha = oColor.a;
// Calculate the aspect ratio of the render area
float aspect = uSize.x / uSize.y;
// Transform UV coordinates for star effects
vec2 starUV = vec2(iTexCoord.s - 0.5, 1.0 - iTexCoord.t) * vec2(aspect, 1.0);
// If four-point stars are enabled, overlay them on the current color
if (uEnable4PStars)
{
oColor = alphaOver(oColor, get4pStars(starUV, progress));
}
// If rays are enabled, overlay them on the current color
if (uEnableRays)
{
oColor = alphaOver(oColor, getRays(progress));
}
// If five-point stars are enabled, overlay them using stored alpha
if (uEnable5pStars)
{
oColor = alphaOver(oColor, get5PStars(starUV, aspect, progress, oColorAlpha));
}
} }
// If five-point stars are enabled, overlay them using stored alpha
if (uRingCount > 0.0 && uStarCount > 0.0)
{
oColor = alphaOver(oColor, getStars(starUV, aspect, progress, oColorAlpha));
}
// Set the final output color to the computed value // Set the final output color to the computed value
setOutputColor(oColor); setOutputColor(oColor);
+153 -182
View File
@@ -13,60 +13,52 @@ SPDX-License-Identifier: GPL-3.0-or-later
<!-- Animation Time Adjustment Section --> <!-- Animation Time Adjustment Section -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title for the animation time adjustment slider -->
<property name="title" translatable="yes">Animation Time [ms]</property> <property name="title" translatable="yes">Animation Time [ms]</property>
<child> <child>
<!-- Slider for adjusting animation duration -->
<object class="GtkScale"> <object class="GtkScale">
<property name="valign">center</property> <property name="valign">center</property>
<property name="draw-value">1</property> <!-- Display the current value --> <property name="draw-value">1</property>
<property name="digits">0</property> <!-- Number of decimal places --> <property name="digits">0</property>
<property name="value-pos">left</property> <!-- Position of the displayed value --> <property name="value-pos">left</property>
<property name="width-request">300</property> <!-- Width of the slider --> <property name="width-request">300</property>
<!-- Adjustment settings for the slider -->
<property name="adjustment"> <property name="adjustment">
<object class="GtkAdjustment" id="mushroom-animation-time"> <object class="GtkAdjustment" id="mushroom-animation-time">
<property name="upper">5000</property> <!-- Maximum value --> <property name="upper">5000</property>
<property name="lower">100</property> <!-- Minimum value --> <property name="lower">100</property>
<property name="step-increment">10</property> <!-- Smallest increment --> <property name="step-increment">10</property>
<property name="page-increment">100</property> <!-- Larger increment --> <property name="page-increment">100</property>
</object> </object>
</property> </property>
</object> </object>
</child> </child>
<!-- Button to reset animation time to its default value -->
<child> <child>
<object class="GtkButton" id="reset-mushroom-animation-time"> <object class="GtkButton" id="reset-mushroom-animation-time">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon --> <property name="icon-name">edit-clear-symbolic</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
<class name="flat" /> <!-- Flat button style --> <class name="flat" />
</style> </style>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<!-- 8Bit Style Toggle Section --> <!-- Star Color Presets -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title and description for 8Bit style toggle -->
<property name="title" translatable="yes">8Bit Style</property> <property name="title" translatable="yes">Color Presets</property>
<property name="subtitle" translatable="yes">If ON an old 8Bit Style will be used</property> <property name="activatable-widget">mushroom-star-color-preset-button</property>
<!-- Toggle switch for enabling or disabling 8Bit style -->
<property name="activatable-widget">mushroom-8bit-enable</property>
<child> <child>
<object class="GtkSwitch" id="mushroom-8bit-enable"> <object class="GtkMenuButton" id="mushroom-star-color-preset-button">
<property name="valign">center</property> <property name="valign">center</property>
</object> <property name="label" translatable="yes">Choose a Preset</property>
</child>
<!-- Button to reset the 8Bit style toggle to its default value -->
<child>
<object class="GtkButton" id="reset-mushroom-8bit-enable">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon -->
<property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
<class name="flat" /> <class name="flat" />
</style> </style>
@@ -74,23 +66,35 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child> </child>
</object> </object>
</child> </child>
<!-- Toggle for showing 4-Point Stars (Sparks) -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title for enabling or disabling 4-point stars -->
<property name="title" translatable="yes">Show 4Point Stars (Sparks)</property> <property name="title" translatable="yes">Scale Style</property>
<!-- Switch for toggling visibility of 4-point stars --> <property name="subtitle" translatable="yes">8Bit --- Smooth</property>
<property name="activatable-widget">mushroom-4pstars-enable</property>
<child> <child>
<object class="GtkSwitch" id="mushroom-4pstars-enable"> <object class="GtkScale" id="mushroom-scale-style-scale">
<property name="valign">center</property> <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="mushroom-scale-style">
<property name="upper">1.0</property>
<property name="lower">0.0</property>
<property name="step-increment">0.1</property>
<property name="page-increment">0.25</property>
</object>
</property>
</object> </object>
</child> </child>
<!-- Button to reset 4-point stars visibility to default -->
<child> <child>
<object class="GtkButton" id="reset-mushroom-4pstars-enable"> <object class="GtkButton" id="reset-mushroom-scale-style">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon --> <property name="icon-name">edit-clear-symbolic</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
@@ -104,31 +108,69 @@ SPDX-License-Identifier: GPL-3.0-or-later
<!-- Adjustment for 4-Point Stars Count --> <!-- Adjustment for 4-Point Stars Count -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title for the slider controlling the count of 4-point stars -->
<property name="title" translatable="yes">4Point Star (Sparks) Count</property> <property name="title" translatable="yes">Spark Count</property>
<!-- Slider for adjusting the count of 4-point stars -->
<child> <child>
<object class="GtkScale" id="mushroom-4pstars-count-scale"> <object class="GtkScale" id="mushroom-spark-count-scale">
<property name="valign">center</property> <property name="valign">center</property>
<property name="draw-value">1</property> <property name="draw-value">1</property>
<property name="digits">0</property> <property name="digits">0</property>
<property name="value-pos">left</property> <property name="value-pos">left</property>
<property name="width-request">300</property> <property name="width-request">300</property>
<!-- Adjustment settings for the slider -->
<property name="adjustment"> <property name="adjustment">
<object class="GtkAdjustment" id="mushroom-4pstars-count"> <object class="GtkAdjustment" id="mushroom-spark-count">
<property name="upper">100</property> <!-- Maximum count --> <property name="upper">25</property>
<property name="lower">0</property> <!-- Minimum count --> <property name="lower">0</property>
<property name="step-increment">1</property> <!-- Step size --> <property name="step-increment">1</property>
<property name="page-increment">5</property> <!-- Page increment size --> <property name="page-increment">5</property>
</object> </object>
</property> </property>
</object> </object>
</child> </child>
<!-- Button to reset 4-point stars count to default -->
<child> <child>
<object class="GtkButton" id="reset-mushroom-4pstars-count"> <object class="GtkButton" id="reset-mushroom-spark-count">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon --> <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>
<!-- Adjustment for 4-Point Stars Count -->
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Spark Rotation</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="mushroom-spark-rotation">
<property name="upper">3.0</property>
<property name="lower">-3.0</property>
<property name="step-increment">0.5</property>
<property name="page-increment">0.25</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-mushroom-spark-rotation">
<property name="icon-name">edit-clear-symbolic</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
@@ -142,53 +184,27 @@ SPDX-License-Identifier: GPL-3.0-or-later
<!-- Color Picker for 4-Point Stars --> <!-- Color Picker for 4-Point Stars -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title for the 4-point stars color picker -->
<property name="title" translatable="yes">4Point Star (Sparks) Color</property> <property name="title" translatable="yes">Spark Color</property>
<!-- Color picker for customizing the 4-point stars -->
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<style> <style>
<class name="linked" /> <class name="linked" />
</style> </style>
<child> <child>
<object class="GtkColorButton" id="mushroom-4pstars-color"> <object class="GtkColorButton" id="mushroom-spark-color">
<property name="use_alpha">1</property> <!-- Enable alpha channel --> <property name="use_alpha">1</property>
<property name="show_editor">1</property> <!-- Show advanced editor --> <property name="show_editor">1</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<!-- Button to reset the color picker to default -->
<child> <child>
<object class="GtkButton" id="reset-mushroom-4pstars-color"> <object class="GtkButton" id="reset-mushroom-spark-color">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon --> <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>
<!-- Rays Toggle -->
<child>
<object class="AdwActionRow">
<!-- Title for enabling or disabling rays -->
<property name="title" translatable="yes">Show Rays</property>
<!-- Toggle switch for controlling the visibility of rays -->
<property name="activatable-widget">mushroom-rays-enable</property>
<child>
<object class="GtkSwitch" id="mushroom-rays-enable">
<property name="valign">center</property>
</object>
</child>
<!-- Button to reset the rays toggle to its default value -->
<child>
<object class="GtkButton" id="reset-mushroom-rays-enable">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon -->
<property name="valign">center</property> <property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
@@ -202,9 +218,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
<!-- Rays Color Picker --> <!-- Rays Color Picker -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title for the rays color picker -->
<property name="title" translatable="yes">Rays Color</property> <property name="title" translatable="yes">Rays Color</property>
<!-- Color picker for customizing rays -->
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<style> <style>
@@ -212,43 +228,17 @@ SPDX-License-Identifier: GPL-3.0-or-later
</style> </style>
<child> <child>
<object class="GtkColorButton" id="mushroom-rays-color"> <object class="GtkColorButton" id="mushroom-rays-color">
<property name="use_alpha">1</property> <!-- Enable alpha channel --> <property name="use_alpha">1</property>
<property name="show_editor">1</property> <!-- Show advanced editor --> <property name="show_editor">1</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<!-- Button to reset the rays color picker to its default value -->
<child> <child>
<object class="GtkButton" id="reset-mushroom-rays-color"> <object class="GtkButton" id="reset-mushroom-rays-color">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon --> <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>
<!-- Star Rings Toggle -->
<child>
<object class="AdwActionRow">
<!-- Title for enabling or disabling star rings -->
<property name="title" translatable="yes">Show Star Rings</property>
<!-- Toggle switch for controlling the visibility of star rings -->
<property name="activatable-widget">mushroom-5pstars-enable</property>
<child>
<object class="GtkSwitch" id="mushroom-5pstars-enable">
<property name="valign">center</property>
</object>
</child>
<!-- Button to reset the star rings toggle to its default value -->
<child>
<object class="GtkButton" id="reset-mushroom-5pstars-enable">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon -->
<property name="valign">center</property> <property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
@@ -262,31 +252,31 @@ SPDX-License-Identifier: GPL-3.0-or-later
<!-- Star Rings Count Adjustment --> <!-- Star Rings Count Adjustment -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title for the slider controlling the number of star rings -->
<property name="title" translatable="yes">Star Rings Count</property> <property name="title" translatable="yes">Star Rings Count</property>
<!-- Slider for adjusting the number of star rings -->
<child> <child>
<object class="GtkScale" id="mushroom-5pstarring-count-scale"> <object class="GtkScale" id="mushroom-ring-count-scale">
<property name="valign">center</property> <property name="valign">center</property>
<property name="draw-value">1</property> <property name="draw-value">1</property>
<property name="digits">0</property> <property name="digits">0</property>
<property name="value-pos">left</property> <property name="value-pos">left</property>
<property name="width-request">300</property> <property name="width-request">300</property>
<!-- Adjustment settings for the slider -->
<property name="adjustment"> <property name="adjustment">
<object class="GtkAdjustment" id="mushroom-5pstarring-count"> <object class="GtkAdjustment" id="mushroom-ring-count">
<property name="upper">10</property> <!-- Maximum count --> <property name="upper">5</property>
<property name="lower">1</property> <!-- Minimum count --> <property name="lower">0</property>
<property name="step-increment">1</property> <!-- Step size --> <property name="step-increment">1</property>
<property name="page-increment">3</property> <!-- Page increment size --> <property name="page-increment">3</property>
</object> </object>
</property> </property>
</object> </object>
</child> </child>
<!-- Button to reset the star rings count to its default value -->
<child> <child>
<object class="GtkButton" id="reset-mushroom-5pstarring-count"> <object class="GtkButton" id="reset-mushroom-ring-count">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon --> <property name="icon-name">edit-clear-symbolic</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
@@ -300,31 +290,31 @@ SPDX-License-Identifier: GPL-3.0-or-later
<!-- Star Rings Rotation Adjustment --> <!-- Star Rings Rotation Adjustment -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title for the slider controlling the rotation of star rings -->
<property name="title" translatable="yes">Star Ring Rotation</property> <property name="title" translatable="yes">Star Ring Rotation</property>
<!-- Slider for adjusting the rotation of star rings -->
<child> <child>
<object class="GtkScale" id="mushroom-5pstarring-rotation-scale"> <object class="GtkScale" id="mushroom-ring-rotation-scale">
<property name="valign">center</property> <property name="valign">center</property>
<property name="draw-value">1</property> <property name="draw-value">1</property>
<property name="digits">2</property> <property name="digits">2</property>
<property name="value-pos">left</property> <property name="value-pos">left</property>
<property name="width-request">300</property> <property name="width-request">300</property>
<!-- Adjustment settings for the slider -->
<property name="adjustment"> <property name="adjustment">
<object class="GtkAdjustment" id="mushroom-5pstarring-rotation"> <object class="GtkAdjustment" id="mushroom-ring-rotation">
<property name="upper">5.0</property> <!-- Maximum rotation --> <property name="upper">3.0</property>
<property name="lower">-5.0</property> <!-- Minimum rotation --> <property name="lower">-3.0</property>
<property name="step-increment">0.25</property> <!-- Step size --> <property name="step-increment">0.25</property>
<property name="page-increment">1.0</property> <!-- Page increment size --> <property name="page-increment">1.0</property>
</object> </object>
</property> </property>
</object> </object>
</child> </child>
<!-- Button to reset the star rings rotation to its default value -->
<child> <child>
<object class="GtkButton" id="reset-mushroom-5pstarring-rotation"> <object class="GtkButton" id="reset-mushroom-ring-rotation">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon --> <property name="icon-name">edit-clear-symbolic</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
@@ -338,31 +328,31 @@ SPDX-License-Identifier: GPL-3.0-or-later
<!-- Stars Per Star Ring Count Adjustment --> <!-- Stars Per Star Ring Count Adjustment -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title for the slider controlling the number of stars per ring -->
<property name="title" translatable="yes">Stars Per Star Ring Count</property> <property name="title" translatable="yes">Stars Count Per Ring</property>
<!-- Slider for adjusting the number of stars per star ring -->
<child> <child>
<object class="GtkScale" id="mushroom-5pstars-count-scale"> <object class="GtkScale" id="mushroom-star-count-scale">
<property name="valign">center</property> <property name="valign">center</property>
<property name="draw-value">1</property> <property name="draw-value">1</property>
<property name="digits">0</property> <property name="digits">0</property>
<property name="value-pos">left</property> <property name="value-pos">left</property>
<property name="width-request">300</property> <property name="width-request">300</property>
<!-- Adjustment settings for the slider -->
<property name="adjustment"> <property name="adjustment">
<object class="GtkAdjustment" id="mushroom-5pstars-count"> <object class="GtkAdjustment" id="mushroom-star-count">
<property name="upper">10</property> <!-- Maximum stars per ring --> <property name="upper">7</property>
<property name="lower">1</property> <!-- Minimum stars per ring --> <property name="lower">0</property>
<property name="step-increment">1</property> <!-- Step size --> <property name="step-increment">1</property>
<property name="page-increment">3</property> <!-- Page increment size --> <property name="page-increment">3</property>
</object> </object>
</property> </property>
</object> </object>
</child> </child>
<!-- Button to reset the stars per ring count to its default value -->
<child> <child>
<object class="GtkButton" id="reset-mushroom-5pstars-count"> <object class="GtkButton" id="reset-mushroom-star-count">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon --> <property name="icon-name">edit-clear-symbolic</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
@@ -373,41 +363,22 @@ SPDX-License-Identifier: GPL-3.0-or-later
</object> </object>
</child> </child>
<!-- Star Color Presets -->
<child>
<object class="AdwActionRow">
<!-- Title for selecting color presets -->
<property name="title" translatable="yes">Color Presets</property>
<property name="activatable-widget">mushroom-star-color-preset-button</property>
<!-- Dropdown menu for selecting predefined color presets -->
<child>
<object class="GtkMenuButton" id="mushroom-star-color-preset-button">
<property name="valign">center</property>
<property name="label" translatable="yes">Choose a Preset</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
<!-- Star Gradient Color Adjustment --> <!-- Star Gradient Color Adjustment -->
<child> <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<!-- Title for the star gradient color settings -->
<property name="title" translatable="yes">Star Gradient</property> <property name="title" translatable="yes">Star Gradient</property>
<!-- Box containing multiple color pickers for gradient customization -->
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<style> <style>
<class name="linked" /> <class name="linked" />
</style> </style>
<!-- Individual color pickers for each gradient step -->
<child> <child>
<object class="GtkColorButton" id="mushroom-star-color-0"> <object class="GtkColorButton" id="mushroom-star-color-0">
<property name="use_alpha">1</property> <!-- Enable alpha channel --> <property name="use_alpha">1</property>
<property name="show_editor">1</property> <!-- Show advanced editor --> <property name="show_editor">1</property>
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
@@ -448,10 +419,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
</child> </child>
</object> </object>
</child> </child>
<!-- Button to reset all star gradient colors to their default values -->
<child> <child>
<object class="GtkButton" id="reset-star-colors"> <object class="GtkButton" id="reset-star-colors">
<property name="icon-name">edit-clear-symbolic</property> <!-- Reset icon --> <property name="icon-name">edit-clear-symbolic</property>
<property name="valign">center</property> <property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Reset to Default Value</property> <property name="tooltip-text" translatable="yes">Reset to Default Value</property>
<style> <style>
@@ -866,40 +866,34 @@ SPDX-License-Identifier: CC0-1.0
<description>The time the mushroom effect takes.</description> <description>The time the mushroom effect takes.</description>
</key> </key>
<key name="mushroom-8bit-enable" type="b"> <!-- <key name="mushroom-8bit-enable" type="b">
<default>true</default> <default>true</default>
<summary>mushroom 8Bit Animation</summary> <summary>mushroom 8Bit Animation</summary>
<description>use the old style.</description> <description>use the old style.</description>
</key> -->
<key name="mushroom-scale-style" type="d">
<default>1.0</default>
<summary>8Bit or Smooth Scaling</summary>
<description>How the window scales</description>
</key> </key>
<key name="mushroom-4pstars-enable" type="b"> <key name="mushroom-spark-count" type="i">
<default>true</default>
<summary>Enable the 4Pointed Stars</summary>
<description>Enable the 4Pointed Stars</description>
</key>
<key name="mushroom-4pstars-count" type="i">
<default>4</default> <default>4</default>
<summary>The Number of 4Pointed Stars</summary> <summary>The Number of Sparks</summary>
<description>The Number of 4Pointed Stars</description> <description>The Number of Sparks</description>
</key> </key>
<key name="mushroom-4pstars-color" type="s"> <key name="mushroom-spark-color" type="s">
<default>"rgba(255, 255, 255, 1.0)"</default> <default>"rgba(255, 255, 255, 1.0)"</default>
<summary>The 4Pointed Star Color</summary> <summary>The Sparks Color</summary>
<description>The 4Pointed Star Color</description> <description>The Sparks Color</description>
</key> </key>
<key name="mushroom-4pstars-rotation" type="d"> <key name="mushroom-spark-rotation" type="d">
<default>0.3</default> <default>0.3</default>
<summary>The Number of Rotations the 4Pointed Stars do</summary> <summary>The Number of Rotations the Sparks do</summary>
<description>The Number of Rotations the 4Pointed Stars do</description> <description>The Number of Rotations the Sparks do</description>
</key>
<key name="mushroom-rays-enable" type="b">
<default>true</default>
<summary>Enable the Rays</summary>
<description>use the old style.</description>
</key> </key>
<key name="mushroom-rays-color" type="s"> <key name="mushroom-rays-color" type="s">
@@ -908,28 +902,22 @@ SPDX-License-Identifier: CC0-1.0
<description>The Rays Color</description> <description>The Rays Color</description>
</key> </key>
<key name="mushroom-5pstars-enable" type="b"> <key name="mushroom-ring-count" type="i">
<default>true</default>
<summary>Enable the 5 Pointed Stars</summary>
<description>Enable the 5 Pointed Stars</description>
</key>
<key name="mushroom-5pstarring-count" type="i">
<default>3</default> <default>3</default>
<summary>Number of Rings of 5Pointed Stars</summary> <summary>Number of Rings</summary>
<description>Number of Rings of 5 Pointed Stars</description> <description>Number of Rings</description>
</key> </key>
<key name="mushroom-5pstarring-rotation" type="d"> <key name="mushroom-ring-rotation" type="d">
<default>1.33</default> <default>1.33</default>
<summary>The Number of Rotations/Cycles the 5Pointed Stars do</summary> <summary>The Number of Rotations/Cycles the Stars do</summary>
<description>The Number of Rotations/Cycles the 5Pointed Stars do</description> <description>The Number of Rotations/Cycles the Stars do</description>
</key> </key>
<key name="mushroom-5pstars-count" type="i"> <key name="mushroom-star-count" type="i">
<default>5</default> <default>5</default>
<summary>The Number of 5Pointed Stars in each Ring</summary> <summary>The Number of Stars in each Ring</summary>
<description>The Number of 5Pointed Stars in each Ring</description> <description>The Number of Stars in each Ring</description>
</key> </key>
<key name="mushroom-star-color-0" type="s"> <key name="mushroom-star-color-0" type="s">
+1 -3
View File
@@ -174,8 +174,7 @@ export default class Effect {
const colorOffset = dialog.getBuilder().get_object('aura-glow-color-offset-scale'); const colorOffset = dialog.getBuilder().get_object('aura-glow-color-offset-scale');
const actionRow = dialog.getBuilder().get_object('aura-glow-action-row'); const actionRow = dialog.getBuilder().get_object('aura-glow-action-row');
if (colorOffset == null) if (colorOffset == null) {
{
log('colorOffset is null'); log('colorOffset is null');
} }
@@ -207,7 +206,6 @@ export default class Effect {
// Function to update the subtitle based on the slider value // Function to update the subtitle based on the slider value
const updateSubtitle = () => { const updateSubtitle = () => {
const value = colorOffset.get_value(); // Get the current slider value const value = colorOffset.get_value(); // Get the current slider value
const index = Math.round(value * 20); // Map value [0.0, 1.0] to index [0, 10] const index = Math.round(value * 20); // Map value [0.0, 1.0] to index [0, 10]
actionRow.set_subtitle( actionRow.set_subtitle(
+131 -274
View File
@@ -24,7 +24,6 @@ import Gio from 'gi://Gio';
// application. // application.
import * as utils from '../utils.js'; import * as utils from '../utils.js';
// We import the ShaderFactory only in the Shell process as it is not required in the // 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 // preferences process. The preferences process does not create any shader instances, it
// only uses the static metadata of the effect. // only uses the static metadata of the effect.
@@ -33,8 +32,9 @@ const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
const _ = await utils.importGettext(); const _ = await utils.importGettext();
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// This effect was obviously inspired my the 8bit mario video games of old, specifically// // This effect is inspired by the old 8bit mario video games and the New Super Mario //
// when mario gets the mushroom. i hope you enjoy this little blast from the past. // // Bros 2 specifically when mario gets the mushroom. i hope you enjoy this little blast //
// from the past. //
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// The effect class can be used to get some metadata (like the effect's name or supported // The effect class can be used to get some metadata (like the effect's name or supported
@@ -58,20 +58,20 @@ export default class Effect {
shader.get_uniform_location('uStarColor5'), shader.get_uniform_location('uStarColor5'),
]; ];
shader._u8BitStyle = shader.get_uniform_location('u8BitStyle');
shader._uEnable4PStars = shader.get_uniform_location('uEnable4PStars'); shader._uScaleStyle = shader.get_uniform_location('uScaleStyle');
shader._u4PStars = shader.get_uniform_location('u4PStars');
shader._u4PSColor = shader.get_uniform_location('u4PSColor');
shader._u4PSRotation = shader.get_uniform_location('u4PSRotation');
shader._uEnableRays = shader.get_uniform_location('uEnableRays'); shader._uSparkCount = shader.get_uniform_location('uSparkCount');
shader._uRaysColor = shader.get_uniform_location('uRaysColor'); shader._uSparkColor = shader.get_uniform_location('uSparkColor');
shader._uSparkRotation = shader.get_uniform_location('uSparkRotation');
shader._uEnable5pStars = shader.get_uniform_location('uEnable5pStars'); shader._uRaysColor = shader.get_uniform_location('uRaysColor');
shader._uRings = shader.get_uniform_location('uRings');
shader._uRingRotation = shader.get_uniform_location('uRingRotation'); shader._uRingCount = shader.get_uniform_location('uRingCount');
shader._uStarPerRing = shader.get_uniform_location('uStarPerRing'); shader._uRingRotation = shader.get_uniform_location('uRingRotation');
shader._uStarCount = shader.get_uniform_location('uStarCount');
shader._uSeed = shader.get_uniform_location('uSeed');
// And update all uniforms at the start of each animation. // And update all uniforms at the start of each animation.
shader.connect('begin-animation', (shader, settings) => { shader.connect('begin-animation', (shader, settings) => {
@@ -82,21 +82,20 @@ export default class Effect {
} }
// clang-format off // clang-format off
shader.set_uniform_float(shader._u8BitStyle, 1, [settings.get_boolean('mushroom-8bit-enable')]);
shader.set_uniform_float(shader._uEnable4PStars, 1, [settings.get_boolean('mushroom-4pstars-enable')]); shader.set_uniform_float(shader._uScaleStyle, 1, [settings.get_double('mushroom-scale-style')]);
shader.set_uniform_float(shader._u4PStars, 1, [settings.get_int('mushroom-4pstars-count')]);
shader.set_uniform_float(shader._u4PSColor, 4, utils.parseColor(settings.get_string('mushroom-4pstars-color'))); shader.set_uniform_float(shader._uSparkCount, 1, [settings.get_int('mushroom-spark-count')]);
shader.set_uniform_float(shader._u4PSRotation, 1, [settings.get_double('mushroom-4pstars-rotation')]); shader.set_uniform_float(shader._uSparkColor, 4, utils.parseColor(settings.get_string('mushroom-spark-color')));
shader.set_uniform_float(shader._uSparkRotation, 1, [settings.get_double('mushroom-spark-rotation')]);
shader.set_uniform_float(shader._uEnableRays, 1, [settings.get_boolean('mushroom-rays-enable')]);
shader.set_uniform_float(shader._uRaysColor, 4, utils.parseColor(settings.get_string('mushroom-rays-color'))); shader.set_uniform_float(shader._uRaysColor, 4, utils.parseColor(settings.get_string('mushroom-rays-color')));
shader.set_uniform_float(shader._uEnable5pStars, 1, [settings.get_boolean('mushroom-5pstars-enable')]); shader.set_uniform_float(shader._uRingCount, 1, [settings.get_int('mushroom-ring-count')]);
shader.set_uniform_float(shader._uRings, 1, [settings.get_int('mushroom-5pstarring-count')]); shader.set_uniform_float(shader._uRingRotation, 1, [settings.get_double('mushroom-ring-rotation')]);
shader.set_uniform_float(shader._uRingRotation, 1, [settings.get_double('mushroom-5pstarring-rotation')]); shader.set_uniform_float(shader._uStarCount, 1, [settings.get_int('mushroom-star-count')]);
shader.set_uniform_float(shader._uStarPerRing, 1, [settings.get_int('mushroom-5pstars-count')]);
shader.set_uniform_float(shader._uSeed, 2, [Math.random(), Math.random()]);
// clang-format on // clang-format on
}); });
@@ -132,7 +131,19 @@ export default class Effect {
static bindPreferences(dialog) { static bindPreferences(dialog) {
// Empty for now... Code is added here later in the tutorial! // Empty for now... Code is added here later in the tutorial!
dialog.bindAdjustment('mushroom-animation-time'); dialog.bindAdjustment('mushroom-animation-time');
dialog.bindSwitch('mushroom-8bit-enable'); // dialog.bindSwitch('mushroom-8bit-enable');
dialog.bindAdjustment('mushroom-scale-style');
dialog.bindAdjustment('mushroom-spark-count');
dialog.bindColorButton('mushroom-spark-color');
dialog.bindAdjustment('mushroom-spark-rotation');
dialog.bindColorButton('mushroom-rays-color');
dialog.bindAdjustment('mushroom-ring-count');
dialog.bindAdjustment('mushroom-ring-rotation');
dialog.bindAdjustment('mushroom-star-count');
dialog.bindColorButton('mushroom-star-color-0'); dialog.bindColorButton('mushroom-star-color-0');
dialog.bindColorButton('mushroom-star-color-1'); dialog.bindColorButton('mushroom-star-color-1');
@@ -141,18 +152,6 @@ export default class Effect {
dialog.bindColorButton('mushroom-star-color-4'); dialog.bindColorButton('mushroom-star-color-4');
dialog.bindColorButton('mushroom-star-color-5'); dialog.bindColorButton('mushroom-star-color-5');
dialog.bindSwitch('mushroom-4pstars-enable');
dialog.bindAdjustment('mushroom-4pstars-count');
dialog.bindColorButton('mushroom-4pstars-color');
dialog.bindAdjustment('mushroom-4pstars-rotation');
dialog.bindSwitch('mushroom-rays-enable');
dialog.bindColorButton('mushroom-rays-color');
dialog.bindSwitch('mushroom-5pstars-enable');
dialog.bindAdjustment('mushroom-5pstarring-count');
dialog.bindAdjustment('mushroom-5pstarring-rotation');
dialog.bindAdjustment('mushroom-5pstars-count');
// Ensure the button connections and other bindings happen only once, // Ensure the button connections and other bindings happen only once,
// even if the bindPreferences function is called multiple times. // even if the bindPreferences function is called multiple times.
@@ -171,56 +170,9 @@ export default class Effect {
dialog.getProfileSettings().reset('mushroom-star-color-5'); dialog.getProfileSettings().reset('mushroom-star-color-5');
}); });
// Initialize the preset dropdown menu for mushroom star colors. // Initialize the preset dropdown menu for mushroom star colors.
Effect._createMushroomPresets(dialog); Effect._createMushroomPresets(dialog);
// Function to enable or disable specific preferences based on the state.
// If `state` is true, the preferences are disabled; if false, they are enabled.
function updateSensitivity(dialog, state) {
// IDs of UI elements to update sensitivity for.
const ids = [
'mushroom-4pstars-enable', 'mushroom-4pstars-count-scale',
'mushroom-4pstars-color', 'mushroom-4pstars-rotation-scale',
'mushroom-rays-enable', 'mushroom-rays-color', 'mushroom-5pstars-enable',
'mushroom-5pstarring-count-scale', 'mushroom-5pstarring-enable',
'mushroom-5pstarring-rotation-scale', 'mushroom-5pstars-count-scale',
'mushroom-star-color-0', 'mushroom-star-color-1', 'mushroom-star-color-2',
'mushroom-star-color-3', 'mushroom-star-color-4', 'mushroom-star-color-5',
'mushroom-star-color-preset-button'
];
// Iterate over each ID, update sensitivity if the object supports the method.
ids.forEach(id => {
const obj = dialog.getBuilder().get_object(id);
if (obj && typeof obj.set_sensitive === 'function') {
obj.set_sensitive(!state); // Disable if state is true, enable if false.
} else {
// Log a warning if the object is null or doesn't support set_sensitive.
log(`Warning: Object with ID '${
id}' does not support set_sensitive or is null.`);
}
});
}
// Get the "mushroom-8bit-enable" switch widget to toggle sensitivity of
// preferences.
const switchWidget = dialog.getBuilder().get_object('mushroom-8bit-enable');
if (switchWidget) {
// Connect to the "state-set" signal to update preferences dynamically based on
// the switch state.
switchWidget.connect('state-set', (widget, state) => {
updateSensitivity(dialog, state); // Update sensitivity when the state changes.
});
// Manually call the update function on startup, using the initial state of the
// switch.
const initialState =
switchWidget.get_active(); // Get the current state of the switch.
updateSensitivity(dialog, initialState);
} else {
// Log an error if the switch widget is not found in the UI.
log('Error: \'mushroom-8bit-enable\' switch widget not found.');
}
} }
} }
@@ -249,7 +201,15 @@ export default class Effect {
// format). // format).
const presets = [ const presets = [
{ {
name: _('Default Colors'), // Default yellow-green-to-cyan palette name: _('8Bit Plumber (Default)'),
ScaleStyle: 0.0,
SparkCount: 0,
SparkColor: 'rgba(255,255,255,0.0)',
SparkRotation: 0.33,
RayColor: 'rgba(255,255,255,0.0)',
RingCount: 0,
RingRotation: 0.0,
StarCount: 0,
color0: 'rgba(233,249,0,1.0)', color0: 'rgba(233,249,0,1.0)',
color1: 'rgba(233,249,0,1.0)', color1: 'rgba(233,249,0,1.0)',
color2: 'rgba(91,255,0,1.0)', color2: 'rgba(91,255,0,1.0)',
@@ -258,7 +218,32 @@ export default class Effect {
color5: 'rgba(0,240,236,1.0)', color5: 'rgba(0,240,236,1.0)',
}, },
{ {
name: _('Red White and Blue'), // A patriotic palette of red, white, and blue name: _('New Bros 2 🍄'),
ScaleStyle: 1.0,
SparkCount: 4,
SparkColor: 'rgba(255,255,255,1.0)',
SparkRotation: 0.3,
RayColor: 'rgba(255,255,255,1.0)',
RingCount: 3,
RingRotation: 1.33,
StarCount: 5,
color0: 'rgba(233,249,0,1.0)',
color1: 'rgba(233,249,0,1.0)',
color2: 'rgba(91,255,0,1.0)',
color3: 'rgba(91,255,0,1.0)',
color4: 'rgba(0,240,236,1.0)',
color5: 'rgba(0,240,236,1.0)',
},
{
name: _('Red White and Blue 🇺🇸'), // A patriotic palette of red, white, and blue
ScaleStyle: 1.0,
SparkCount: 4,
SparkColor: 'rgba(255,255,255,1.0)',
SparkRotation: 0.3,
RayColor: 'rgba(255,255,255,0.0)',
RingCount: 3,
RingRotation: 1.33,
StarCount: 5,
color0: 'rgba(255, 0, 0, 1.0)', color0: 'rgba(255, 0, 0, 1.0)',
color1: 'rgba(255, 0, 0, 1.0)', color1: 'rgba(255, 0, 0, 1.0)',
color2: 'rgba(255,255,255, 1.0)', color2: 'rgba(255,255,255, 1.0)',
@@ -267,7 +252,15 @@ export default class Effect {
color5: 'rgba(0,0,255, 1.0)' color5: 'rgba(0,0,255, 1.0)'
}, },
{ {
name: _('Rainbow'), // A vivid rainbow spectrum of colors name: _('Rainbow 🌈'), // A vivid rainbow spectrum of colors
ScaleStyle: 1.0,
SparkCount: 4,
SparkColor: 'rgba(255,255,255,1.0)',
SparkRotation: 0.3,
RayColor: 'rgba(255,255,255,0.0)',
RingCount: 3,
RingRotation: 2.0,
StarCount: 7,
color0: 'rgba(255, 69, 58, 1.0)', // Bold Red color0: 'rgba(255, 69, 58, 1.0)', // Bold Red
color1: 'rgba(255, 140, 0, 1.0)', // Bold Orange color1: 'rgba(255, 140, 0, 1.0)', // Bold Orange
color2: 'rgba(255, 223, 0, 1.0)', // Bold Yellow color2: 'rgba(255, 223, 0, 1.0)', // Bold Yellow
@@ -276,8 +269,16 @@ export default class Effect {
color5: 'rgba(148, 0, 211, 1.0)' // Bold Purple color5: 'rgba(148, 0, 211, 1.0)' // Bold Purple
}, },
{ {
name: _('Cattuccino Colors'), // A soft pastel palette inspired by a name: _('Cattuccino 😺'), // A soft pastel palette inspired by a
// cappuccino theme // cappuccino theme
ScaleStyle: 1.0,
SparkCount: 4,
SparkColor: 'rgba(255,255,255,1.0)',
SparkRotation: 0.3,
RayColor: 'rgba(255,255,255,0.0)',
RingCount: 3,
RingRotation: 2.0,
StarCount: 7,
color0: 'rgba(239, 146, 160, 1.0)', color0: 'rgba(239, 146, 160, 1.0)',
color1: 'rgba(246, 178, 138, 1.0)', color1: 'rgba(246, 178, 138, 1.0)',
color2: 'rgba(240, 217, 169, 1.0)', color2: 'rgba(240, 217, 169, 1.0)',
@@ -286,13 +287,38 @@ export default class Effect {
color5: 'rgba(205, 170, 247, 1.0)' color5: 'rgba(205, 170, 247, 1.0)'
}, },
{ {
name: _('Dracula Colors'), // A dark palette inspired by the Dracula theme name: _('Dracula 🦇'), // A dark palette inspired by the Dracula theme
ScaleStyle: 1.0,
SparkCount: 0,
SparkColor: 'rgba(255,255,255,1.0)',
SparkRotation: 0.3,
RayColor: 'rgba(255,255,255,0.0)',
RingCount: 3,
RingRotation: 2.0,
StarCount: 7,
color0: 'rgba(40, 42, 54, 1.0)', // Dark Grey color0: 'rgba(40, 42, 54, 1.0)', // Dark Grey
color1: 'rgba(68, 71, 90, 1.0)', // Medium Grey color1: 'rgba(68, 71, 90, 1.0)', // Medium Grey
color2: 'rgba(90, 94, 119, 1.0)', // Light Grey color2: 'rgba(90, 94, 119, 1.0)', // Light Grey
color3: 'rgba(90, 94, 119, 1.0)', // Light Grey color3: 'rgba(90, 94, 119, 1.0)', // Light Grey
color4: 'rgba(68, 71, 90, 1.0)', // Medium Grey color4: 'rgba(68, 71, 90, 1.0)', // Medium Grey
color5: 'rgba(40, 42, 54, 1.0)' // Dark Grey color5: 'rgba(40, 42, 54, 1.0)' // Dark Grey
},
{
name: _('Sparkle ✨'), // A dark palette inspired by the Dracula theme
ScaleStyle: 1.0,
SparkCount: 25,
SparkColor: 'rgba(255,255,255,1.0)',
SparkRotation: 0.3,
RayColor: 'rgba(255,255,255,0.0)',
RingCount: 0,
RingRotation: 1.33,
StarCount: 7,
color0: 'rgba(255,255,255,0.0)',
color1: 'rgba(255,255,255,0.0)',
color2: 'rgba(255,255,255,0.0)',
color3: 'rgba(255,255,255,0.0)',
color4: 'rgba(255,255,255,0.0)',
color5: 'rgba(255,255,255,0.0)',
} }
]; ];
@@ -316,6 +342,21 @@ export default class Effect {
// Connect the action to a function that loads the preset colors into the // Connect the action to a function that loads the preset colors into the
// dialog. // dialog.
action.connect('activate', () => { action.connect('activate', () => {
dialog.getProfileSettings().set_double('mushroom-scale-style',
preset.ScaleStyle);
dialog.getProfileSettings().set_int('mushroom-spark-count',
preset.SparkCount);
dialog.getProfileSettings().set_string('mushroom-spark-color',
preset.SparkColor);
dialog.getProfileSettings().set_double('mushroom-spark-rotation',
preset.SparkRotation);
dialog.getProfileSettings().set_string('mushroom-rays-color',
preset.RayColor);
dialog.getProfileSettings().set_int('mushroom-ring-count', preset.RingCount);
dialog.getProfileSettings().set_double('mushroom-ring-rotation',
preset.RingRotation);
dialog.getProfileSettings().set_int('mushroom-star-count', preset.StarCount);
dialog.getProfileSettings().set_string('mushroom-star-color-0', dialog.getProfileSettings().set_string('mushroom-star-color-0',
preset.color0); preset.color0);
dialog.getProfileSettings().set_string('mushroom-star-color-1', dialog.getProfileSettings().set_string('mushroom-star-color-1',
@@ -345,187 +386,3 @@ export default class Effect {
}); });
} }
} }
// large comment to fix the comment percentage check
/*
The provided code is a JavaScript implementation for creating and managing a graphical
effect inspired by the classic "Mushroom" feature in retro Mario games. It integrates with
the GNOME Shell and uses shaders for visual rendering. Here is an overview and explanation
of its key sections:
---
### 1. **Imports and Initialization**
```javascript
import Gio from 'gi://Gio';
import * as utils from '../utils.js';
// Import ShaderFactory in the GNOME Shell process.
const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');
// Import gettext for internationalization.
const _ = await utils.importGettext();
```
- **`Gio` Import:** Provides GNOME-specific APIs for handling I/O and application
settings.
- **`utils.js` Import:** Utility functions used across the codebase, like parsing and
importing modules.
- **ShaderFactory:** Dynamically imports the shader manager, ensuring it's only loaded
when necessary.
- **Gettext:** Enables internationalization, allowing translations of strings like effect
names or preset descriptions.
---
### 2. **Effect Metadata and Management**
#### Metadata
```javascript
static getMinShellVersion() {
return [3, 36];
}
static getNick() {
return 'mushroom';
}
static getLabel() {
return _('Mushroom');
}
```
- **Shell Version Support:** Specifies compatibility with GNOME Shell versions 3.36 and
above.
- **Nick:** A unique identifier for the effect, linking its settings, shader files, and UI
components.
- **Label:** Display name shown in GNOME's preferences dialog.
#### Constructor
```javascript
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
shader._uGradient = [
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._u8BitStyle = shader.get_uniform_location('u8BitStyle');
shader._uEnable4PStars = shader.get_uniform_location('uEnable4PStars');
shader._uEnableRays = shader.get_uniform_location('uEnableRays');
shader._uEnable5pStars = shader.get_uniform_location('uEnable5pStars');
shader.connect('begin-animation', (shader, settings) => {
shader.set_uniform_float(shader._u8BitStyle, 1,
[settings.get_boolean('mushroom-8bit-enable')]);
// More uniforms are updated...
});
});
}
```
- **Shader Factory:** Generates shader instances for rendering the effect.
- **Uniform Locations:** Identifies GLSL shader variables for dynamic updates, such as
color gradients and toggles for features like rays and star effects.
- **Animation Hook:** Updates uniforms at the beginning of each animation to reflect user
preferences.
---
### 3. **Preferences and UI Binding**
#### Binding Preferences
```javascript
static bindPreferences(dialog) {
dialog.bindAdjustment('mushroom-animation-time');
dialog.bindSwitch('mushroom-8bit-enable');
// Other bindings for colors and toggles...
}
```
- **Binding Settings to UI:** Links user preferences (e.g., animation time, star colors)
to corresponding UI elements in the GNOME settings dialog.
- **Dynamic Updates:** Automatically updates the effect when preferences change.
#### Resetting Star Colors
```javascript
dialog.getBuilder().get_object('reset-star-colors').connect('clicked', () => {
dialog.getProfileSettings().reset('mushroom-star-color-0');
dialog.getProfileSettings().reset('mushroom-star-color-1');
// Reset other colors...
});
```
- **Reset Functionality:** Provides a mechanism to restore star colors to their default
values.
---
### 4. **Color Presets**
#### Preset Initialization
```javascript
static _createMushroomPresets(dialog) {
const presets = [
{
name: _('Default Colors'),
color0: 'rgba(233,249,0,1.0)',
// Other colors...
},
{
name: _('Rainbow'),
color0: 'rgba(255, 69, 58, 1.0)', // Bold Red
// Other colors...
},
// More presets...
];
}
```
- **Preset Definitions:** Includes a list of predefined color schemes like "Rainbow" and
"Cattuccino."
- **Dynamic Menu Creation:** Populates a menu for selecting these presets dynamically
during runtime.
#### Applying Presets
```javascript
presets.forEach((preset, i) => {
const actionName = 'mushroom' + i;
action.connect('activate', () => {
dialog.getProfileSettings().set_string('mushroom-star-color-0', preset.color0);
// Set other colors...
});
});
```
- **Preset Selection Logic:** Updates star colors based on the selected preset from the
dropdown menu.
---
### 5. **Shader Integration**
#### Shader Configuration
```javascript
shader.set_uniform_float(shader._uEnableRays, 1,
[settings.get_boolean('mushroom-rays-enable')]); shader.set_uniform_float(shader._uRings,
1, [settings.get_int('mushroom-5pstarring-count')]);
shader.set_uniform_float(shader._uRingRotation, 1,
[settings.get_double('mushroom-5pstarring-rotation')]);
```
- **Dynamic Updates:** Configures shader variables for rays, star rings, and other visual
elements based on user preferences.
- **Fine-Grained Control:** Allows customization of features like the number of stars,
rotations, and colors.
---
### 6. **Effect Rendering**
The rendering pipeline uses GLSL shaders for creating dynamic and visually appealing
effects, such as:
- **8-Bit Style:** Applies a retro aesthetic inspired by old Mario games.
- **Star Gradients:** Smooth color transitions for the stars.
- **Rays and Rings:** Adds depth and complexity to the visual design.
---
### Conclusion
This code is a well-structured implementation of a GNOME Shell effect. It blends modern
shader-based graphics with retro gaming aesthetics, offering customization through
user-friendly settings. The modular approach makes it easy to extend and maintain.
*/