class_texture.rst 11 KB

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