CanvasItem

package
v0.0.0-...-fa94a0d Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 38 Imported by: 0

Documentation

Overview

Abstract base class for everything in 2D space. Canvas items are laid out in a tree; children inherit and extend their parent's transform. CanvasItem is extended by Control for GUI-related nodes, and by Node2D for 2D game objects.

Any CanvasItem can draw. For this, QueueRedraw is called by the engine, then NotificationDraw will be received on idle time to request a redraw. Because of this, canvas items don't need to be redrawn on every frame, improving the performance significantly. Several functions for drawing on the CanvasItem are provided (see draw_* functions). However, they can only be used inside Draw, its corresponding Object.Notification or methods connected to the OnDraw signal.

Canvas items are drawn in tree order on their canvas layer. By default, children are on top of their parents, so a root CanvasItem will be drawn behind everything. This behavior can be changed on a per-item basis.

A CanvasItem can be hidden, which will also hide its children. By adjusting various other properties of a CanvasItem, you can also modulate its color (via Modulate or SelfModulate), change its Z-index, blend mode, and more.

Note that properties like transform, modulation, and visibility are only propagated to direct CanvasItem child nodes. If there is a non-CanvasItem node in between, like Node or AnimationPlayer, the CanvasItem nodes below will have an independent position and Modulate chain. See also TopLevel.

Index

Constants

View Source
const NotificationDraw Object.Notification = 30 //gd:CanvasItem.NOTIFICATION_DRAW
View Source
const NotificationEnterCanvas Object.Notification = 32 //gd:CanvasItem.NOTIFICATION_ENTER_CANVAS
View Source
const NotificationExitCanvas Object.Notification = 33 //gd:CanvasItem.NOTIFICATION_EXIT_CANVAS
View Source
const NotificationLocalTransformChanged Object.Notification = 35 //gd:CanvasItem.NOTIFICATION_LOCAL_TRANSFORM_CHANGED
View Source
const NotificationTransformChanged Object.Notification = 2000 //gd:CanvasItem.NOTIFICATION_TRANSFORM_CHANGED
View Source
const NotificationVisibilityChanged Object.Notification = 31 //gd:CanvasItem.NOTIFICATION_VISIBILITY_CHANGED
View Source
const NotificationWorld2dChanged Object.Notification = 36 //gd:CanvasItem.NOTIFICATION_WORLD_2D_CHANGED

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
	AsCanvasItem() Instance
}

type ClipChildrenMode

type ClipChildrenMode int //gd:CanvasItem.ClipChildrenMode
const (
	// Children are drawn over this node and are not clipped.
	ClipChildrenDisabled ClipChildrenMode = 0
	// This node is used as a mask and is not drawn. The mask is based on this node's alpha channel: Opaque pixels are kept, transparent pixels are discarded, and semi-transparent pixels are blended in according to their opacity. Children are clipped to this node's drawn area.
	ClipChildrenOnly ClipChildrenMode = 1
	// This node is used as a mask and is also drawn. The mask is based on this node's alpha channel: Opaque pixels are kept, transparent pixels are discarded, and semi-transparent pixels are blended in according to their opacity. Children are clipped to the parent's drawn area.
	ClipChildrenAndDraw ClipChildrenMode = 2
	// Represents the size of the [ClipChildrenMode] enum.
	ClipChildrenMax ClipChildrenMode = 3
)

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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]See Interface for methods that can be overridden by T.

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.CanvasItem

Instance of the class with convieniently typed arguments and results.

var Nil Instance

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

func New

func New() Instance

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

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

func (Instance) ClipChildren

func (self Instance) ClipChildren() ClipChildrenMode

func (Instance) DrawAnimationSlice

func (self Instance) DrawAnimationSlice(animation_length Float.X, slice_begin Float.X, slice_end Float.X)

Subsequent drawing commands will be ignored unless they fall within the specified animation slice. This is a faster way to implement animations that loop on background rather than redrawing constantly.

func (Instance) DrawArc

func (self Instance) DrawArc(center Vector2.XY, radius Float.X, start_angle Angle.Radians, end_angle Angle.Radians, point_count int, color Color.RGBA)

Draws an unfilled arc between the given angles with a uniform 'color' and 'width' and optional antialiasing (supported only for positive 'width'). The larger the value of 'point_count', the smoother the curve. 'center' is defined in local space. See also DrawCircle.

If 'width' is negative, it will be ignored and the arc will be drawn using [Renderingserver.PrimitiveLineStrip]. This means that when the CanvasItem is scaled, the arc will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

The arc is drawn from 'start_angle' towards the value of 'end_angle' so in clockwise direction if start_angle < end_angle and counter-clockwise otherwise. Passing the same angles but in reversed order will produce the same arc. If absolute difference of 'start_angle' and 'end_angle' is greater than [@Gdscript.Tau] radians, then a full circle arc is drawn (i.e. arc will not overlap itself).

func (Instance) DrawChar

func (self Instance) DrawChar(font Font.Instance, pos Vector2.XY, char string)

Draws a string first character using a custom font. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used. 'pos' is defined in local space.

func (Instance) DrawCharOutline

func (self Instance) DrawCharOutline(font Font.Instance, pos Vector2.XY, char string)

Draws a string first character outline using a custom font. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used. 'pos' is defined in local space.

func (Instance) DrawCircle

func (self Instance) DrawCircle(position Vector2.XY, radius Float.X, color Color.RGBA)

Draws a circle, with 'position' defined in local space. See also DrawArc, DrawPolyline, and DrawPolygon.

If 'filled' is true, the circle will be filled with the 'color' specified. If 'filled' is false, the circle will be drawn as a stroke with the 'color' and 'width' specified.

If 'width' is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

If 'antialiased' is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.

Note: 'width' is only effective if 'filled' is false.

func (Instance) DrawColoredPolygon

func (self Instance) DrawColoredPolygon(points []Vector2.XY, color Color.RGBA)

