🎉 Start incinerate effect at pointer location
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
// This part is automatically included in the effect's source during the build process.
|
// This part is automatically included in the effect's source during the build process.
|
||||||
// The code below is called whenever a window is closed or opened.
|
// The code below is called whenever a window is closed or opened.
|
||||||
|
|
||||||
effect.setUniform(this.shader, 'uSeed', [Math.random(), Math.random()]);
|
let seed = [Math.random(), Math.random()];
|
||||||
|
let startPos = seed[0] > seed[1] ? [seed[0], Math.floor(seed[1] + 0.5)] :
|
||||||
|
[Math.floor(seed[0] + 0.5), seed[1]];
|
||||||
|
|
||||||
|
effect.setUniform(this.shader, 'uSeed', seed);
|
||||||
|
effect.setUniform(this.shader, 'uStartPos', startPos);
|
||||||
@@ -17,6 +17,7 @@ uniform vec2 uSeed;
|
|||||||
uniform vec3 uColor;
|
uniform vec3 uColor;
|
||||||
uniform float uScale;
|
uniform float uScale;
|
||||||
uniform float uTurbulence;
|
uniform float uTurbulence;
|
||||||
|
uniform vec2 uStartPos;
|
||||||
|
|
||||||
// This maps a given value in [0..1] to a color from the rgba color ramp
|
// This maps a given value in [0..1] to a color from the rgba color ramp
|
||||||
// [transparent black ... semi-transparent uColor ... opaque white].
|
// [transparent black ... semi-transparent uColor ... opaque white].
|
||||||
@@ -75,11 +76,8 @@ void main() {
|
|||||||
|
|
||||||
// Now we compute a 2D gradient in [0..1] which covers the entire window. The dark
|
// Now we compute a 2D gradient in [0..1] which covers the entire window. The dark
|
||||||
// regions will be burned first, the bright regions in the end. We mix a radial gradient
|
// regions will be burned first, the bright regions in the end. We mix a radial gradient
|
||||||
// with some noise. The center of the radial gradient is positioned somewhere at the
|
// with some noise. The center of the radial gradient is positioned at uStartPos.
|
||||||
// window boundary.
|
float circle = length(iTexCoord - uStartPos);
|
||||||
vec2 center = uSeed.x > uSeed.y ? vec2(uSeed.x, floor(uSeed.y + 0.5))
|
|
||||||
: vec2(floor(uSeed.x + 0.5), uSeed.y);
|
|
||||||
float circle = length(iTexCoord - center);
|
|
||||||
|
|
||||||
vec2 uv = iTexCoord / uScale * uSize / 1.5;
|
vec2 uv = iTexCoord / uScale * uSize / 1.5;
|
||||||
float smokeNoise =
|
float smokeNoise =
|
||||||
|
|||||||
@@ -181,6 +181,68 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBoxRow">
|
||||||
|
<property name="margin-start">10</property>
|
||||||
|
<property name="margin-end">10</property>
|
||||||
|
<property name="margin-top">10</property>
|
||||||
|
<property name="margin-bottom">10</property>
|
||||||
|
<property name="activatable">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">3</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">Start at Pointer</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">If disabled, a random location will be chosen.</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label" />
|
||||||
|
<class name="caption" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSwitch" id="incinerate-use-pointer">
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="reset-incinerate-use-pointer">
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="icon-name">edit-clear-symbolic</property>
|
||||||
|
<property name="icon-size">1</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||||
|
<style>
|
||||||
|
<class name="flat" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBoxRow">
|
<object class="GtkListBoxRow">
|
||||||
<property name="margin-start">10</property>
|
<property name="margin-start">10</property>
|
||||||
|
|||||||
@@ -152,6 +152,59 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBoxRow">
|
||||||
|
<property name="activatable">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">3</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">Start at Pointer</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label" translatable="yes">If disabled, a random location will be chosen.</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
<style>
|
||||||
|
<class name="dim-label" />
|
||||||
|
<class name="caption" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSwitch" id="incinerate-use-pointer">
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="reset-incinerate-use-pointer">
|
||||||
|
<property name="icon-name">edit-clear-symbolic</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Reset to Default Value</property>
|
||||||
|
<style>
|
||||||
|
<class name="flat" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBoxRow">
|
<object class="GtkListBoxRow">
|
||||||
<property name="activatable">0</property>
|
<property name="activatable">0</property>
|
||||||
|
|||||||
@@ -371,6 +371,12 @@
|
|||||||
<description>The color of the effect.</description>
|
<description>The color of the effect.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
<key name="incinerate-use-pointer" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Incinerate Use Pointer</summary>
|
||||||
|
<description>Use the pointer location for the incinerate effect.</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||||
<!-- Energize A Options -->
|
<!-- Energize A Options -->
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||||
|
|||||||
+50
-6
@@ -47,22 +47,65 @@ var Incinerate = class {
|
|||||||
shader._uColor = shader.get_uniform_location('uColor');
|
shader._uColor = shader.get_uniform_location('uColor');
|
||||||
shader._uScale = shader.get_uniform_location('uScale');
|
shader._uScale = shader.get_uniform_location('uScale');
|
||||||
shader._uTurbulence = shader.get_uniform_location('uTurbulence');
|
shader._uTurbulence = shader.get_uniform_location('uTurbulence');
|
||||||
|
shader._uStartPos = shader.get_uniform_location('uStartPos');
|
||||||
|
|
||||||
// Write all uniform values at the start of each animation.
|
// Write all uniform values at the start of each animation.
|
||||||
shader.connect('begin-animation', (shader, settings) => {
|
shader.connect('begin-animation', (shader, settings, forOpening, actor) => {
|
||||||
const c = Clutter.Color.from_string(settings.get_string('incinerate-color'))[1];
|
|
||||||
|
|
||||||
// If we are currently performing integration test, the animation uses a fixed
|
// If we are currently performing integration test, the animation uses a fixed
|
||||||
// seed.
|
// seed.
|
||||||
const testMode = settings.get_boolean('test-mode');
|
const testMode = settings.get_boolean('test-mode');
|
||||||
|
let seed = [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()];
|
||||||
|
|
||||||
|
// If this option is set, we use the mouse pointer position. Because the actor
|
||||||
|
// position may change after the begin-animation signal is called, we set the
|
||||||
|
// uStartPos uniform during the update callback.
|
||||||
|
if (settings.get_boolean('incinerate-use-pointer')) {
|
||||||
|
this._startPointerPos = global.get_pointer();
|
||||||
|
this._actor = actor;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Else, a random position along the window boundary is used as start position
|
||||||
|
// for the incinerate effect.
|
||||||
|
let startPos = seed[0] > seed[1] ? [seed[0], Math.floor(seed[1] + 0.5)] :
|
||||||
|
[Math.floor(seed[0] + 0.5), seed[1]];
|
||||||
|
|
||||||
|
shader.set_uniform_float(shader._uStartPos, 2, startPos);
|
||||||
|
|
||||||
|
this._startPointerPos = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const c = Clutter.Color.from_string(settings.get_string('incinerate-color'))[1];
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
shader.set_uniform_float(shader._uSeed, 2, [testMode ? 0 : Math.random(), testMode ? 0 : Math.random()]);
|
shader.set_uniform_float(shader._uSeed, 2, seed);
|
||||||
shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
shader.set_uniform_float(shader._uColor, 3, [c.red / 255, c.green / 255, c.blue / 255]);
|
||||||
shader.set_uniform_float(shader._uScale, 1, [settings.get_double('incinerate-scale')]);
|
shader.set_uniform_float(shader._uScale, 1, [settings.get_double('incinerate-scale')]);
|
||||||
shader.set_uniform_float(shader._uTurbulence, 1, [settings.get_double('incinerate-turbulence')]);
|
shader.set_uniform_float(shader._uTurbulence, 1, [settings.get_double('incinerate-turbulence')]);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If the mouse pointer position is used as start position, we set the uStartPos
|
||||||
|
// uniform during the update callback as the actor position may not be set up
|
||||||
|
// properly before the begin animation callback.
|
||||||
|
shader.connect('update-animation', (shader) => {
|
||||||
|
if (this._startPointerPos) {
|
||||||
|
const [x, y] = this._startPointerPos;
|
||||||
|
const [ok, localX, localY] = this._actor.transform_stage_point(x, y);
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
let startPos = [
|
||||||
|
Math.max(0.0, Math.min(1.0, localX / this._actor.width)),
|
||||||
|
Math.max(0.0, Math.min(1.0, localY / this._actor.height))
|
||||||
|
];
|
||||||
|
shader.set_uniform_float(shader._uStartPos, 2, startPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Make sure to drop the reference to the actor.
|
||||||
|
shader.connect('end-animation', (shader) => {
|
||||||
|
shader._actor = null;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +143,7 @@ var Incinerate = class {
|
|||||||
dialog.bindAdjustment('incinerate-animation-time');
|
dialog.bindAdjustment('incinerate-animation-time');
|
||||||
dialog.bindAdjustment('incinerate-scale');
|
dialog.bindAdjustment('incinerate-scale');
|
||||||
dialog.bindAdjustment('incinerate-turbulence');
|
dialog.bindAdjustment('incinerate-turbulence');
|
||||||
|
dialog.bindSwitch('incinerate-use-pointer');
|
||||||
dialog.bindColorButton('incinerate-color');
|
dialog.bindColorButton('incinerate-color');
|
||||||
|
|
||||||
// Finally, return the new settings page.
|
// Finally, return the new settings page.
|
||||||
|
|||||||
Reference in New Issue
Block a user