Documentation
¶
Overview ¶
Package Texture2D provides methods for working with Texture2D object instances.
Index ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Implementation
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) AsTexture() Texture.Instance
- func (self Instance) AsTexture2D() Instance
- func (self Instance) CreatePlaceholder() Resource.Instance
- func (self Instance) Draw(canvas_item RID.CanvasItem, position Vector2.XY)
- func (self Instance) DrawRect(canvas_item RID.CanvasItem, rect Rect2.PositionSize, tile bool)
- func (self Instance) DrawRectRegion(canvas_item RID.CanvasItem, rect Rect2.PositionSize, ...)
- func (self Instance) GetHeight() int
- func (self Instance) GetImage() Image.Instance
- func (self Instance) GetSize() Vector2.XY
- func (self Instance) GetWidth() int
- func (self Instance) HasAlpha() bool
- func (self Instance) ID() ID
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) Virtual(name string) reflect.Value
- type Interface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Expanded ¶
func (Expanded) Draw ¶
func (self Expanded) Draw(canvas_item RID.CanvasItem, position Vector2.XY, modulate Color.RGBA, transpose bool)
Draws the texture using a [CanvasItem] with the [RenderingServer] API at the specified [param position].
func (Expanded) DrawRect ¶
func (self Expanded) DrawRect(canvas_item RID.CanvasItem, rect Rect2.PositionSize, tile bool, modulate Color.RGBA, transpose bool)
Draws the texture using a [CanvasItem] with the [RenderingServer] API.
func (Expanded) DrawRectRegion ¶
func (self Expanded) DrawRectRegion(canvas_item RID.CanvasItem, rect Rect2.PositionSize, src_rect Rect2.PositionSize, modulate Color.RGBA, transpose bool, clip_uv bool)
Draws a part of the texture using a [CanvasItem] with the [RenderingServer] API.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
func (*Extension[T]) AsTexture2D ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D [Sprite2D] or GUI [Control]. Textures are often created by loading them from a file. See [method @GDScript.load]. [Texture2D] is a base for other resources. It cannot be used directly. [b]Note:[/b] The maximum texture size is 16384×16384 pixels due to graphics hardware limitations. Larger textures may fail to import.
See [Interface] for methods that can be overridden by a [Class] that extends it.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) AsTexture2D ¶
func (Instance) CreatePlaceholder ¶
Creates a placeholder version of this resource ([PlaceholderTexture2D]).
func (Instance) Draw ¶
func (self Instance) Draw(canvas_item RID.CanvasItem, position Vector2.XY)
Draws the texture using a [CanvasItem] with the [RenderingServer] API at the specified [param position].
func (Instance) DrawRect ¶
func (self Instance) DrawRect(canvas_item RID.CanvasItem, rect Rect2.PositionSize, tile bool)
Draws the texture using a [CanvasItem] with the [RenderingServer] API.
func (Instance) DrawRectRegion ¶
func (self Instance) DrawRectRegion(canvas_item RID.CanvasItem, rect Rect2.PositionSize, src_rect Rect2.PositionSize)
Draws a part of the texture using a [CanvasItem] with the [RenderingServer] API.
func (Instance) GetImage ¶
Returns an [Image] that is a copy of data from this [Texture2D] (a new [Image] is created each time). [Image]s can be accessed and manipulated directly. [b]Note:[/b] This will return [code]null[/code] if this [Texture2D] is invalid. [b]Note:[/b] This will fetch the texture data from the GPU, which might cause performance problems when overused. Avoid calling [method get_image] every frame, especially on large textures.
type Interface ¶
type Interface interface { //Called when the [Texture2D]'s width is queried. GetWidth() int //Called when the [Texture2D]'s height is queried. GetHeight() int //Called when a pixel's opaque state in the [Texture2D] is queried at the specified [code](x, y)[/code] position. IsPixelOpaque(x int, y int) bool //Called when the presence of an alpha channel in the [Texture2D] is queried. HasAlpha() bool //Called when the entire [Texture2D] is requested to be drawn over a [CanvasItem], with the top-left offset specified in [param pos]. [param modulate] specifies a multiplier for the colors being drawn, while [param transpose] specifies whether drawing should be performed in column-major order instead of row-major order (resulting in 90-degree clockwise rotation). //[b]Note:[/b] This is only used in 2D rendering, not 3D. Draw(to_canvas_item RID.Any, pos Vector2.XY, modulate Color.RGBA, transpose bool) //Called when the [Texture2D] is requested to be drawn onto [CanvasItem]'s specified [param rect]. [param modulate] specifies a multiplier for the colors being drawn, while [param transpose] specifies whether drawing should be performed in column-major order instead of row-major order (resulting in 90-degree clockwise rotation). //[b]Note:[/b] This is only used in 2D rendering, not 3D. DrawRect(to_canvas_item RID.Any, rect Rect2.PositionSize, tile bool, modulate Color.RGBA, transpose bool) //Called when a part of the [Texture2D] specified by [param src_rect]'s coordinates is requested to be drawn onto [CanvasItem]'s specified [param rect]. [param modulate] specifies a multiplier for the colors being drawn, while [param transpose] specifies whether drawing should be performed in column-major order instead of row-major order (resulting in 90-degree clockwise rotation). //[b]Note:[/b] This is only used in 2D rendering, not 3D. DrawRectRegion(to_canvas_item RID.Any, rect Rect2.PositionSize, src_rect Rect2.PositionSize, modulate Color.RGBA, transpose bool, clip_uv bool) }