Draws a colored polygon of any number of points, convex or concave. The points in the 'points' array are defined in local space. Unlike DrawPolygon, a single color must be specified for the whole polygon.

Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using DrawMesh, DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray.

func (Instance) DrawDashedLine

func (self Instance) DrawDashedLine(from Vector2.XY, to Vector2.XY, color Color.RGBA)

Draws a dashed line from a 2D point to another, with a given color and width. The 'from' and 'to' positions are defined in local space. See also DrawLine, DrawMultiline, and DrawPolyline.

If 'width' is negative, then a two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the line parts will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

'dash' is the length of each dash in pixels, with the gap between each dash being the same length. If 'aligned' is true, the length of the first and last dashes may be shortened or lengthened to allow the line to begin and end at the precise points defined by 'from' and 'to'. Both ends are always symmetrical when 'aligned' is true. If 'aligned' is false, all dashes will have the same length, but the line may appear incomplete at the end due to the dash length not dividing evenly into the line length. Only full dashes are drawn when 'aligned' is false.

If 'antialiased' is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.

Note: 'antialiased' is only effective if 'width' is greater than 0.0.

func (Instance) DrawEndAnimation

func (self Instance) DrawEndAnimation()

After submitting all animations slices via DrawAnimationSlice, this function can be used to revert drawing to its default state (all subsequent drawing commands will be visible). If you don't care about this particular use case, usage of this function after submitting the slices is not required.

func (Instance) DrawLcdTextureRectRegion

func (self Instance) DrawLcdTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, src_rect Rect2.PositionSize)

Draws a textured rectangle region of the font texture with LCD subpixel anti-aliasing at a given position, optionally modulated by a color. The 'rect' is defined in local space.

Texture is drawn using the following blend operation, blend mode of the CanvasItemMaterial is ignored:

var dst, texture, modulate Color.RGBA
dst.R = texture.R*modulate.R*modulate.A + dst.R*(1.0-texture.R*modulate.A)
dst.G = texture.G*modulate.G*modulate.A + dst.G*(1.0-texture.G*modulate.A)
dst.B = texture.B*modulate.B*modulate.A + dst.B*(1.0-texture.B*modulate.A)
dst.A = modulate.A + dst.A*(1.0-modulate.A)

func (Instance) DrawLine

func (self Instance) DrawLine(from Vector2.XY, to Vector2.XY, color Color.RGBA)

Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. The 'from' and 'to' positions are defined in local space. See also DrawDashedLine, DrawMultiline, and DrawPolyline.

If 'width' is negative, then a two-point primitive will be drawn instead of a four-point one. This means that when the CanvasItem is scaled, the line will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

func (Instance) DrawMesh

func (self Instance) DrawMesh(mesh Mesh.Instance, texture Texture2D.Instance)

Draws a Mesh in 2D, using the provided texture. See MeshInstance2D for related documentation. The 'transform' is defined in local space.

func (Instance) DrawMsdfTextureRectRegion

func (self Instance) DrawMsdfTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, src_rect Rect2.PositionSize)

Draws a textured rectangle region of the multichannel signed distance field texture at a given position, optionally modulated by a color. The 'rect' is defined in local space. See FontFile.MultichannelSignedDistanceField for more information and caveats about MSDF font rendering.

If 'outline' is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the 'outline' radius.

Value of the 'pixel_range' should the same that was used during distance field texture generation.

func (Instance) DrawMultiline

func (self Instance) DrawMultiline(points []Vector2.XY, color Color.RGBA)

Draws multiple disconnected lines with a uniform 'width' and 'color'. Each line is defined by two consecutive points from 'points' array in local space, i.e. i-th segment consists of points[2 * i], points[2 * i + 1] endpoints. When drawing large amounts of lines, this is faster than using individual DrawLine calls. To draw interconnected lines, use DrawPolyline instead.

If 'width' is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

Note: 'antialiased' is only effective if 'width' is greater than 0.0.

func (Instance) DrawMultilineColors

func (self Instance) DrawMultilineColors(points []Vector2.XY, colors []Color.RGBA)

Draws multiple disconnected lines with a uniform 'width' and segment-by-segment coloring. Each segment is defined by two consecutive points from 'points' array in local space and a corresponding color from 'colors' array, i.e. i-th segment consists of points[2 * i], points[2 * i + 1] endpoints and has colors[i] color. When drawing large amounts of lines, this is faster than using individual DrawLine calls. To draw interconnected lines, use DrawPolylineColors instead.

If 'width' is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

Note: 'antialiased' is only effective if 'width' is greater than 0.0.

func (Instance) DrawMultilineString

func (self Instance) DrawMultilineString(font Font.Instance, pos Vector2.XY, text string)

Breaks 'text' into lines and draws it using the specified 'font' at the 'pos' in local space (top-left corner). The text will have its color multiplied by 'modulate'. If 'width' is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

func (Instance) DrawMultilineStringOutline

func (self Instance) DrawMultilineStringOutline(font Font.Instance, pos Vector2.XY, text string)

Breaks 'text' to the lines and draws text outline using the specified 'font' at the 'pos' in local space (top-left corner). The text will have its color multiplied by 'modulate'. If 'width' is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

func (Instance) DrawMultimesh

func (self Instance) DrawMultimesh(multimesh MultiMesh.Instance, texture Texture2D.Instance)

Draws a MultiMesh in 2D with the provided texture. See MultiMeshInstance2D for related documentation.

func (Instance) DrawPolygon

func (self Instance) DrawPolygon(points []Vector2.XY, colors []Color.RGBA)

Draws a solid polygon of any number of points, convex or concave. Unlike DrawColoredPolygon, each point's color can be changed individually. The 'points' array is defined in local space. See also DrawPolyline and DrawPolylineColors. If you need more flexibility (such as being able to use bones), use RenderingServer.CanvasItemAddTriangleArray instead.

Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using DrawMesh, DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray.

func (Instance) DrawPolyline

func (self Instance) DrawPolyline(points []Vector2.XY, color Color.RGBA)

