| 1 | /* |
| 2 | This frei0r plugin generates white noise images |
| 3 | |
| 4 | Copyright (C) 2004, 2005 Martin Bayer <[email protected]> |
| 5 | |
| 6 | This library is free software; you can redistribute it and/or |
| 7 | modify it under the terms of the GNU Lesser General Public |
| 8 | License as published by the Free Software Foundation; either |
| 9 | version 2.1 of the License, or (at your option) any later version. |
| 10 | |
| 11 | This library is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | Lesser General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU Lesser General Public |
| 17 | License along with this library; if not, write to the Free Software |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | #include "frei0r.hpp"cxx . . $ `<file>/include/frei0r.hpp`/ |
| 22 | |
| 23 | #include <algorithm> |
| 24 | |
| 25 | struct wnoisecxx . . $ wnoise# |
| 26 | { |
| 27 | wnoisecxx . . $ wnoise#wnoise(cb2f890c2fdad230).(unsigned int s) |
| 28 | : seedcxx . . $ wnoise#seed.(s) {} |
| 29 | |
| 30 | unsigned int seedcxx . . $ wnoise#seed.; |
| 31 | |
| 32 | unsigned int operatorcxx . . $ wnoise#`operator()`(db52760e79bf9054).()() |
| 33 | { |
| 34 | seedcxx . . $ wnoise#seed. *= 3039177861U; // parameter for LCG |
| 35 | unsigned char rd = seedcxx . . $ wnoise#seed. >> 24; |
| 36 | return (rd | rd << 8 | rd << 16 | 0xff000000); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | }; |
| 41 | |
| 42 | class nois0rcxx . . $ nois0r# : public frei0rcxx . . $ frei0r/::sourcecxx . . $ frei0r/source# |
| 43 | { |
| 44 | public: |
| 45 | nois0rcxx . . $ nois0r#nois0r(b4d55b1286ff73e8).(unsigned int width, unsigned int height) |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | |
| 50 | virtual void updatecxx . . $ nois0r#update(c707e0475ee5518c).(double time, |
| 51 | uint32_t* out) |
| 52 | { |
| 53 | wnoisecxx . . $ wnoise# wncxx . . $ wnoise#wnoise(cb2f890c2fdad230).(0x0f0f0f0f ^ (unsigned int)(time*100000.0)); |
| 54 | |
| 55 | stdcxx . . $ std/::generatecxx . . $ std/generate(4d3091562df4e52e).(out, out+widthcxx . . $ frei0r/fx#width.*heightcxx . . $ frei0r/fx#height., wn); |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | |
| 60 | frei0rcxx . . $ frei0r/::constructcxx . . $ frei0r/construct#<nois0rcxx . . $ nois0r#> plugincxx . . $ plugin.("Nois0r"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., |
| 61 | "Generates white noise images"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., |
| 62 | "Martin Bayer"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., |
| 63 | 0,3); |
| 64 |