rotationlayer.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //----------------------------------------------------------------------------------------
  2. //
  3. // rotationlayer.m
  4. //
  5. //----------------------------------------------------------------------------------------
  6. // Use like this :
  7. // #define ROTATION_LAYER_VAR MyVar
  8. // #include "rotationlayer.m"
  9. //
  10. // _MyVarInit(Group parentgroup, String layername); // init rotationlayer
  11. // _MyVarRotateDegree(double r); // in degrees
  12. // _MyVarRotate(double r); // in radians
  13. // double _MyVarGetRotationDegree(); // in degrees
  14. // double _MyVarGetRotation(); // in radians
  15. //
  16. #ifndef PI
  17. #define PI 3.1415926536
  18. #endif
  19. Global Double _##ROTATION_LAYER_VAR##R;
  20. Global Layer _##ROTATION_LAYER_VAR##Layer;
  21. Function _##ROTATION_LAYER_VAR##Init(Group parentgroup, String layername);
  22. Function _##ROTATION_LAYER_VAR##RotateDegree(double r);
  23. Function _##ROTATION_LAYER_VAR##Rotate(double r);
  24. Function double _##ROTATION_LAYER_VAR##GetRotationDegree();
  25. Function double _##ROTATION_LAYER_VAR##GetRotation();
  26. _##ROTATION_LAYER_VAR##RotateDegree(double r) {
  27. _##ROTATION_LAYER_VAR##Rotate(r * PI / 180.0);
  28. }
  29. _##ROTATION_LAYER_VAR##Rotate(double r) {
  30. _##ROTATION_LAYER_VAR##R = r;
  31. _##ROTATION_LAYER_VAR##Layer.fx_update();
  32. }
  33. double _##ROTATION_LAYER_VAR##GetRotationDegree() {
  34. return _##ROTATION_LAYER_VAR##R * 180 / PI;
  35. }
  36. double _##ROTATION_LAYER_VAR##GetRotation() {
  37. return _##ROTATION_LAYER_VAR##R;
  38. }
  39. _##ROTATION_LAYER_VAR##Init(Group parentgroup, String layername) {
  40. _##ROTATION_LAYER_VAR##Layer = parentgroup.getObject(layername);
  41. _##ROTATION_LAYER_VAR##Layer.fx_setGridSize(1,1);
  42. _##ROTATION_LAYER_VAR##Layer.fx_setBgFx(0);
  43. _##ROTATION_LAYER_VAR##Layer.fx_setWrap(1);
  44. _##ROTATION_LAYER_VAR##Layer.fx_setBilinear(1);
  45. _##ROTATION_LAYER_VAR##Layer.fx_setRect(0);
  46. _##ROTATION_LAYER_VAR##Layer.fx_setClear(0);
  47. _##ROTATION_LAYER_VAR##Layer.fx_setLocalized(1);
  48. _##ROTATION_LAYER_VAR##Layer.fx_setRealtime(0);
  49. _##ROTATION_LAYER_VAR##Layer.fx_setEnabled(1);
  50. }
  51. _##ROTATION_LAYER_VAR##Layer.fx_onGetPixelR(double r, double d, double x, double y) {
  52. return r + _##ROTATION_LAYER_VAR##R;
  53. }
  54. //--------------------II-----------------
  55. Global Double _##ROTATION_LAYER_VARII##R;
  56. Global Layer _##ROTATION_LAYER_VARII##Layer;
  57. Function _##ROTATION_LAYER_VARII##Init(Group parentgroup, String layername);
  58. Function _##ROTATION_LAYER_VARII##RotateDegree(double r);
  59. Function _##ROTATION_LAYER_VARII##Rotate(double r);
  60. Function double _##ROTATION_LAYER_VARII##GetRotationDegree();
  61. Function double _##ROTATION_LAYER_VARII##GetRotation();
  62. _##ROTATION_LAYER_VARII##RotateDegree(double r) {
  63. _##ROTATION_LAYER_VARII##Rotate(r * PI / 180.0);
  64. }
  65. _##ROTATION_LAYER_VARII##Rotate(double r) {
  66. _##ROTATION_LAYER_VARII##R = r;
  67. _##ROTATION_LAYER_VARII##Layer.fx_update();
  68. }
  69. double _##ROTATION_LAYER_VARII##GetRotationDegree() {
  70. return _##ROTATION_LAYER_VARII##R * 180 / PI;
  71. }
  72. double _##ROTATION_LAYER_VARII##GetRotation() {
  73. return _##ROTATION_LAYER_VARII##R;
  74. }
  75. _##ROTATION_LAYER_VARII##Init(Group parentgroup, String layername) {
  76. _##ROTATION_LAYER_VARII##Layer = parentgroup.getObject(layername);
  77. _##ROTATION_LAYER_VARII##Layer.fx_setGridSize(1,1);
  78. _##ROTATION_LAYER_VARII##Layer.fx_setBgFx(0);
  79. _##ROTATION_LAYER_VARII##Layer.fx_setWrap(1);
  80. _##ROTATION_LAYER_VARII##Layer.fx_setBilinear(1);
  81. _##ROTATION_LAYER_VARII##Layer.fx_setRect(0);
  82. _##ROTATION_LAYER_VARII##Layer.fx_setClear(0);
  83. _##ROTATION_LAYER_VARII##Layer.fx_setLocalized(1);
  84. _##ROTATION_LAYER_VARII##Layer.fx_setRealtime(0);
  85. _##ROTATION_LAYER_VARII##Layer.fx_setEnabled(1);
  86. }
  87. _##ROTATION_LAYER_VARII##Layer.fx_onGetPixelR(double r, double d, double x, double y) {
  88. return r + _##ROTATION_LAYER_VAR##R;
  89. }