Draws interconnected line segments with a uniform 'color' and 'width' and optional antialiasing (supported only for positive 'width'). The 'points' array is defined in local space. When drawing large amounts of lines, this is faster than using individual DrawLine calls. To draw disconnected lines, use DrawMultiline instead. See also DrawPolygon.

If 'width' is negative, it will be ignored and the polyline will be drawn using [Renderingserver.PrimitiveLineStrip]. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

func (Instance) DrawPolylineColors

func (self Instance) DrawPolylineColors(points []Vector2.XY, colors []Color.RGBA)

Draws interconnected line segments with a uniform 'width', point-by-point coloring, and optional antialiasing (supported only for positive 'width'). Colors assigned to line points match by index between 'points' and 'colors', i.e. each line segment is filled with a gradient between the colors of the endpoints. The 'points' array is defined in local space. When drawing large amounts of lines, this is faster than using individual DrawLine calls. To draw disconnected lines, use DrawMultilineColors instead. See also DrawPolygon.

If 'width' is negative, it will be ignored and the polyline will be drawn using [Renderingserver.PrimitiveLineStrip]. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

func (Instance) DrawPrimitive

func (self Instance) DrawPrimitive(points []Vector2.XY, colors []Color.RGBA, uvs []Vector2.XY)

Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. If 0 points or more than 4 points are specified, nothing will be drawn and an error message will be printed. The 'points' array is defined in local space. See also DrawLine, DrawPolyline, DrawPolygon, and DrawRect.

func (Instance) DrawRect

func (self Instance) DrawRect(rect Rect2.PositionSize, color Color.RGBA)

Draws a rectangle. If 'filled' is true, the rectangle will be filled with the 'color' specified. If 'filled' is false, the rectangle will be drawn as a stroke with the 'color' and 'width' specified. The 'rect' is specified in local space. See also DrawTextureRect.

If 'width' is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

If 'antialiased' is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.

Note: 'width' is only effective if 'filled' is false.

Note: Unfilled rectangles drawn with a negative 'width' may not display perfectly. For example, corners may be missing or brighter due to overlapping lines (for a translucent 'color').

func (Instance) DrawSetTransform

func (self Instance) DrawSetTransform(position Vector2.XY)

Sets a custom local transform for drawing via components. Anything drawn afterwards will be transformed by this.

Note: FontFile.Oversampling does not take 'scale' into account. This means that scaling up/down will cause bitmap fonts and rasterized (non-MSDF) dynamic fonts to appear blurry or pixelated. To ensure text remains crisp regardless of scale, you can enable MSDF font rendering by enabling ProjectSettings "gui/theme/default_font_multichannel_signed_distance_field" (applies to the default project font only), or enabling Multichannel Signed Distance Field in the import options of a DynamicFont for custom fonts. On system fonts, SystemFont.MultichannelSignedDistanceField can be enabled in the inspector.

func (Instance) DrawSetTransformMatrix

func (self Instance) DrawSetTransformMatrix(xform Transform2D.OriginXY)

Sets a custom local transform for drawing via matrix. Anything drawn afterwards will be transformed by this.

func (Instance) DrawString

func (self Instance) DrawString(font Font.Instance, pos Vector2.XY, text string)

Draws 'text' using the specified 'font' at the 'pos' in local space (bottom-left corner using the baseline of the font). The text will have its color multiplied by 'modulate'. If 'width' is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

Example: Draw "Hello world", using the project's default font:

// If using this method in a script that redraws constantly, move the
// `default_font` declaration to a member variable assigned in `Ready()`
// so the Control is only created once.
var defaultFont = ThemeDB.FallbackFont()
var defaultFontSize = ThemeDB.FallbackFontSize()
canvas_item.MoreArgs().DrawString(defaultFont, Vector2.New(64, 64), "Hello world", GUI.HorizontalAlignmentLeft, -1, defaultFontSize,
	Color.W3C.White, TextServer.JustificationKashida|TextServer.JustificationWordBound, 0, 0, 0)

See also Font.DrawString.

func (Instance) DrawStringOutline

func (self Instance) DrawStringOutline(font Font.Instance, pos Vector2.XY, text string)

Draws 'text' outline using the specified 'font' at the 'pos' in local space (bottom-left corner using the baseline of the font). The text will have its color multiplied by 'modulate'. If 'width' is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

func (Instance) DrawTexture

func (self Instance) DrawTexture(texture Texture2D.Instance, position Vector2.XY)

Draws a texture at a given position. The 'position' is defined in local space.

func (Instance) DrawTextureRect

func (self Instance) DrawTextureRect(texture Texture2D.Instance, rect Rect2.PositionSize, tile bool)

Draws a textured rectangle at a given position, optionally modulated by a color. The 'rect' is defined in local space. If 'transpose' is true, the texture will have its X and Y coordinates swapped. See also DrawRect and DrawTextureRectRegion.

func (Instance) DrawTextureRectRegion

func (self Instance) DrawTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, src_rect Rect2.PositionSize)

Draws a textured rectangle from a texture's region (specified by 'src_rect') at a given position in local space, optionally modulated by a color. If 'transpose' is true, the texture will have its X and Y coordinates swapped. See also DrawTextureRect.

func (Instance) ForceUpdateTransform

func (self Instance) ForceUpdateTransform()

Forces the node's transform to update. Fails if the node is not inside the tree. See also GetTransform.

Note: For performance reasons, transform changes are usually accumulated and applied once at the end of the frame. The update propagates through CanvasItem children, as well. Therefore, use this method only when you need an up-to-date transform (such as during physics operations).

func (Instance) GetCanvas

func (self Instance) GetCanvas() RID.Canvas

Returns the Resource.ID of the World2D canvas where this node is registered to, used by the RenderingServer.

func (Instance) GetCanvasItem

func (self Instance) GetCanvasItem() RID.CanvasItem

Returns the internal canvas item Resource.ID used by the RenderingServer for this node.

func (Instance) GetCanvasLayerNode

