| 1 | /* |
| 2 | This frei0r plugin generates white noise images |
| 3 | |
| 4 | Copyright (C) 2004, 2005 Martin Bayer <[email protected]> |
| 5 | Copyright (C) 2005 Georg Seidel <[email protected]> |
| 6 | |
| 7 | This library is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU Lesser General Public |
| 9 | License as published by the Free Software Foundation; either |
| 10 | version 2.1 of the License, or (at your option) any later version. |
| 11 | |
| 12 | This library is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | Lesser General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public |
| 18 | License along with this library; if not, write to the Free Software |
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | #include "frei0r.hpp"cxx . . $ `<file>/include/frei0r.hpp`/ |
| 23 | |
| 24 | #include <algorithm> |
| 25 | #include <cmath> |
| 26 | |
| 27 | |
| 28 | #ifndef M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`! |
| 29 | #define M_PI 3.14159265358979323846 |
| 30 | #endif |
| 31 | |
| 32 | class lissajous0rcxx . . $ lissajous0r#: public frei0rcxx . . $ frei0r/::sourcecxx . . $ frei0r/source# |
| 33 | { |
| 34 | public: |
| 35 | lissajous0rcxx . . $ lissajous0r#lissajous0r(b4d55b1286ff73e8).(unsigned int width, unsigned int height) |
| 36 | { |
| 37 | r_xcxx . . $ lissajous0r#r_x. = r_ycxx . . $ lissajous0r#r_y. = 0.0; |
| 38 | register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(r_xcxx . . $ lissajous0r#r_x.,"ratiox"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,"x-ratio"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 39 | register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(r_ycxx . . $ lissajous0r#r_y.,"ratioy"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,"y-ratio"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 40 | } |
| 41 | |
| 42 | |
| 43 | virtual void updatecxx . . $ lissajous0r#update(c707e0475ee5518c).(double time, |
| 44 | uint32_t* out) |
| 45 | { |
| 46 | std::fillcxx . . $ std/fill(4a9bfaed88eccda7).(out, out+widthcxx . . $ frei0r/fx#width.*heightcxx . . $ frei0r/fx#height., 0x00000000); |
| 47 | |
| 48 | double rx=1.0/(0.999999-r_xcxx . . $ lissajous0r#r_x.); |
| 49 | double ry=1.0/(0.999999-r_ycxx . . $ lissajous0r#r_y.); |
| 50 | |
| 51 | double w = 0.5*(widthcxx . . $ frei0r/fx#width.-1); |
| 52 | double h = 0.5*(heightcxx . . $ frei0r/fx#height.-1); |
| 53 | |
| 54 | const unsigned int samples = 15*(widthcxx . . $ frei0r/fx#width.+heightcxx . . $ frei0r/fx#height.); |
| 55 | |
| 56 | double deltax = (rx*2*M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!) / (double) samples; |
| 57 | double deltay = (ry*2*M_PIcxx . . $ `<external>/11263917310783833665/math.h:1289:10`!) / (double) samples; |
| 58 | double tx = 0; |
| 59 | double ty = 0; |
| 60 | for (unsigned int i=samples; i != 0; --i, tx+=deltax, ty+=deltay) |
| 61 | { |
| 62 | unsigned int x = static_cast<unsigned int>(w*(1.0+sin(tx))); |
| 63 | unsigned int y = static_cast<unsigned int>(h*(1.0+cos(ty))); |
| 64 | |
| 65 | out[widthcxx . . $ frei0r/fx#width.*y + x]=0xffffffff; |
| 66 | } |
| 67 | } |
| 68 | private: |
| 69 | double r_xcxx . . $ lissajous0r#r_x.; |
| 70 | double r_ycxx . . $ lissajous0r#r_y.; |
| 71 | }; |
| 72 | |
| 73 | |
| 74 | frei0rcxx . . $ frei0r/::constructcxx . . $ frei0r/construct#<lissajous0rcxx . . $ lissajous0r#> plugincxx . . $ plugin.("Lissajous0r"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., |
| 75 | "Generates Lissajous0r images"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., |
| 76 | "Martin Bayer"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., |
| 77 | 0,3); |
| 78 |