canvas_app.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This file is Copyright (c) 2025 Victor Suarez Rovere <suarezvictor@gmail.com>
  2. // SPDX-License-Identifier: AGPL-3.0-only
  3. #include "misc.h"
  4. #include "processing_api.h"
  5. using namespace processing;
  6. PGraphics canvas;
  7. PFont dejavu;
  8. #include "DejaVuSansMono.ttf.c" //inline font data
  9. void setup()
  10. {
  11. dejavu = createFont("DejaVuSansMono.ttf", 75, DejaVuSansMono_ttf, DejaVuSansMono_ttf_len);
  12. canvas.clear();
  13. println("drawing start");
  14. }
  15. void draw()
  16. {
  17. //oblique lines
  18. canvas.stroke(GRAY);
  19. for(int x = 0; x < canvas.width; x += 8)
  20. canvas.line(x, 0, x*2 - canvas.width, canvas.height);
  21. //rectangular shapes
  22. canvas.fill(BLUE);
  23. canvas.rect(400, 50, 600, 400);
  24. canvas.fill(GREEN);
  25. canvas.rect(10, 175, 300, 400, 15); //rounded corners
  26. //ellipse with shadow
  27. canvas.fill(BLACK);
  28. canvas.ellipse(320, 170, 100, 80);
  29. canvas.fill(WHITE);
  30. canvas.lastshape(-10, -10);
  31. //text
  32. canvas.fill(RED);
  33. canvas.textFont(dejavu);
  34. canvas.text("Hello", 30, 320);
  35. }
  36. extern "C" int graphics_app(void)
  37. {
  38. setup();
  39. draw();
  40. return 0;
  41. }
  42. //include all source dependencies
  43. #include "accel_canvas.cpp"
  44. #include "processing_api.cpp"