creating_icons.rst 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. .. _doc_editor_icons:
  2. Editor icons
  3. ============
  4. When a new class is created and exposed to scripting, the editor's interface
  5. will display it with a default icon representing the base class it inherits
  6. from. In most cases, it's still recommended to create icons for new classes to
  7. improve the user experience.
  8. Creating icons
  9. ~~~~~~~~~~~~~~
  10. To create new icons, you first need a vector graphics editor installed.
  11. For instance, you can use the open source `Inkscape <https://inkscape.org/>`_ editor.
  12. Clone the ``godot`` repository containing all the editor icons:
  13. .. code-block:: bash
  14. git clone https://github.com/godotengine/godot.git
  15. The icons must be created in a vector graphics editor in SVG format. There are
  16. two main requirements to follow:
  17. - Icons must be 16×16. In Inkscape, you can configure the document size in
  18. **File > Document Properties**.
  19. - Lines should be snapped to pixels whenever possible to remain crisp at lower DPI.
  20. You can create a 16×16 grid in Inkscape to make this easier.
  21. Once you're satisfied with the icon's design, save the icon in the cloned
  22. repository's ``editor/icons`` folder. The icon name should match the intended
  23. name in a case-sensitive manner. For example, to create an icon for
  24. CPUParticles2D, name the file ``CPUParticles2D.svg``.
  25. Color conversion for light editor themes
  26. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  27. If the user has configured their editor to use a light theme, Godot will
  28. convert the icon's colors based on a
  29. `set of predefined color mappings <https://github.com/godotengine/godot/blob/b9f2e57d6240346f1833fd0390de195c956299e7/editor/editor_themes.cpp#L122-L184>`__.
  30. This is to ensure the icon always displays with a sufficient contrast rate.
  31. Try to restrict your icon's color palette to colors found in the list above.
  32. Otherwise, your icon may become difficult to read on a light background.
  33. Icon optimization
  34. ~~~~~~~~~~~~~~~~~
  35. Because the editor renders SVGs once at load time, they need to be small
  36. in size so they can be efficiently parsed. Editor icons must be first
  37. optimized before being added to the engine, to do so:
  38. 1. Install `svgcleaner <https://github.com/RazrFalcon/svgcleaner>`__
  39. by downloading a binary from its
  40. `Releases tab <https://github.com/RazrFalcon/svgcleaner/releases/latest>`__
  41. and placing it into a location in your ``PATH`` environment variable.
  42. 2. Run the command below, replacing ``svg_source.svg`` with the path to your
  43. SVG file (which can be a relative or absolute path):
  44. .. code-block:: bash
  45. svgcleaner --multipass svg_source.svg svg_optimized.svg
  46. The ``--multipass`` switch improves compression, so make sure to include it.
  47. The optimized icon will be saved to ``svg_optimized.svg``. You can also change
  48. the destination parameter to any relative or absolute path you'd like.
  49. .. note::
  50. While this optimization step won't impact the icon's quality noticeably, it
  51. will still remove editor-only information such as guides. Therefore, it's
  52. recommended to keep the source SVG around if you need to make further
  53. changes.
  54. Integrating and sharing the icons
  55. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56. If you're contributing to the engine itself, you should make a pull request to
  57. add optimized icons to ``editor/icons`` in the main repository. Recompile the
  58. engine to make it pick up new icons for classes.
  59. It's also possible to create custom icons within a module. If you're creating
  60. your own module and don't plan to integrate it with Godot, you don't need to
  61. make a separate pull request for your icons to be available within the editor
  62. as they can be self-contained.
  63. For specific instructions on how to create module icons, refer to
  64. :ref:`Creating custom module icons<doc_custom_module_icons>`.
  65. Troubleshooting
  66. ~~~~~~~~~~~~~~~
  67. If icons don't appear in the editor, make sure that:
  68. 1. Each icon's filename matches the naming requirement as described previously.
  69. 2. ``modules/svg`` is enabled (it should be enabled by default). Without it,
  70. icons won't appear in the editor at all.
  71. References
  72. ~~~~~~~~~~
  73. - `editor/icons <https://github.com/godotengine/godot/tree/master/editor/icons>`__