No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

63 líneas
1.7 KiB

  1. //
  2. // Lol Engine — GIF encoding sample
  3. //
  4. // Copyright © 2016—2019 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // Lol Engine is free software. It comes without any warranty, to
  7. // the extent permitted by applicable law. You can redistribute it
  8. // and/or modify it under the terms of the Do What the Fuck You Want
  9. // to Public License, Version 2, as published by the WTFPL Task Force.
  10. // See http://www.wtfpl.net/ for more details.
  11. //
  12. #if HAVE_CONFIG_H
  13. # include "config.h"
  14. #endif
  15. #include <lol/engine.h>
  16. #include "loldebug.h"
  17. int main(int argc, char **argv)
  18. {
  19. UNUSED(argc, argv);
  20. lol::ivec2 size(256, 256);
  21. lol::movie movie(size);
  22. if (!movie.open_file("16_movie.gif"))
  23. return EXIT_FAILURE;
  24. // Use 4D Perlin noise
  25. lol::perlin_noise<4> noise;
  26. for (int i = 0; i < 256; ++i)
  27. {
  28. lol::image im(size);
  29. lol::array2d<lol::u8vec3> &data = im.lock2d<lol::PixelFormat::RGB_8>();
  30. for (int y = 0; y < size.y; ++y)
  31. for (int x = 0; x < size.x; ++x)
  32. {
  33. float alpha = lol::F_TAU * i / 256;
  34. float beta = lol::F_TAU * i / 256;
  35. lol::vec4 p(2.f * x / (float)size.x + cos(alpha),
  36. 2.f * x / (float)size.x + sin(alpha),
  37. 2.f * y / (float)size.y + cos(beta),
  38. 2.f * y / (float)size.y + sin(beta));
  39. data[x][y].r = 128 * (noise.eval(p) + 1 + lol::rand(0.1f));
  40. data[x][y].g = 128 * (noise.eval(p.zyxw) + 1 + lol::rand(0.1f));
  41. data[x][y].b = 128 * (noise.eval(p.ywxz) + 1 + lol::rand(0.1f));
  42. }
  43. im.unlock2d(data);
  44. if (!movie.push_image(im))
  45. break;
  46. }
  47. movie.close();
  48. return 0;
  49. }