logo.ino 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include <EEPROM.h>
  2. #include <SPI.h>
  3. #include <GD2.h>
  4. #include "logo_assets.h"
  5. void setup()
  6. {
  7. Serial.begin(1000000); // JCB
  8. GD.begin();
  9. LOAD_ASSETS();
  10. }
  11. byte clamp255(int x)
  12. {
  13. if (x < 0)
  14. return 0;
  15. if (255 < x)
  16. return 255;
  17. return x;
  18. }
  19. #define NSTARS 256
  20. void loop()
  21. {
  22. byte fade;
  23. xy stars[NSTARS];
  24. for (int i = 0; i < NSTARS; i++)
  25. stars[i].set(GD.random(PIXELS(GD.w)), GD.random(PIXELS(GD.h)));
  26. for (int t = 0; t < 464; t++) {
  27. GD.cmd_gradient(0, 0, 0x120000, 0, GD.h, 0x480000);
  28. GD.BlendFunc(SRC_ALPHA, ONE);
  29. GD.Begin(POINTS);
  30. for (int i = 0; i < NSTARS; i++) {
  31. GD.ColorA(64 + (i >> 2));
  32. GD.PointSize(8 + (i >> 5));
  33. stars[i].draw();
  34. // stars drift left, then wrap around
  35. stars[i].x -= 1 + (i >> 5);
  36. if (stars[i].x < -256) {
  37. stars[i].x += PIXELS(GD.w + 20);
  38. stars[i].y = GD.random(PIXELS(GD.h));
  39. }
  40. }
  41. GD.RestoreContext();
  42. GD.Begin(BITMAPS);
  43. // Main logo fades up from black
  44. fade = clamp255(5 * (t - 15));
  45. GD.ColorRGB(fade, fade, fade);
  46. GD.Vertex2ii(240 - GAMEDUINO_WIDTH/2, 65, GAMEDUINO_HANDLE, 0);
  47. GD.RestoreContext();
  48. // The '2' and its glow
  49. fade = clamp255(8 * (t - 120));
  50. GD.ColorA(fade);
  51. GD.Vertex2ii(270, 115, TWO_HANDLE, 0);
  52. fade = clamp255(5 * (t - 144));
  53. GD.BlendFunc(SRC_ALPHA, ONE);
  54. GD.ColorA(fade);
  55. GD.ColorRGB(85,85,85);
  56. GD.Vertex2ii(270, 115, TWO_HANDLE, 1);
  57. GD.RestoreContext();
  58. // The text fades up. Its glow is a full-screen bitmap
  59. fade = clamp255(8 * (t - 160));
  60. GD.ColorA(fade);
  61. GD.cmd_text(140, 200, 29, OPT_CENTER, "This time");
  62. GD.cmd_text(140, 225, 29, OPT_CENTER, "it's personal");
  63. fade = clamp255(5 * (t - 184));
  64. GD.BlendFunc(SRC_ALPHA, ONE);
  65. GD.ColorA(fade);
  66. GD.ColorRGB(85,85,85);
  67. GD.Vertex2ii(0, 0, PERSONAL_HANDLE, 0);
  68. // OSHW logo fades in
  69. GD.ColorRGB(0, 153 * 160 / 255, 176 * 160 / 255);
  70. GD.Vertex2ii(2, 2, OSHW_HANDLE, 0);
  71. GD.RestoreContext();
  72. // Fade to white at the end by drawing a white rectangle on top
  73. fade = clamp255(5 * (t - 400));
  74. GD.ColorA(fade);
  75. GD.Begin(EDGE_STRIP_R);
  76. GD.Vertex2f(0, 0);
  77. GD.Vertex2f(0, PIXELS(GD.h));
  78. GD.swap();
  79. }
  80. }