_canvas.py 5.3 KB

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