class_texture.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Texture.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Texture:
  5. Texture
  6. =======
  7. **Inherits:** :ref:`Resource<class_resource>` **<** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`
  8. **Inherited By:** :ref:`CurveTexture<class_curvetexture>`, :ref:`AtlasTexture<class_atlastexture>`, :ref:`ProxyTexture<class_proxytexture>`, :ref:`GradientTexture<class_gradienttexture>`, :ref:`ViewportTexture<class_viewporttexture>`, :ref:`StreamTexture<class_streamtexture>`, :ref:`ImageTexture<class_imagetexture>`, :ref:`LargeTexture<class_largetexture>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Texture for 2D and 3D.
  13. Member Functions
  14. ----------------
  15. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`draw<class_Texture_draw>` **(** :ref:`RID<class_rid>` canvas_item, :ref:`Vector2<class_vector2>` position, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null **)** const |
  17. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`draw_rect<class_Texture_draw_rect>` **(** :ref:`RID<class_rid>` canvas_item, :ref:`Rect2<class_rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null **)** const |
  19. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`draw_rect_region<class_Texture_draw_rect_region>` **(** :ref:`RID<class_rid>` canvas_item, :ref:`Rect2<class_rect2>` rect, :ref:`Rect2<class_rect2>` src_rect, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null, :ref:`bool<class_bool>` clip_uv=true **)** const |
  21. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`Image<class_image>` | :ref:`get_data<class_Texture_get_data>` **(** **)** const |
  23. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`get_flags<class_Texture_get_flags>` **(** **)** const |
  25. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`get_height<class_Texture_get_height>` **(** **)** const |
  27. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Vector2<class_vector2>` | :ref:`get_size<class_Texture_get_size>` **(** **)** const |
  29. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`get_width<class_Texture_get_width>` **(** **)** const |
  31. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`has_alpha<class_Texture_has_alpha>` **(** **)** const |
  33. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_flags<class_Texture_set_flags>` **(** :ref:`int<class_int>` flags **)** |
  35. +--------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. Numeric Constants
  37. -----------------
  38. - **FLAG_MIPMAPS** = **1** --- Generate mipmaps, which are smaller versions of the same texture to use when zoomed out, keeping the aspect ratio.
  39. - **FLAG_REPEAT** = **2** --- Repeats texture (instead of clamp to edge).
  40. - **FLAG_FILTER** = **4** --- Magnifying filter, to enable smooth zooming in of the texture.
  41. - **FLAGS_DEFAULT** = **7** --- Default flags. Generate mipmaps, repeat, and filter are enabled.
  42. - **FLAG_ANISOTROPIC_FILTER** = **8** --- Anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.
  43. More effective on planes often shown going to the horrizon as those textures (Walls or Ground for example) get squashed in the viewport to different aspect ratios and regular mipmaps keep the aspect ratio so they don't optimize storage that well in those cases.
  44. - **FLAG_CONVERT_TO_LINEAR** = **16** --- Converts texture to SRGB color space.
  45. - **FLAG_MIRRORED_REPEAT** = **32** --- Repeats texture with alternate sections mirrored.
  46. - **FLAG_VIDEO_SURFACE** = **4096** --- Texture is a video surface.
  47. Description
  48. -----------
  49. A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D :ref:`Sprite<class_sprite>` or GUI :ref:`Control<class_control>`.
  50. Member Function Description
  51. ---------------------------
  52. .. _class_Texture_draw:
  53. - void **draw** **(** :ref:`RID<class_rid>` canvas_item, :ref:`Vector2<class_vector2>` position, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null **)** const
  54. .. _class_Texture_draw_rect:
  55. - void **draw_rect** **(** :ref:`RID<class_rid>` canvas_item, :ref:`Rect2<class_rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null **)** const
  56. .. _class_Texture_draw_rect_region:
  57. - void **draw_rect_region** **(** :ref:`RID<class_rid>` canvas_item, :ref:`Rect2<class_rect2>` rect, :ref:`Rect2<class_rect2>` src_rect, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null, :ref:`bool<class_bool>` clip_uv=true **)** const
  58. .. _class_Texture_get_data:
  59. - :ref:`Image<class_image>` **get_data** **(** **)** const
  60. .. _class_Texture_get_flags:
  61. - :ref:`int<class_int>` **get_flags** **(** **)** const
  62. Return the current texture flags.
  63. .. _class_Texture_get_height:
  64. - :ref:`int<class_int>` **get_height** **(** **)** const
  65. Return the texture height.
  66. .. _class_Texture_get_size:
  67. - :ref:`Vector2<class_vector2>` **get_size** **(** **)** const
  68. Return the texture size.
  69. .. _class_Texture_get_width:
  70. - :ref:`int<class_int>` **get_width** **(** **)** const
  71. Return the texture width.
  72. .. _class_Texture_has_alpha:
  73. - :ref:`bool<class_bool>` **has_alpha** **(** **)** const
  74. .. _class_Texture_set_flags:
  75. - void **set_flags** **(** :ref:`int<class_int>` flags **)**
  76. Change the texture flags.