[opengtl-commits] [635] add roundify and sectorize effects

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 635
Author:   cyrille
Date:     2009-03-16 16:07:20 +0100 (Mon, 16 Mar 2009)

Log Message:
-----------
add roundify and sectorize effects

Added Paths:
-----------
    trunk/shiva-collections/filters/Roundify.shiva
    trunk/shiva-collections/filters/Sectorize.shiva


Added: trunk/shiva-collections/filters/Roundify.shiva
===================================================================
--- trunk/shiva-collections/filters/Roundify.shiva	                        (rev 0)
+++ trunk/shiva-collections/filters/Roundify.shiva	2009-03-16 15:07:20 UTC (rev 635)
@@ -0,0 +1,49 @@
+<
+  parameters: <
+    xcenter: <
+      label: "Center x";
+      type: float;
+    >;
+    ycenter: <
+      label: "Center y";
+      type: float;
+    >;
+    rho: <
+      label: "Rho";
+      type: double;
+      minValue: 0;
+      defaultValue: 10;
+      maxValue: 64;
+    >;
+    theta: <
+      label: "Theta";
+      type: float;
+      minValue: 0;
+      defaultValue: 10;
+      maxValue: 64;
+    >;
+  >;
+>;  
+kernel Roundify
+{  
+  const float width = 500.0;
+  const float height = 500.0;
+  const float2 center = { width * xcenter, height * ycenter };
+  void evaluatePixel(image img, out pixel result)
+  {
+    float2 vec = result.coord - center;
+    float vec_length = length( vec );
+    float angle = atan2(vec.y, vec.x);
+
+    float mvt = vec_length * rho + fabs(angle) * theta;
+    float2 displacement;
+    displacement[0] = mvt;
+    displacement[1] = mvt;
+
+    result = img.sampleNearest( result.coord + displacement );
+  }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
+}

Added: trunk/shiva-collections/filters/Sectorize.shiva
===================================================================
--- trunk/shiva-collections/filters/Sectorize.shiva	                        (rev 0)
+++ trunk/shiva-collections/filters/Sectorize.shiva	2009-03-16 15:07:20 UTC (rev 635)
@@ -0,0 +1,50 @@
+<
+  parameters: <
+    xcenter: <
+      label: "Center x";
+      type: float;
+    >;
+    ycenter: <
+      label: "Center y";
+      type: float;
+    >;
+    rho: <
+      label: "Rho";
+      type: int;
+      minValue: 0;
+      defaultValue: 10;
+      maxValue: 64;
+    >;
+    theta: <
+      label: "Theta";
+      type: int;
+      minValue: 0;
+      defaultValue: 10;
+      maxValue: 64;
+    >;
+  >;
+>;  
+kernel Sectorize
+{  
+  const float width = 500.0;
+  const float height = 500.0;
+  const float2 center = { width * xcenter, height * ycenter };
+  void evaluatePixel(image img, out pixel result)
+  {
+    float2 vec = result.coord - center;
+    int vec_length = length( vec );
+    int angle = atan2(vec.y, vec.x) * 512 / 3.14;
+    if(angle < 0 ) angle = -angle;
+
+    float mvt = vec_length % rho + angle % theta;
+    float2 displacement;
+    displacement[0] = mvt;
+    displacement[1] = mvt;
+
+    result = img.sampleNearest( result.coord + displacement );
+  }
+  region changed(region changed_input_region, int input_index, region input_DOD[])
+  {
+    return changed_input_region;
+  }
+}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/