Texture2D

package
v0.0.0-...-2b43b64 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package Texture2D provides methods for working with Texture2D object instances.

Index

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 Any

type Any interface {
	gd.IsClass
	AsTexture2D() Instance
}

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.Texture2D

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.

%!(EXTRA string=Texture2D)

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsTexture

func (self Instance) AsTexture() Texture.Instance

func (Instance) AsTexture2D

func (self Instance) AsTexture2D() Instance

func (Instance) CreatePlaceholder

func (self Instance) CreatePlaceholder() [1]gdclass.Resource

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) GetHeight

func (self Instance) GetHeight() int

Returns the texture height in pixels.

func (Instance) GetImage

func (self Instance) GetImage() [1]gdclass.Image

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.

func (Instance) GetSize

func (self Instance) GetSize() Vector2.XY

Returns the texture size in pixels.

func (Instance) GetWidth

func (self Instance) GetWidth() int

Returns the texture width in pixels.

func (Instance) HasAlpha

func (self Instance) HasAlpha() bool

Returns [code]true[/code] if this [Texture2D] has an alpha channel.

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL