_canvas.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. def canvas_update() -> None:
  2. '''
  3. Updates the display buffer with your drawings from the canvas.
  4. .. note::
  5. Your drawings will only appear on the display after this function call.
  6. '''
  7. pass
  8. def canvas_clear() -> None:
  9. '''
  10. Clear the whole canvas. This does not affect the current display buffer.
  11. You need to call :func:`canvas_update` to reveal your changes.
  12. '''
  13. pass
  14. def canvas_width() -> int:
  15. '''
  16. Get the canvas width in pixels.
  17. :returns: The canvas width.
  18. '''
  19. pass
  20. def canvas_height() -> int:
  21. '''
  22. Get the canvas height in pixels.
  23. :returns: The canvas height.
  24. '''
  25. pass
  26. COLOR_BLACK: int
  27. '''
  28. Constant value for the color `black`.
  29. '''
  30. COLOR_WHITE: int
  31. '''
  32. Constant value for the color `white`.
  33. '''
  34. def canvas_set_color(color: int) -> None:
  35. '''
  36. Set the color to use when drawing or writing on the canvas.
  37. :param color: The color to use.
  38. '''
  39. pass
  40. ALIGN_BEGIN: int
  41. '''
  42. Align element at `begin` (horizontal or vertical, depends on the context).
  43. '''
  44. ALIGN_END: int
  45. '''
  46. Align element at `end` (horizontal or vertical, depends on the context).
  47. '''
  48. ALIGN_CENTER: int
  49. '''
  50. Align element at `center` (horizontal or vertical, depends on the context).
  51. '''
  52. def canvas_set_text_align(x: int, y: int) -> None:
  53. '''
  54. Define how the text should be aligned in relation to the ``x`` and ``y`` coordinates
  55. when writing on the canvas, using the :func:`canvas_set_text` function.
  56. :param x: The horizontal alignment.
  57. :param y: The vertical alignment.
  58. '''
  59. pass
  60. FONT_PRIMARY: int
  61. '''
  62. Constant value for the primary font.
  63. '''
  64. FONT_SECONDARY: int
  65. '''
  66. Constant value for the secondary font.
  67. '''
  68. def canvas_set_font(font: int) -> None:
  69. '''
  70. Change the font to use when writing on the canvas using the :func:`canvas_set_text` function.
  71. :param font: The font to use.
  72. '''
  73. pass
  74. def canvas_set_text(x: int, y: int, text: str) -> None:
  75. '''
  76. Write text on the canvas at the position of ``x`` and ``y`` by using the currently active color, font and alignment settings.
  77. :param x: The horizontal position.
  78. :param y: The vertical position.
  79. :param text: The text to write.
  80. .. code-block::
  81. import flipperzero as f0
  82. f0.canvas_set_color(f0.COLOR_BLACK)
  83. f0.canvas_set_text_align(f0.ALIGN_CENTER, f0.ALIGN_BEGIN)
  84. f0.canvas_set_text(64, 32, 'Hello World!')
  85. f0.canvas_update()
  86. .. seealso::
  87. * :func:`canvas_set_color` to change the canvas color.
  88. * :func:`canvas_set_text_align` to change the alignment settings.
  89. * :func:`canvas_set_font` to change the current font.
  90. '''
  91. pass
  92. def canvas_draw_dot(x: int, y: int) -> None:
  93. '''
  94. Draw a dot on the canvas by using the currently active color settings.
  95. :param x: The horizontal position.
  96. :param y: The vertical position.
  97. '''
  98. pass
  99. def canvas_draw_box(x: int, y: int, w: int, h: int, r: int) -> None:
  100. '''
  101. Draw a box on the canvas. The fill color is defined by the currently active color settings.
  102. Set the corner radius to zero to draw a rectangle without rounded corners.
  103. :param x: The horizontal position.
  104. :param y: The vertical position.
  105. :param w: The width of the box.
  106. :param h: The height of the box.
  107. :param r: The corner radius to use.
  108. '''
  109. pass
  110. def canvas_draw_frame(x: int, y: int, w: int, h: int, r: int) -> None:
  111. '''
  112. Draw a frame on the canvas. The border color is defined by the currently active color settings.
  113. Set the corner radius to zero to draw a rectangle without rounded corners.
  114. :param x: The horizontal position.
  115. :param y: The vertical position.
  116. :param w: The width of the box.
  117. :param h: The height of the box.
  118. :param r: The corner radius to use.
  119. '''
  120. pass
  121. def canvas_draw_line(x0: int, y0: int, x1: int, y1: int) -> None:
  122. '''
  123. Draw a line on the canvas. The color is defined by the currently active color settings.
  124. :param x0: The horizontal start position.
  125. :param y0: The vertical start position.
  126. :param x1: The horizontal end position.
  127. :param y1: The vertical end sposition.
  128. '''
  129. pass
  130. def canvas_draw_circle(x: int, y: int, r: int) -> None:
  131. '''
  132. Draw a circle on the canvas. The border color is defined by the currently active color settings.
  133. :param x: The horizontal position.
  134. :param y: The vertical position.
  135. :param r: The radius to use.
  136. '''
  137. pass
  138. def canvas_draw_disc(x: int, y: int, r: int) -> None:
  139. '''
  140. Draw a disc on the canvas. The fill color is defined by the currently active color settings.
  141. :param x: The horizontal position.
  142. :param y: The vertical position.
  143. :param r: The radius to use.
  144. '''
  145. pass