[opengtl-commits] [632] add a zigzag effect |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 632
Author: cyrille
Date: 2009-03-16 15:11:15 +0100 (Mon, 16 Mar 2009)
Log Message:
-----------
add a zigzag effect
Added Paths:
-----------
trunk/shiva-collections/filters/ZigZag.shiva
Added: trunk/shiva-collections/filters/ZigZag.shiva
===================================================================
--- trunk/shiva-collections/filters/ZigZag.shiva (rev 0)
+++ trunk/shiva-collections/filters/ZigZag.shiva 2009-03-16 14:11:15 UTC (rev 632)
@@ -0,0 +1,45 @@
+<
+ parameters: <
+ cellWidth: <
+ label: "Cell width";
+ type: int;
+ minValue: 1;
+ maxValue: 50;
+ defaultValue: 10;
+ >;
+ cellHeight: <
+ label: "Cell height";
+ type: int;
+ minValue: 1;
+ maxValue: 50;
+ defaultValue: 10;
+ >;
+ >;
+>;
+kernel ZigZag
+{
+ const float width = 500.0;
+ const float height = 500.0;
+ const float2 center = { width * 0.5, height * 0.5 };
+ void evaluatePixel(image img, out pixel result)
+ {
+ float2 vec = result.coord - center;
+ float dx = vec.x;
+ if(dx < 0 ) dx = -dx;
+ float dy = vec.y;
+ if(dy < 0 ) dy = -dy;
+
+ float2 displacement;
+ int iy = dy * result.coord.y;
+ int ix = dx * result.coord.x;
+ displacement[0] = iy % cellWidth;
+ displacement[1] = ix % cellHeight;
+// R=src(x+((abs(y-Y/2))*y%val(0,0,X/2)),y+((abs(x-X/2))*x%val(1,0,Y/2)),z)
+
+ result = img.sampleNearest( result.coord + displacement );
+ }
+ region changed(region changed_input_region, int input_index, region input_DOD[])
+ {
+ return changed_input_region;
+ }
+}