func (self Instance) GetCanvasLayerNode() CanvasLayer.Instance

Returns the CanvasLayer that contains this node, or null if the node is not in any CanvasLayer.

func (Instance) GetCanvasTransform

func (self Instance) GetCanvasTransform() Transform2D.OriginXY

Returns the transform of this node, converted from its registered canvas's coordinate system to its viewport's coordinate system. See also Node.GetViewport.

func (Instance) GetGlobalMousePosition

func (self Instance) GetGlobalMousePosition() Vector2.XY

Returns mouse cursor's global position relative to the CanvasLayer that contains this node.

Note: For screen-space coordinates (e.g. when using a non-embedded Popup), you can use DisplayServer.MouseGetPosition.

func (Instance) GetGlobalTransform

func (self Instance) GetGlobalTransform() Transform2D.OriginXY

Returns the global transform matrix of this item, i.e. the combined transform up to the topmost CanvasItem node. The topmost item is a CanvasItem that either has no parent, has non-CanvasItem parent or it has TopLevel enabled.

func (Instance) GetGlobalTransformWithCanvas

func (self Instance) GetGlobalTransformWithCanvas() Transform2D.OriginXY

Returns the transform from the local coordinate system of this CanvasItem to the Viewports coordinate system.

func (Instance) GetInstanceShaderParameter

func (self Instance) GetInstanceShaderParameter(name string) any

Get the value of a shader parameter as set on this instance.

func (Instance) GetLocalMousePosition

func (self Instance) GetLocalMousePosition() Vector2.XY

Returns the mouse's position in this CanvasItem using the local coordinate system of this CanvasItem.

func (Instance) GetScreenTransform

func (self Instance) GetScreenTransform() Transform2D.OriginXY

Returns the transform of this CanvasItem in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.

Equals to GetGlobalTransform if the window is embedded (see Viewport.GuiEmbedSubwindows).

func (Instance) GetTransform

func (self Instance) GetTransform() Transform2D.OriginXY

Returns the transform matrix of this CanvasItem.

func (Instance) GetViewportRect

func (self Instance) GetViewportRect() Rect2.PositionSize

Returns this node's viewport boundaries as a Rect2.PositionSize. See also Node.GetViewport.

func (Instance) GetViewportTransform

func (self Instance) GetViewportTransform() Transform2D.OriginXY

Returns the transform of this node, converted from its registered canvas's coordinate system to its viewport embedder's coordinate system. See also Viewport.GetFinalTransform and Node.GetViewport.

func (Instance) GetVisibilityLayerBit

func (self Instance) GetVisibilityLayerBit(layer int) bool

Returns true if the layer at the given index is set in VisibilityLayer.

func (Instance) GetWorld2d

func (self Instance) GetWorld2d() World2D.Instance

Returns the World2D this node is registered to.

Usually, this is the same as this node's viewport (see Node.GetViewport and Viewport.FindWorld2d).

func (Instance) Hide

func (self Instance) Hide()

Hide the CanvasItem if it's currently visible. This is equivalent to setting Visible to false.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsLocalTransformNotificationEnabled

func (self Instance) IsLocalTransformNotificationEnabled() bool

Returns true if the node receives NotificationLocalTransformChanged whenever its local transform changes. This is enabled with SetNotifyLocalTransform.

func (Instance) IsTransformNotificationEnabled

func (self Instance) IsTransformNotificationEnabled() bool

Returns true if the node receives NotificationTransformChanged whenever its global transform changes. This is enabled with SetNotifyTransform.

func (Instance) IsVisibleInTree

func (self Instance) IsVisibleInTree() bool

Returns true if the node is present in the SceneTree, its Visible property is true and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree, and is therefore not drawn (see Draw).

Visibility is checked only in parent nodes that inherit from CanvasItem, CanvasLayer, and Window. If the parent is of any other type (such as Node, AnimationPlayer, or Node3D), it is assumed to be visible.

Note: This method does not take VisibilityLayer into account, so even if this method returns true, the node might end up not being rendered.

func (Instance) LightMask

func (self Instance) LightMask() int

func (Instance) MakeCanvasPositionLocal

func (self Instance) MakeCanvasPositionLocal(viewport_point Vector2.XY) Vector2.XY

Transforms 'viewport_point' from the viewport's coordinates to this node's local coordinates.

For the opposite operation, use GetGlobalTransformWithCanvas.

var viewport_point = Transform2D.Vector(local_point, canvas_item.GetGlobalTransformWithCanvas())

func (Instance) MakeInputLocal

func (self Instance) MakeInputLocal(event InputEvent.Instance) InputEvent.Instance

Returns a copy of the given 'event' with its coordinates converted from global space to this CanvasItem's local space. If not possible, returns the same InputEvent unchanged.

func (Instance) Material

func (self Instance) Material() Material.Instance

func (Instance) Modulate

func (self Instance) Modulate() Color.RGBA

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) MoveToFront

func (self Instance) MoveToFront()

Moves this node below its siblings, usually causing the node to draw on top of its siblings. Does nothing if this node does not have a parent. See also Node.MoveChild.

func (Instance) OnDraw

func (self Instance) OnDraw(cb func(), flags ...Signal.Flags)

func (Instance) OnHidden

func (self Instance) OnHidden(cb func(), flags ...Signal.Flags)

func (Instance) OnItemRectChanged

func (self Instance) OnItemRectChanged(cb func(), flags ...Signal.Flags)

func (Instance) OnVisibilityChanged

func (self Instance) OnVisibilityChanged(cb func(), flags ...Signal.Flags)

func (Instance) QueueRedraw

func (self Instance) QueueRedraw()

Queues the CanvasItem to redraw. During idle time, if CanvasItem is visible, NotificationDraw is sent and Draw is called. This only occurs once per frame, even if this method has been called multiple times.

func (Instance) SelfModulate

func (self Instance) SelfModulate() Color.RGBA

func (Instance) SetClipChildren

func (self Instance) SetClipChildren(value ClipChildrenMode)

