fork download
  1. #include <stdint.h>
  2.  
  3. const int WIDTH = 320;
  4. const int HEIGHT = 240;
  5. const int RADIUS = 10;
  6.  
  7. void drawPixel(int x, int y, uint16_t color) {
  8. // code to draw a single pixel at (x, y) with the specified color
  9. }
  10.  
  11. void drawRectangle(int x, int y, int width, int height, uint16_t color) {
  12. for (int i = x; i < x + width; i++) {
  13. for (int j = y; j < y + height; j++) {
  14. drawPixel(i, j, color);
  15. }
  16. }
  17. }
  18.  
  19. void drawCircle(int x, int y, int r, uint16_t color) {
  20. for (int i = x - r; i <= x + r; i++) {
  21. for (int j = y - r; j <= y + r; j++) {
  22. if ((i - x) * (i - x) + (j - y) * (j - y) <= r * r) {
  23. drawPixel(i, j, color);
  24. }
  25. }
  26. }
  27. }
  28.  
  29. void drawRoundedRectangle(int x, int y, int width, int height, uint16_t color) {
  30. drawRectangle(x + RADIUS, y, width - 2 * RADIUS, height, color);
  31. drawRectangle(x, y + RADIUS, RADIUS, height - 2 * RADIUS, color);
  32. drawRectangle(x + width - RADIUS, y + RADIUS, RADIUS, height - 2 * RADIUS, color);
  33. drawCircle(x + RADIUS, y + RADIUS, RADIUS, color);
  34. drawCircle(x + width - RADIUS, y + RADIUS, RADIUS, color);
  35. drawCircle(x + RADIUS, y + height - RADIUS, RADIUS, color);
  36. drawCircle(x + width - RADIUS, y + height - RADIUS, RADIUS, color);
  37. }
  38.  
  39. int main() {
  40. drawRoundedRectangle(50, 50, 200, 100, 0xF800);
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 5524KB
stdin
Standard input is empty
stdout
Standard output is empty