class_texture.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Texture.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Texture:
  6. Texture
  7. =======
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`AnimatedTexture<class_AnimatedTexture>`, :ref:`AtlasTexture<class_AtlasTexture>`, :ref:`CurveTexture<class_CurveTexture>`, :ref:`GradientTexture<class_GradientTexture>`, :ref:`ImageTexture<class_ImageTexture>`, :ref:`LargeTexture<class_LargeTexture>`, :ref:`NoiseTexture<class_NoiseTexture>`, :ref:`ProxyTexture<class_ProxyTexture>`, :ref:`StreamTexture<class_StreamTexture>`, :ref:`ViewportTexture<class_ViewportTexture>`
  10. **Category:** Core
  11. Brief Description
  12. -----------------
  13. Texture for 2D and 3D.
  14. Properties
  15. ----------
  16. +-----------------------+--------------------------------------------+
  17. | :ref:`int<class_int>` | :ref:`flags<class_Texture_property_flags>` |
  18. +-----------------------+--------------------------------------------+
  19. Methods
  20. -------
  21. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`draw<class_Texture_method_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 |
  23. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`draw_rect<class_Texture_method_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 |
  25. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`draw_rect_region<class_Texture_method_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 |
  27. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Image<class_Image>` | :ref:`get_data<class_Texture_method_get_data>` **(** **)** const |
  29. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`get_height<class_Texture_method_get_height>` **(** **)** const |
  31. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Vector2<class_Vector2>` | :ref:`get_size<class_Texture_method_get_size>` **(** **)** const |
  33. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`get_width<class_Texture_method_get_width>` **(** **)** const |
  35. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`has_alpha<class_Texture_method_has_alpha>` **(** **)** const |
  37. +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. Enumerations
  39. ------------
  40. .. _enum_Texture_Flags:
  41. .. _class_Texture_constant_FLAGS_DEFAULT:
  42. .. _class_Texture_constant_FLAG_MIPMAPS:
  43. .. _class_Texture_constant_FLAG_REPEAT:
  44. .. _class_Texture_constant_FLAG_FILTER:
  45. .. _class_Texture_constant_FLAG_ANISOTROPIC_FILTER:
  46. .. _class_Texture_constant_FLAG_CONVERT_TO_LINEAR:
  47. .. _class_Texture_constant_FLAG_MIRRORED_REPEAT:
  48. .. _class_Texture_constant_FLAG_VIDEO_SURFACE:
  49. enum **Flags**:
  50. - **FLAGS_DEFAULT** = **7** --- Default flags. Generate mipmaps, repeat, and filter are enabled.
  51. - **FLAG_MIPMAPS** = **1** --- Generate mipmaps, which are smaller versions of the same texture to use when zoomed out, keeping the aspect ratio.
  52. - **FLAG_REPEAT** = **2** --- Repeats texture (instead of clamp to edge).
  53. - **FLAG_FILTER** = **4** --- Magnifying filter, to enable smooth zooming in of the texture.
  54. - **FLAG_ANISOTROPIC_FILTER** = **8** --- Anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.
  55. 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.
  56. - **FLAG_CONVERT_TO_LINEAR** = **16** --- Converts texture to SRGB color space.
  57. - **FLAG_MIRRORED_REPEAT** = **32** --- Repeats texture with alternate sections mirrored.
  58. - **FLAG_VIDEO_SURFACE** = **2048** --- Texture is a video surface.
  59. Description
  60. -----------
  61. 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>`.
  62. Textures are often created by loading them from a file. See :ref:`@GDScript.load<class_@GDScript_method_load>`.
  63. Property Descriptions
  64. ---------------------
  65. .. _class_Texture_property_flags:
  66. - :ref:`int<class_int>` **flags**
  67. +----------+------------------+
  68. | *Setter* | set_flags(value) |
  69. +----------+------------------+
  70. | *Getter* | get_flags() |
  71. +----------+------------------+
  72. The texture's flags.
  73. Method Descriptions
  74. -------------------
  75. .. _class_Texture_method_draw:
  76. - 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
  77. ----
  78. .. _class_Texture_method_draw_rect:
  79. - 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
  80. ----
  81. .. _class_Texture_method_draw_rect_region:
  82. - 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
  83. ----
  84. .. _class_Texture_method_get_data:
  85. - :ref:`Image<class_Image>` **get_data** **(** **)** const
  86. ----
  87. .. _class_Texture_method_get_height:
  88. - :ref:`int<class_int>` **get_height** **(** **)** const
  89. Returns the texture height.
  90. ----
  91. .. _class_Texture_method_get_size:
  92. - :ref:`Vector2<class_Vector2>` **get_size** **(** **)** const
  93. Returns the texture size.
  94. ----
  95. .. _class_Texture_method_get_width:
  96. - :ref:`int<class_int>` **get_width** **(** **)** const
  97. Returns the texture width.
  98. ----
  99. .. _class_Texture_method_has_alpha:
  100. - :ref:`bool<class_bool>` **has_alpha** **(** **)** const