func (Instance) SetInstanceShaderParameter

func (self Instance) SetInstanceShaderParameter(name string, value any)

Set the value of a shader uniform for this instance only (per-instance uniform). See also ShaderMaterial.SetShaderParameter to assign a uniform on all instances using the same ShaderMaterial.

Note: For a shader uniform to be assignable on a per-instance basis, it must be defined with instance uniform ... rather than uniform ... in the shader code.

Note: 'name' is case-sensitive and must match the name of the uniform in the code exactly (not the capitalized name in the inspector).

func (Instance) SetLightMask

func (self Instance) SetLightMask(value int)

func (Instance) SetMaterial

func (self Instance) SetMaterial(value Material.Instance)

func (Instance) SetModulate

func (self Instance) SetModulate(value Color.RGBA)

func (Instance) SetNotifyLocalTransform

func (self Instance) SetNotifyLocalTransform(enable bool)

If true, the node will receive NotificationLocalTransformChanged whenever its local transform changes.

Note: Many canvas items such as Bone2D or CollisionShape2D automatically enable this in order to function correctly.

func (Instance) SetNotifyTransform

func (self Instance) SetNotifyTransform(enable bool)

If true, the node will receive NotificationTransformChanged whenever global transform changes.

Note: Many canvas items such as Camera2D or Light2D automatically enable this in order to function correctly.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetSelfModulate

func (self Instance) SetSelfModulate(value Color.RGBA)

func (Instance) SetShowBehindParent

func (self Instance) SetShowBehindParent(value bool)

func (Instance) SetTextureFilter

func (self Instance) SetTextureFilter(value TextureFilter)

func (Instance) SetTextureRepeat

func (self Instance) SetTextureRepeat(value TextureRepeat)

func (Instance) SetTopLevel

func (self Instance) SetTopLevel(value bool)

func (Instance) SetUseParentMaterial

func (self Instance) SetUseParentMaterial(value bool)

func (Instance) SetVisibilityLayer

func (self Instance) SetVisibilityLayer(value int)

func (Instance) SetVisibilityLayerBit

func (self Instance) SetVisibilityLayerBit(layer int, enabled bool)

Set/clear individual bits on the rendering visibility layer. This simplifies editing this CanvasItem's visibility layer.

func (Instance) SetVisible

func (self Instance) SetVisible(value bool)

func (Instance) SetYSortEnabled

func (self Instance) SetYSortEnabled(value bool)

func (Instance) SetZAsRelative

func (self Instance) SetZAsRelative(value bool)

func (Instance) SetZIndex

func (self Instance) SetZIndex(value int)

func (Instance) Show

func (self Instance) Show()

Show the CanvasItem if it's currently hidden. This is equivalent to setting Visible to true.

Note: For controls that inherit Popup, the correct way to make them visible is to call one of the multiple popup*() functions instead.

func (Instance) ShowBehindParent

func (self Instance) ShowBehindParent() bool

func (Instance) TextureFilter

func (self Instance) TextureFilter() TextureFilter

func (Instance) TextureRepeat

func (self Instance) TextureRepeat() TextureRepeat

func (Instance) TopLevel

func (self Instance) TopLevel() bool

func (Instance) UseParentMaterial

func (self Instance) UseParentMaterial() bool

func (Instance) Virtual

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

func (Instance) VisibilityLayer

func (self Instance) VisibilityLayer() int

func (Instance) Visible

func (self Instance) Visible() bool

func (Instance) YSortEnabled

func (self Instance) YSortEnabled() bool

func (Instance) ZAsRelative

func (self Instance) ZAsRelative() bool

func (Instance) ZIndex

func (self Instance) ZIndex() int

type Interface

type Interface interface {
	// Called when [CanvasItem] has been requested to redraw (after [QueueRedraw] is called, either manually or by the engine).
	//
	// Corresponds to the [NotificationDraw] notification in [Object.Notification].
	//
	// [CanvasItem]: https://pkg.go.dev/graphics.gd/classdb/CanvasItem
	// [Object.Notification]: https://pkg.go.dev/graphics.gd/variant/Object#Notification
	// [QueueRedraw]: https://pkg.go.dev/graphics.gd/classdb/CanvasItem#Instance.QueueRedraw
	Draw()
}

type MoreArgs

type MoreArgs [1]gdclass.CanvasItem

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) DrawAnimationSlice

func (self MoreArgs) DrawAnimationSlice(animation_length Float.X, slice_begin Float.X, slice_end Float.X, offset Float.X)

Subsequent drawing commands will be ignored unless they fall within the specified animation slice. This is a faster way to implement animations that loop on background rather than redrawing constantly.

func (MoreArgs) DrawArc

func (self MoreArgs) DrawArc(center Vector2.XY, radius Float.X, start_angle Angle.Radians, end_angle Angle.Radians, point_count int, color Color.RGBA, width Float.X, antialiased bool)

Draws an unfilled arc between the given angles with a uniform 'color' and 'width' and optional antialiasing (supported only for positive 'width'). The larger the value of 'point_count', the smoother the curve. 'center' is defined in local space. See also DrawCircle.

If 'width' is negative, it will be ignored and the arc will be drawn using [Renderingserver.PrimitiveLineStrip]. This means that when the CanvasItem is scaled, the arc will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

The arc is drawn from 'start_angle' towards the value of 'end_angle' so in clockwise direction if start_angle < end_angle and counter-clockwise otherwise. Passing the same angles but in reversed order will produce the same arc. If absolute difference of 'start_angle' and 'end_angle' is greater than [@Gdscript.Tau] radians, then a full circle arc is drawn (i.e. arc will not overlap itself).

func (MoreArgs) DrawChar

func (self MoreArgs) DrawChar(font Font.Instance, pos Vector2.XY, char string, font_size int, modulate Color.RGBA, oversampling Float.X)

Draws a string first character using a custom font. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used. 'pos' is defined in local space.

func (MoreArgs) DrawCharOutline

