docs_image_guidelines.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. .. _docs_image_guidelines:
  2. Creating documentation images and videos
  3. ========================================
  4. Throughout the documentation, images are often needed to make the explanation
  5. of a feature or concept as clear as possible for a reader. This page will
  6. explain the process from beginning to end.
  7. Images
  8. ------
  9. Capturing an image
  10. ^^^^^^^^^^^^^^^^^^
  11. To take a picture of something in Godot, a screen capture tool can be used.
  12. On Windows 10 and 11 that would be the Snip & Sketch program.
  13. Pressing :kbd:`Windows + Shift + S` lets you take a screenshot
  14. of a portion of the screen and save it to the clipboard.
  15. After pressing those keys, click and drag over
  16. the area you wish to take a picture of.
  17. On macOS, pressing :kbd:`Shift + Command + 3` does the same.
  18. To take a picture of the entire screen press :kbd:`Shift + Command + 4`.
  19. All screenshots taken will be saved to the desktop.
  20. Each Linux desktop environment has it's own screenshot tool. For example,
  21. on KDE Plasma the program Spectacle is used for taking screenshots. If your
  22. distribution doesn't come with one by default try searching its package
  23. repository, or Flathub if that's supported.
  24. All screenshots should ideally be taken on a 1080p screen. Anything higher
  25. resolution is adding detail that doesn't make the documentation better and
  26. dramatically increases file size. If you're taking screenshots on a higher
  27. resolution screen the screenshot should be scaled down. There are instructions
  28. on how to do this later on this page.
  29. Format conversion
  30. ^^^^^^^^^^^^^^^^^
  31. The current format for images in Godot's documentation is WebP (``.webp``).
  32. While some Linux programs will support saving screenshots in this format, macOS
  33. and the Snip & Sketch program on Windows do not. For images that don't need
  34. editing, such as precise cropping or adding outlines, Squoosh can be used.
  35. `Squoosh <https://squoosh.app/>`_ is a converter developed by Google, is open
  36. source, and doesn't give Google any image rights by using it. When choosing
  37. compression if you can get an image that's under 300KB in size use lossless
  38. compression. If it's over 300KB, use just enough lossy compression to get it
  39. under that size. If this results in noticeable compression artifacts using less
  40. compression is fine, even if the file size is bigger.
  41. If you already have an image editor such as GIMP, Krita or Photoshop installed
  42. it may have the ability to open an image then save it as a WebP file.
  43. .. note::
  44. Since WebP supports animations and the documentation can display videos,
  45. GIFs should be avoided. Their compression is inefficient and they only support
  46. a 256-color palette with 1-bit transparency.
  47. Cropping
  48. ^^^^^^^^
  49. For a screenshot of a 2D or 3D scene in the editor, the above steps will be enough.
  50. But for most UI images some extra work should be done, specifically cropping to
  51. make an image look clean. Below is an example of good cropping.
  52. .. image:: img/cropped_image.webp
  53. For cropping Krita is the recommended program. While some screenshot programs do
  54. have cropping built-in it's not always easy to get something precise. And while
  55. Krita is designed as a painting program the cropping tool gives you pixel precision
  56. by default. Of course, feel free to use a different program you are familiar with.
  57. If you've never used Krita before download it from the `official Krita website <https://krita.org/en/download/>`_,
  58. on Linux you may also be able to download it from your distributions repository,
  59. flathub is also an option. Once it's installed on your computer open Krita then
  60. open the image you want to crop. This button on the left panel is the crop tool.
  61. .. image:: img/crop_tool.webp
  62. After selecting it, click on the image, you should now have cropping tools available.
  63. .. image:: img/crop_edit.webp
  64. Click and drag the white boxes to adjust what gets cropped, if you zoom in close
  65. to the image you will see the individual pixels in an image, which is useful for
  66. precision.
  67. .. image:: img/crop_pixels.webp
  68. If you make a mistake and overcrop don't worry, cropping is non-destructive in
  69. Krita and can be adjusted. Click on the image with your cropping tool still selected
  70. and the controls will return.
  71. Scaling down an image
  72. ^^^^^^^^^^^^^^^^^^^^^
  73. As explained earlier on this page, all images taken on a screen that is a higher resolution
  74. than 1080p should be scaled down. To do this in Krita click on **Image** on the top bar, and
  75. from the dropdown menu select **Scale Image To New Size**. This menu can also be opened by
  76. pressing :kbd:`Ctrl + Alt + I`. On this menu you want to adjust the pixel dimensions. For
  77. anything taken on a 4K monitor change the value of the width and height to half of its current
  78. value, for anything taken on a 1440p monitor multiply the width and height by 0.75. Make
  79. sure the **Constrain Proportions** box at the bottom of the menu is checked so you only have
  80. to change 1 value.
  81. Saving as WebP in Krita
  82. ^^^^^^^^^^^^^^^^^^^^^^^
  83. To save an image as webp if it isn't already one, Go to **File > Save As**. Select **webp** from the
  84. **Save as type:** dropdown, then choose wherever you want to save it. After clicking **Save** a menu
  85. will popup with webp options. Make sure **Lossless** is checked and **Quality** is set to 100%. This
  86. means the image will not lose detail and will be as small as possible.
  87. If the image is over 300KB in size try compressing it losslessly using `Squoosh <https://squoosh.app/>`_.
  88. If it's still over 300KB change to lossy compression and slowly increase the compression until it's under
  89. 300KB. If this results in noticeable compression artifacts using less compression is fine, even if the file
  90. size is bigger.
  91. Outlines, arrows and text
  92. ^^^^^^^^^^^^^^^^^^^^^^^^^
  93. Sometimes an image needs something extra to properly direct the readers
  94. attention, or make something clear. Outlines and arrows can be used
  95. for this purpose. For these types of edits Inkscape is the recommended open
  96. source program, it can be downloaded from the `official Inkscape website <https://inkscape.org/>`_.
  97. Like Krita, if you're on Linux you can also check your distributions repository
  98. or get it from Flathub.
  99. A full tutorial on creating outlines is not provided here, we recommend searching
  100. for various tutorials on how to use it online. However there are two standards
  101. for doc image outlines and arrows. First, the color should be yellow, specifically
  102. this hex color: ``fffb44`` (``fffb44ff`` if there is a transparency value like in Inkscape).
  103. This color was chosen specifically to make sure color blind people do not have
  104. issues reading the documentation, other colors can be used in addition to this yellow
  105. if multiple outlines on an image are needed, red should be avoided. The second standard
  106. is that all outlines and arrow lines should be 2 pixels wide.
  107. Finally, some images might require text to differentiate multiple parts of an image.
  108. There are no strict requirements other than use an easy to read non fancy font. As for
  109. color the yellow color from before should also be used, but black or other colors can
  110. be used if appropriate. For example, if yellow blends into the image, or if there are
  111. multiple outlines in multiple colors.
  112. Adding an image to a documentation page
  113. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  114. Once you've finished working on your image, it can be added to the documentation.
  115. All images are stored in folders named ``img`` next to the page they are used in.
  116. To add your image, add it to the ``img`` folder that's in the same folder as the
  117. ``.rst`` file for the page (create it if it doesn't exist). In the ``.rst`` page,
  118. images should be included with the following code snippet::
  119. .. image:: img/documentation_image.webp
  120. Where ``documentation_image.webp`` would be changed to the name of the image you
  121. created. Name your images in a way that makes their meaning clear, possibly with
  122. a prefix that makes their relationship to a documentation page explicit.
  123. Videos
  124. ------
  125. Capturing a video
  126. ^^^^^^^^^^^^^^^^^
  127. To record a video of something in Godot, a screen capture tool can be used.
  128. Operating systems generally don't come with tools that are flexible enough
  129. for this, so you'll need to install a third-party utility.
  130. `OBS Studio <https://obsproject.com/>`__ is the most popular option, but
  131. `SimpleScreenRecorder <https://www.maartenbaert.be/simplescreenrecorder/>`__
  132. can be used as an alternative on Linux. `ShareX <https://getsharex.com/>`__
  133. can be used as an alternative on Windows. All these tools can be configured
  134. to record the entire screen, a specific window or a predetermined rectangle.
  135. The recommended framerate for video recordings is 60 FPS, although you can use
  136. 30 FPS for longer videos to reduce their file size. For fullscreen videos,
  137. use a resolution of 1280×720.
  138. .. note::
  139. Godot's :ref:`Movie Maker mode <doc_creating_movies>` can be used to record
  140. the output of a running project, including its audio. This doesn't require
  141. installing any third-party software and avoids any frame drops (even when
  142. recording on a slow device), but it's less flexible.
  143. Compressing the captured video
  144. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  145. The recommendation is to record your video in the highest quality possible
  146. (without dropping frames due to excessive CPU/GPU utilization), then re-encode
  147. it later to reduce its file size. This results in more efficient compression
  148. than directly aiming for a small file size, as real-time compression methods are
  149. less efficient than slower compression methods.
  150. To re-encode videos for a smaller file size, use `HandBrake <https://handbrake.fr/>`__
  151. or the `FFmpeg <https://ffmpeg.org/>` command line below:
  152. ::
  153. ffmpeg -i input.mp4 -crf 23 output.webm
  154. The number after ``-crf`` adjusts the video quality, with higher numbers
  155. resulting in *lower* quality (and smaller file sizes). A CRF of ``23`` is a good
  156. starting point, but you may need to use a higher value for longer videos to
  157. ensure the file size remains reasonable. Try to aim for a file size under 2 MB
  158. if possible.
  159. If the video was recorded in a higher resolution or framerate, you can adjust
  160. its output resolution and framerate as follows:
  161. ::
  162. ffmpeg -i input.mp4 -crf 23 -vf scale=1280:-2 -r 30 output.webm
  163. This results in a video resolution around 1280×720 at 30 FPS. The exact
  164. video resolution will vary depending on the source's aspect ratio.
  165. .. tip::
  166. If the video was recorded with an audio track but this audio track is not
  167. necessary, consider stripping it by adding the ``-an`` option to the FFmpeg
  168. command line (before the output file name). This will reduce file size and
  169. also ensure audio controls don't show up on the video when played in a
  170. browser.
  171. Adding a video to a documentation page
  172. --------------------------------------
  173. Once you've finished working on your video, it can be added to the documentation.
  174. All videos are stored in folders named ``video`` next to the page they are used in.
  175. To add your video, add it to the ``video`` folder that's in the same folder as the
  176. ``.rst`` file for the page (create it if it doesn't exist). In the ``.rst`` page,
  177. videos should be included with the following code snippet::
  178. .. video:: video/csg_tools.webm
  179. :alt: Put a text description of the video here
  180. :autoplay:
  181. :loop:
  182. :muted:
  183. Where ``documentation_video.webp`` would be changed to the name of the video you
  184. created. Name your videos in a way that makes their meaning clear, possibly with
  185. a prefix that makes their relationship to a documentation page explicit.
  186. The ``:autoplay:``, ``:loop:`` and ``:muted:`` flags should always be specified
  187. unless the video needs to play audio. In this case, do not specify *any* of these flags.