[gegl] lua-ui: add scaffold ui for many ops that take a radius parameter



commit 1804a24d65f95218bdf8a8834e92d2694d2ee222
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Feb 23 22:57:21 2019 +0100

    lua-ui: add scaffold ui for many ops that take a radius parameter

 bin/lua/gegl_box-blur.lua      | 16 ++++++++++++++++
 bin/lua/gegl_c2g.lua           | 16 ++++++++++++++++
 bin/lua/gegl_edge-neon.lua     | 18 ++++++++++++++++++
 bin/lua/gegl_gaussian-blur.lua | 19 +++++++++++++++++++
 bin/lua/gegl_median-blur.lua   | 16 ++++++++++++++++
 bin/lua/gegl_snn-mean.lua      | 18 ++++++++++++++++++
 bin/lua/gegl_stress.lua        | 16 ++++++++++++++++
 bin/lua/gegl_unsharp-mask.lua  | 18 ++++++++++++++++++
 bin/lua/init.lua               |  8 ++++----
 9 files changed, 141 insertions(+), 4 deletions(-)
---
diff --git a/bin/lua/gegl_box-blur.lua b/bin/lua/gegl_box-blur.lua
new file mode 100644
index 000000000..83bce7644
--- /dev/null
+++ b/bin/lua/gegl_box-blur.lua
@@ -0,0 +1,16 @@
+local radius = active:get_property("radius").value
+
+touch_point(centerx - dim  - radius, centery)
+mrg:listen(Mrg.DRAG, function(ev)
+  if ev.type == Mrg.DRAG_MOTION then
+    local x = active:get_property("radius").value
+    x = x - ev.delta_x
+    if x < 0 then x = 0 end
+    active:set_property("radius", GObject.Value(GObject.Type.DOUBLE, x))
+    ev:stop_propagate();
+  end
+end)
+cr:new_path()
+
+cr:arc(centerx, centery, radius, 0, 3.14152 * 2)
+contrasty_stroke()
diff --git a/bin/lua/gegl_c2g.lua b/bin/lua/gegl_c2g.lua
new file mode 100644
index 000000000..83bce7644
--- /dev/null
+++ b/bin/lua/gegl_c2g.lua
@@ -0,0 +1,16 @@
+local radius = active:get_property("radius").value
+
+touch_point(centerx - dim  - radius, centery)
+mrg:listen(Mrg.DRAG, function(ev)
+  if ev.type == Mrg.DRAG_MOTION then
+    local x = active:get_property("radius").value
+    x = x - ev.delta_x
+    if x < 0 then x = 0 end
+    active:set_property("radius", GObject.Value(GObject.Type.DOUBLE, x))
+    ev:stop_propagate();
+  end
+end)
+cr:new_path()
+
+cr:arc(centerx, centery, radius, 0, 3.14152 * 2)
+contrasty_stroke()
diff --git a/bin/lua/gegl_edge-neon.lua b/bin/lua/gegl_edge-neon.lua
new file mode 100644
index 000000000..0a8aa530c
--- /dev/null
+++ b/bin/lua/gegl_edge-neon.lua
@@ -0,0 +1,18 @@
+local radius = active:get_property("radius").value
+
+touch_point(centerx - dim  - radius, centery)
+mrg:listen(Mrg.DRAG, function(ev)
+  if ev.type == Mrg.DRAG_MOTION then
+    local x = active:get_property("radius").value
+    x = x - ev.delta_x
+    if x < 0 then x = 0 end
+    active:set_property("radius", GObject.Value(GObject.Type.DOUBLE, x))
+    ev:stop_propagate();
+  end
+end)
+cr:new_path()
+
+cr:arc(centerx, centery, radius, 0, 3.14152 * 2)
+contrasty_stroke()
+cr:arc(centerx, centery, radius * 2, 0, 3.14152 * 2)
+contrasty_stroke()
diff --git a/bin/lua/gegl_gaussian-blur.lua b/bin/lua/gegl_gaussian-blur.lua
new file mode 100644
index 000000000..dc6e2c741
--- /dev/null
+++ b/bin/lua/gegl_gaussian-blur.lua
@@ -0,0 +1,19 @@
+local std_dev = active:get_property("std-dev-x").value
+
+touch_point(centerx - dim  - std_dev, centery)
+mrg:listen(Mrg.DRAG, function(ev)
+  if ev.type == Mrg.DRAG_MOTION then
+    local x = active:get_property("std-dev-x").value
+    x = x - ev.delta_x
+    if x < 0 then x = 0 end
+    active:set_property("std-dev-y", GObject.Value(GObject.Type.DOUBLE, x))
+    active:set_property("std-dev-x", GObject.Value(GObject.Type.DOUBLE, x))
+    ev:stop_propagate();
+  end
+end)
+cr:new_path()
+
+cr:arc(centerx, centery, std_dev, 0, 3.14152 * 2)
+contrasty_stroke()
+cr:arc(centerx, centery, std_dev * 2, 0, 3.14152 * 2)
+contrasty_stroke()
diff --git a/bin/lua/gegl_median-blur.lua b/bin/lua/gegl_median-blur.lua
new file mode 100644
index 000000000..83bce7644
--- /dev/null
+++ b/bin/lua/gegl_median-blur.lua
@@ -0,0 +1,16 @@
+local radius = active:get_property("radius").value
+
+touch_point(centerx - dim  - radius, centery)
+mrg:listen(Mrg.DRAG, function(ev)
+  if ev.type == Mrg.DRAG_MOTION then
+    local x = active:get_property("radius").value
+    x = x - ev.delta_x
+    if x < 0 then x = 0 end
+    active:set_property("radius", GObject.Value(GObject.Type.DOUBLE, x))
+    ev:stop_propagate();
+  end
+end)
+cr:new_path()
+
+cr:arc(centerx, centery, radius, 0, 3.14152 * 2)
+contrasty_stroke()
diff --git a/bin/lua/gegl_snn-mean.lua b/bin/lua/gegl_snn-mean.lua
new file mode 100644
index 000000000..0a8aa530c
--- /dev/null
+++ b/bin/lua/gegl_snn-mean.lua
@@ -0,0 +1,18 @@
+local radius = active:get_property("radius").value
+
+touch_point(centerx - dim  - radius, centery)
+mrg:listen(Mrg.DRAG, function(ev)
+  if ev.type == Mrg.DRAG_MOTION then
+    local x = active:get_property("radius").value
+    x = x - ev.delta_x
+    if x < 0 then x = 0 end
+    active:set_property("radius", GObject.Value(GObject.Type.DOUBLE, x))
+    ev:stop_propagate();
+  end
+end)
+cr:new_path()
+
+cr:arc(centerx, centery, radius, 0, 3.14152 * 2)
+contrasty_stroke()
+cr:arc(centerx, centery, radius * 2, 0, 3.14152 * 2)
+contrasty_stroke()
diff --git a/bin/lua/gegl_stress.lua b/bin/lua/gegl_stress.lua
new file mode 100644
index 000000000..83bce7644
--- /dev/null
+++ b/bin/lua/gegl_stress.lua
@@ -0,0 +1,16 @@
+local radius = active:get_property("radius").value
+
+touch_point(centerx - dim  - radius, centery)
+mrg:listen(Mrg.DRAG, function(ev)
+  if ev.type == Mrg.DRAG_MOTION then
+    local x = active:get_property("radius").value
+    x = x - ev.delta_x
+    if x < 0 then x = 0 end
+    active:set_property("radius", GObject.Value(GObject.Type.DOUBLE, x))
+    ev:stop_propagate();
+  end
+end)
+cr:new_path()
+
+cr:arc(centerx, centery, radius, 0, 3.14152 * 2)
+contrasty_stroke()
diff --git a/bin/lua/gegl_unsharp-mask.lua b/bin/lua/gegl_unsharp-mask.lua
new file mode 100644
index 000000000..25bd7e3f5
--- /dev/null
+++ b/bin/lua/gegl_unsharp-mask.lua
@@ -0,0 +1,18 @@
+local std_dev = active:get_property("std-dev").value
+
+touch_point(centerx - dim  - std_dev, centery)
+mrg:listen(Mrg.DRAG, function(ev)
+  if ev.type == Mrg.DRAG_MOTION then
+    local x = active:get_property("std-dev").value
+    x = x - ev.delta_x
+    if x < 0 then x = 0 end
+    active:set_property("std-dev", GObject.Value(GObject.Type.DOUBLE, x))
+    ev:stop_propagate();
+  end
+end)
+cr:new_path()
+
+cr:arc(centerx, centery, std_dev, 0, 3.14152 * 2)
+contrasty_stroke()
+cr:arc(centerx, centery, std_dev * 2, 0, 3.14152 * 2)
+contrasty_stroke()
diff --git a/bin/lua/init.lua b/bin/lua/init.lua
index 90c693ed2..f02e51690 100644
--- a/bin/lua/init.lua
+++ b/bin/lua/init.lua
@@ -127,10 +127,10 @@ function touch_point(x, y)
 end
 
 function contrasty_stroke()
-  local x0 = 6.0
-  local y0 = 6.0;
-  local x1 = 4.0
-  local y1 = 4.0;
+  local x0 = 3.0
+  local y0 = 3.0;
+  local x1 = 2.0
+  local y1 = 2.0;
 
   x0, y0 = cr:device_to_user_distance (x0, y0)
   x1, y1 = cr:device_to_user_distance (x1, y1)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]