func (self MoreArgs) DrawCharOutline(font Font.Instance, pos Vector2.XY, char string, font_size int, size int, modulate Color.RGBA, oversampling Float.X)

Draws a string first character outline using a custom font. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used. 'pos' is defined in local space.

func (MoreArgs) DrawCircle

func (self MoreArgs) DrawCircle(position Vector2.XY, radius Float.X, color Color.RGBA, filled bool, width Float.X, antialiased bool)

Draws a circle, with 'position' defined in local space. See also DrawArc, DrawPolyline, and DrawPolygon.

If 'filled' is true, the circle will be filled with the 'color' specified. If 'filled' is false, the circle will be drawn as a stroke with the 'color' and 'width' specified.

If 'width' is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

If 'antialiased' is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.

Note: 'width' is only effective if 'filled' is false.

func (MoreArgs) DrawColoredPolygon

func (self MoreArgs) DrawColoredPolygon(points []Vector2.XY, color Color.RGBA, uvs []Vector2.XY, texture Texture2D.Instance)

Draws a colored polygon of any number of points, convex or concave. The points in the 'points' array are defined in local space. Unlike DrawPolygon, a single color must be specified for the whole polygon.

Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using DrawMesh, DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray.

func (MoreArgs) DrawDashedLine

func (self MoreArgs) DrawDashedLine(from Vector2.XY, to Vector2.XY, color Color.RGBA, width Float.X, dash Float.X, aligned bool, antialiased bool)

Draws a dashed line from a 2D point to another, with a given color and width. The 'from' and 'to' positions are defined in local space. See also DrawLine, DrawMultiline, and DrawPolyline.

If 'width' is negative, then a two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the line parts will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

'dash' is the length of each dash in pixels, with the gap between each dash being the same length. If 'aligned' is true, the length of the first and last dashes may be shortened or lengthened to allow the line to begin and end at the precise points defined by 'from' and 'to'. Both ends are always symmetrical when 'aligned' is true. If 'aligned' is false, all dashes will have the same length, but the line may appear incomplete at the end due to the dash length not dividing evenly into the line length. Only full dashes are drawn when 'aligned' is false.

If 'antialiased' is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.

Note: 'antialiased' is only effective if 'width' is greater than 0.0.

func (MoreArgs) DrawLcdTextureRectRegion

func (self MoreArgs) DrawLcdTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, src_rect Rect2.PositionSize, modulate Color.RGBA)

Draws a textured rectangle region of the font texture with LCD subpixel anti-aliasing at a given position, optionally modulated by a color. The 'rect' is defined in local space.

Texture is drawn using the following blend operation, blend mode of the CanvasItemMaterial is ignored:

var dst, texture, modulate Color.RGBA
dst.R = texture.R*modulate.R*modulate.A + dst.R*(1.0-texture.R*modulate.A)
dst.G = texture.G*modulate.G*modulate.A + dst.G*(1.0-texture.G*modulate.A)
dst.B = texture.B*modulate.B*modulate.A + dst.B*(1.0-texture.B*modulate.A)
dst.A = modulate.A + dst.A*(1.0-modulate.A)

func (MoreArgs) DrawLine

func (self MoreArgs) DrawLine(from Vector2.XY, to Vector2.XY, color Color.RGBA, width Float.X, antialiased bool)

Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. The 'from' and 'to' positions are defined in local space. See also DrawDashedLine, DrawMultiline, and DrawPolyline.

If 'width' is negative, then a two-point primitive will be drawn instead of a four-point one. This means that when the CanvasItem is scaled, the line will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

func (MoreArgs) DrawMesh

func (self MoreArgs) DrawMesh(mesh Mesh.Instance, texture Texture2D.Instance, transform Transform2D.OriginXY, modulate Color.RGBA)

Draws a Mesh in 2D, using the provided texture. See MeshInstance2D for related documentation. The 'transform' is defined in local space.

func (MoreArgs) DrawMsdfTextureRectRegion

func (self MoreArgs) DrawMsdfTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, src_rect Rect2.PositionSize, modulate Color.RGBA, outline Float.X, pixel_range Float.X, scale Float.X)

Draws a textured rectangle region of the multichannel signed distance field texture at a given position, optionally modulated by a color. The 'rect' is defined in local space. See FontFile.MultichannelSignedDistanceField for more information and caveats about MSDF font rendering.

If 'outline' is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the 'outline' radius.

Value of the 'pixel_range' should the same that was used during distance field texture generation.

func (MoreArgs) DrawMultiline

func (self MoreArgs) DrawMultiline(points []Vector2.XY, color Color.RGBA, width Float.X, antialiased bool)

Draws multiple disconnected lines with a uniform 'width' and 'color'. Each line is defined by two consecutive points from 'points' array in local space, i.e. i-th segment consists of points[2 * i], points[2 * i + 1] endpoints. When drawing large amounts of lines, this is faster than using individual DrawLine calls. To draw interconnected lines, use DrawPolyline instead.

If 'width' is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

Note: 'antialiased' is only effective if 'width' is greater than 0.0.

func (MoreArgs) DrawMultilineColors

func (self MoreArgs) DrawMultilineColors(points []Vector2.XY, colors []Color.RGBA, width Float.X, antialiased bool)

Draws multiple disconnected lines with a uniform 'width' and segment-by-segment coloring. Each segment is defined by two consecutive points from 'points' array in local space and a corresponding color from 'colors' array, i.e. i-th segment consists of points[2 * i], points[2 * i + 1] endpoints and has colors[i] color. When drawing large amounts of lines, this is faster than using individual DrawLine calls. To draw interconnected lines, use DrawPolylineColors instead.

If 'width' is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

Note: 'antialiased' is only effective if 'width' is greater than 0.0.

func (MoreArgs) DrawMultilineString

func (self MoreArgs) DrawMultilineString(font Font.Instance, pos Vector2.XY, text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, max_lines int, modulate Color.RGBA, brk_flags TextServer.LineBreakFlag, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation, oversampling Float.X)

