a little polishing
This commit is contained in:
@@ -136,7 +136,6 @@ void main() {
|
||||
progress, 0.0, ((uSize.x + (uPadding*2.0)) / uSize.x)
|
||||
,0.0, 1.0
|
||||
);
|
||||
progress = clamp(progress,0.0,1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +195,7 @@ void main() {
|
||||
vec3 color = cos(progress*uColorSpeed+uv.xyx+vec3(0,2,4)).xyz;
|
||||
//coloroffset
|
||||
float colorOffset = (uRandomColorOffset) ? hash12(uSeed) : uColorOffset ;
|
||||
color = offsetHue(color, colorOffset);
|
||||
color = offsetHue(color, colorOffset + 0.10);
|
||||
//clamp and saturate
|
||||
color = clamp(color * uColorSaturation,vec3(0.0),vec3(1.0));
|
||||
|
||||
|
||||
@@ -385,6 +385,15 @@ vec2 rotate(vec2 a, float angle) {
|
||||
);
|
||||
}
|
||||
|
||||
//rotates a given 2d vector, around a given center (angle is in radians)
|
||||
vec2 rotate(vec2 a, float angle, vec2 center)
|
||||
{
|
||||
return vec2(
|
||||
cos(angle) * (a.x - center.x) + sin(angle) * (a.y - center.y) + center.x,
|
||||
cos(angle) * (a.y - center.y) - sin(angle) * (a.x - center.x) + center.y
|
||||
);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------- noise
|
||||
|
||||
// These noise algorithms are based on implementations by various authors from
|
||||
@@ -613,26 +622,42 @@ This ensures a linear transformation from the old range to the new range.
|
||||
// Maps a float value from one range [oldMin, oldMax] to another range [newMin, newMax].
|
||||
// This is useful for normalizing or scaling scalar values to fit within a desired range.
|
||||
float remap(float value, float oldMin, float oldMax, float newMin, float newMax) {
|
||||
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
|
||||
return clamp(
|
||||
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin),
|
||||
newMin,
|
||||
newMax
|
||||
);
|
||||
}
|
||||
|
||||
// Remap for vec2
|
||||
// Maps a 2D vector (vec2) from one range [oldMin, oldMax] to another range [newMin, newMax].
|
||||
// Each component of the vec2 is individually scaled and transformed.
|
||||
vec2 remap(vec2 value, vec2 oldMin, vec2 oldMax, vec2 newMin, vec2 newMax) {
|
||||
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
|
||||
return clamp(
|
||||
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin),
|
||||
newMin,
|
||||
newMax
|
||||
);
|
||||
}
|
||||
|
||||
// Remap for vec3
|
||||
// Maps a 3D vector (vec3) from one range [oldMin, oldMax] to another range [newMin, newMax].
|
||||
// Each component of the vec3 is individually scaled and transformed.
|
||||
vec3 remap(vec3 value, vec3 oldMin, vec3 oldMax, vec3 newMin, vec3 newMax) {
|
||||
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
|
||||
return clamp(
|
||||
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin),
|
||||
newMin,
|
||||
newMax
|
||||
);
|
||||
}
|
||||
|
||||
// Remap for vec4
|
||||
// Maps a 4D vector (vec4) from one range [oldMin, oldMax] to another range [newMin, newMax].
|
||||
// Each component of the vec4 is individually scaled and transformed.
|
||||
vec4 remap(vec4 value, vec4 oldMin, vec4 oldMax, vec4 newMin, vec4 newMax) {
|
||||
return newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin);
|
||||
return clamp(
|
||||
newMin + (value - oldMin) * (newMax - newMin) / (oldMax - oldMin),
|
||||
newMin,
|
||||
newMax
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,16 +121,6 @@ vec2 scaleUV(vec2 uv, vec2 scale)
|
||||
return uv;
|
||||
}
|
||||
|
||||
//rotates the UV
|
||||
//needs to use this once since it rotates around the middle (i.e. 0.5)
|
||||
vec2 rotateUV(vec2 uv, float rotation)
|
||||
{
|
||||
float mid = 0.5;
|
||||
return vec2(
|
||||
cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,
|
||||
cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid
|
||||
);
|
||||
}
|
||||
|
||||
//this returns the Spark
|
||||
float getSpark(vec2 uv, vec2 center, float brightness, float size, float rotation)
|
||||
@@ -142,7 +132,7 @@ float getSpark(vec2 uv, vec2 center, float brightness, float size, float rotatio
|
||||
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
|
||||
uv = rotate(uv, rotation, vec2(0.5)); //rotate the UV
|
||||
|
||||
//this is basically the brightness
|
||||
float p = mix(-1.0,1000.0,easeInExpo(bn));
|
||||
@@ -349,10 +339,11 @@ vec4 getRays(float progress)
|
||||
0.0,1.0,
|
||||
-5.0,1.0
|
||||
);
|
||||
ray = clamp(ray,0.0,1.0);
|
||||
|
||||
float alpha = clamp(uRaysColor.a * 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,alpha);
|
||||
|
||||
}
|
||||
|
||||
@@ -452,6 +443,7 @@ void main() {
|
||||
oColor = alphaOver(oColor, getRays(progress));
|
||||
}
|
||||
|
||||
|
||||
// If five-point stars are enabled, overlay them using stored alpha
|
||||
if (uRingCount > 0.0 && uStarCount > 0.0)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</child>
|
||||
|
||||
|
||||
<child>
|
||||
<!-- <child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title" translatable="yes">Random Color</property>
|
||||
<property name="activatable-widget">aura-glow-random-color</property>
|
||||
@@ -62,12 +62,19 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</child> -->
|
||||
|
||||
<child>
|
||||
<object class="AdwActionRow" id="aura-glow-action-row">
|
||||
<property name="title" translatable="yes">Color Offset</property>
|
||||
<property name="subtitle" translatable="yes">Red</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="aura-glow-random-color">
|
||||
<property name="label" translatable="yes">random</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="active">true</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale" id="aura-glow-color-offset-scale">
|
||||
<property name="valign">center</property>
|
||||
|
||||
+19
-1
@@ -151,6 +151,24 @@ export default class Effect {
|
||||
.set_sensitive(!state);
|
||||
}
|
||||
|
||||
const randColor = dialog.getBuilder().get_object('aura-glow-random-color');
|
||||
if (randColor) {
|
||||
// Connect to the "toggled" signal to update preferences dynamically
|
||||
randColor.connect('toggled', (widget) => {
|
||||
const state = widget.get_active(); // Retrieve the state directly
|
||||
EnableDisablePref(dialog, state); // Update sensitivity when the state changes
|
||||
});
|
||||
|
||||
// Manually call the update function on startup, using the initial state of the switch
|
||||
const initialState = randColor.get_active(); // Get the initial state of the check button
|
||||
EnableDisablePref(dialog, initialState);
|
||||
} else {
|
||||
// Log an error if the switch widget is not found in the UI
|
||||
log('Error: \'aura-glow-random-color\' switch widget not found.');
|
||||
}
|
||||
|
||||
//if we use a switch instead of a checkbox
|
||||
/*
|
||||
const switchWidget = dialog.getBuilder().get_object('aura-glow-random-color');
|
||||
if (switchWidget) {
|
||||
// Connect to the "state-set" signal to update preferences dynamically based on
|
||||
@@ -168,7 +186,7 @@ export default class Effect {
|
||||
// Log an error if the switch widget is not found in the UI.
|
||||
log('Error: \'aura-glow-random-color\' switch widget not found.');
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// Retrieve the necessary objects
|
||||
const colorOffset = dialog.getBuilder().get_object('aura-glow-color-offset-scale');
|
||||
|
||||
Reference in New Issue
Block a user