Breaks 'text' into lines and draws it using the specified 'font' at the 'pos' in local space (top-left corner). The text will have its color multiplied by 'modulate'. If 'width' is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

func (MoreArgs) DrawMultilineStringOutline

func (self MoreArgs) DrawMultilineStringOutline(font Font.Instance, pos Vector2.XY, text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, max_lines int, size int, modulate Color.RGBA, brk_flags TextServer.LineBreakFlag, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation, oversampling Float.X)

Breaks 'text' to the lines and draws text outline using the specified 'font' at the 'pos' in local space (top-left corner). The text will have its color multiplied by 'modulate'. If 'width' is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

func (MoreArgs) DrawPolygon

func (self MoreArgs) DrawPolygon(points []Vector2.XY, colors []Color.RGBA, uvs []Vector2.XY, texture Texture2D.Instance)

Draws a solid polygon of any number of points, convex or concave. Unlike DrawColoredPolygon, each point's color can be changed individually. The 'points' array is defined in local space. See also DrawPolyline and DrawPolylineColors. If you need more flexibility (such as being able to use bones), use RenderingServer.CanvasItemAddTriangleArray instead.

Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using DrawMesh, DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray.

func (MoreArgs) DrawPolyline

func (self MoreArgs) DrawPolyline(points []Vector2.XY, color Color.RGBA, width Float.X, antialiased bool)

Draws interconnected line segments with a uniform 'color' and 'width' and optional antialiasing (supported only for positive 'width'). The 'points' array is defined in local space. When drawing large amounts of lines, this is faster than using individual DrawLine calls. To draw disconnected lines, use DrawMultiline instead. See also DrawPolygon.

If 'width' is negative, it will be ignored and the polyline will be drawn using [Renderingserver.PrimitiveLineStrip]. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

func (MoreArgs) DrawPolylineColors

func (self MoreArgs) DrawPolylineColors(points []Vector2.XY, colors []Color.RGBA, width Float.X, antialiased bool)

Draws interconnected line segments with a uniform 'width', point-by-point coloring, and optional antialiasing (supported only for positive 'width'). Colors assigned to line points match by index between 'points' and 'colors', i.e. each line segment is filled with a gradient between the colors of the endpoints. The 'points' array is defined in local space. When drawing large amounts of lines, this is faster than using individual DrawLine calls. To draw disconnected lines, use DrawMultilineColors instead. See also DrawPolygon.

If 'width' is negative, it will be ignored and the polyline will be drawn using [Renderingserver.PrimitiveLineStrip]. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

func (MoreArgs) DrawPrimitive

func (self MoreArgs) DrawPrimitive(points []Vector2.XY, colors []Color.RGBA, uvs []Vector2.XY, texture Texture2D.Instance)

Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. If 0 points or more than 4 points are specified, nothing will be drawn and an error message will be printed. The 'points' array is defined in local space. See also DrawLine, DrawPolyline, DrawPolygon, and DrawRect.

func (MoreArgs) DrawRect

func (self MoreArgs) DrawRect(rect Rect2.PositionSize, color Color.RGBA, filled bool, width Float.X, antialiased bool)

Draws a rectangle. If 'filled' is true, the rectangle will be filled with the 'color' specified. If 'filled' is false, the rectangle will be drawn as a stroke with the 'color' and 'width' specified. The 'rect' is specified in local space. See also DrawTextureRect.

If 'width' is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive 'width' like 1.0.

If 'antialiased' is true, half transparent "feathers" will be attached to the boundary, making outlines smooth.

Note: 'width' is only effective if 'filled' is false.

Note: Unfilled rectangles drawn with a negative 'width' may not display perfectly. For example, corners may be missing or brighter due to overlapping lines (for a translucent 'color').

func (MoreArgs) DrawSetTransform

func (self MoreArgs) DrawSetTransform(position Vector2.XY, rotation Angle.Radians, scale Vector2.XY)

Sets a custom local transform for drawing via components. Anything drawn afterwards will be transformed by this.

Note: FontFile.Oversampling does not take 'scale' into account. This means that scaling up/down will cause bitmap fonts and rasterized (non-MSDF) dynamic fonts to appear blurry or pixelated. To ensure text remains crisp regardless of scale, you can enable MSDF font rendering by enabling ProjectSettings "gui/theme/default_font_multichannel_signed_distance_field" (applies to the default project font only), or enabling Multichannel Signed Distance Field in the import options of a DynamicFont for custom fonts. On system fonts, SystemFont.MultichannelSignedDistanceField can be enabled in the inspector.

func (MoreArgs) DrawString

func (self MoreArgs) DrawString(font Font.Instance, pos Vector2.XY, text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, modulate Color.RGBA, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation, oversampling Float.X)

Draws 'text' using the specified 'font' at the 'pos' in local space (bottom-left corner using the baseline of the font). The text will have its color multiplied by 'modulate'. If 'width' is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

Example: Draw "Hello world", using the project's default font:

// If using this method in a script that redraws constantly, move the
// `default_font` declaration to a member variable assigned in `Ready()`
// so the Control is only created once.
var defaultFont = ThemeDB.FallbackFont()
var defaultFontSize = ThemeDB.FallbackFontSize()
canvas_item.MoreArgs().DrawString(defaultFont, Vector2.New(64, 64), "Hello world", GUI.HorizontalAlignmentLeft, -1, defaultFontSize,
	Color.W3C.White, TextServer.JustificationKashida|TextServer.JustificationWordBound, 0, 0, 0)

See also Font.DrawString.

func (MoreArgs) DrawStringOutline

func (self MoreArgs) DrawStringOutline(font Font.Instance, pos Vector2.XY, text string, alignment GUI.HorizontalAlignment, width Float.X, font_size int, size int, modulate Color.RGBA, justification_flags TextServer.JustificationFlag, direction TextServer.Direction, orientation TextServer.Orientation, oversampling Float.X)

Draws 'text' outline using the specified 'font' at the 'pos' in local space (bottom-left corner using the baseline of the font). The text will have its color multiplied by 'modulate'. If 'width' is greater than or equal to 0, the text will be clipped if it exceeds the specified width. If 'oversampling' is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.

func (MoreArgs) DrawTexture

func (self MoreArgs) DrawTexture(texture Texture2D.Instance, position Vector2.XY, modulate Color.RGBA)

Draws a texture at a given position. The 'position' is defined in local space.

func (MoreArgs) DrawTextureRect

func (self MoreArgs) DrawTextureRect(texture Texture2D.Instance, rect Rect2.PositionSize, tile bool, modulate Color.RGBA, transpose bool)

Draws a textured rectangle at a given position, optionally modulated by a color. The 'rect' is defined in local space. If 'transpose' is true, the texture will have its X and Y coordinates swapped. See also DrawRect and DrawTextureRectRegion.

func (MoreArgs) DrawTextureRectRegion

func (self MoreArgs) DrawTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, src_rect Rect2.PositionSize, modulate Color.RGBA, transpose bool, clip_uv bool)

Draws a textured rectangle from a texture's region (specified by 'src_rect') at a given position in local space, optionally modulated by a color. If 'transpose' is true, the texture will have its X and Y coordinates swapped. See also DrawTextureRect.

type TextureFilter

type TextureFilter int //gd:CanvasItem.TextureFilter
const (
	// The [CanvasItem] will inherit the filter from its parent.
	//
	// [CanvasItem]: https://pkg.go.dev/graphics.gd/classdb/CanvasItem
	TextureFilterParentNode TextureFilter = 0
	// The texture filter reads from the nearest pixel only. This makes the texture look pixelated from up close, and grainy from a distance (due to mipmaps not being sampled).
	TextureFilterNearest TextureFilter = 1
	// The texture filter blends between the nearest 4 pixels. This makes the texture look smooth from up close, and grainy from a distance (due to mipmaps not being sampled).
	TextureFilterLinear TextureFilter = 2
	// The texture filter reads from the nearest pixel and blends between the nearest 2 mipmaps (or uses the nearest mipmap if [ProjectSettings] "rendering/textures/default_filters/use_nearest_mipmap_filter" is true). This makes the texture look pixelated from up close, and smooth from a distance.
	//
	// Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to [Camera2D] zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.
	//
	// [Camera2D]: https://pkg.go.dev/graphics.gd/classdb/Camera2D
	// [ProjectSettings]: https://pkg.go.dev/graphics.gd/classdb/ProjectSettings
	TextureFilterNearestWithMipmaps TextureFilter = 3
	// The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps (or uses the nearest mipmap if [ProjectSettings] "rendering/textures/default_filters/use_nearest_mipmap_filter" is true). This makes the texture look smooth from up close, and smooth from a distance.
	//
	// Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to [Camera2D] zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.
	//
	// [Camera2D]: https://pkg.go.dev/graphics.gd/classdb/Camera2D
	// [ProjectSettings]: https://pkg.go.dev/graphics.gd/classdb/ProjectSettings
	TextureFilterLinearWithMipmaps TextureFilter = 4
	// The texture filter reads from the nearest pixel and blends between 2 mipmaps (or uses the nearest mipmap if [ProjectSettings] "rendering/textures/default_filters/use_nearest_mipmap_filter" is true) based on the angle between the surface and the camera view. This makes the texture look pixelated from up close, and smooth from a distance. Anisotropic filtering improves texture quality on surfaces that are almost in line with the camera, but is slightly slower. The anisotropic filtering level can be changed by adjusting [ProjectSettings] "rendering/textures/default_filters/anisotropic_filtering_level".
	//
	// Note: This texture filter is rarely useful in 2D projects. [TextureFilterNearestWithMipmaps] is usually more appropriate in this case.
	//
	// [ProjectSettings]: https://pkg.go.dev/graphics.gd/classdb/ProjectSettings
	TextureFilterNearestWithMipmapsAnisotropic TextureFilter = 5
	// The texture filter blends between the nearest 4 pixels and blends between 2 mipmaps (or uses the nearest mipmap if [ProjectSettings] "rendering/textures/default_filters/use_nearest_mipmap_filter" is true) based on the angle between the surface and the camera view. This makes the texture look smooth from up close, and smooth from a distance. Anisotropic filtering improves texture quality on surfaces that are almost in line with the camera, but is slightly slower. The anisotropic filtering level can be changed by adjusting [ProjectSettings] "rendering/textures/default_filters/anisotropic_filtering_level".
	//
	// Note: This texture filter is rarely useful in 2D projects. [TextureFilterLinearWithMipmaps] is usually more appropriate in this case.
	//
	// [ProjectSettings]: https://pkg.go.dev/graphics.gd/classdb/ProjectSettings
	TextureFilterLinearWithMipmapsAnisotropic TextureFilter = 6
	// Represents the size of the [TextureFilter] enum.
	TextureFilterMax TextureFilter = 7
)

type TextureRepeat

type TextureRepeat int //gd:CanvasItem.TextureRepeat
const (
	// The [CanvasItem] will inherit the filter from its parent.
	//
	// [CanvasItem]: https://pkg.go.dev/graphics.gd/classdb/CanvasItem
	TextureRepeatParentNode TextureRepeat = 0
	// The texture does not repeat. Sampling the texture outside its extents will result in "stretching" of the edge pixels. You can avoid this by ensuring a 1-pixel fully transparent border on each side of the texture.
	TextureRepeatDisabled TextureRepeat = 1
	// The texture repeats when exceeding the texture's size.
	TextureRepeatEnabled TextureRepeat = 2
	// The texture repeats when the exceeding the texture's size in a "2×2 tiled mode". Repeated textures at even positions are mirrored.
	TextureRepeatMirror TextureRepeat = 3
	// Represents the size of the [TextureRepeat] enum.
	TextureRepeatMax TextureRepeat = 4
)

Jump to

Keyboard shortcuts

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