CanvasItem

package
v0.0.0-...-0d6c339 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 37 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. graphics.gd/classdb/CanvasItem is extended by graphics.gd/classdb/Control for GUI-related nodes, and by graphics.gd/classdb/Node2D for 2D game objects.

Any graphics.gd/classdb/CanvasItem can draw. For this, Instance.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 graphics.gd/classdb/CanvasItem are provided (see draw_* functions). However, they can only be used inside [Interface.Draw], its corresponding graphics.gd/classdb/Object.Instance.Notification or methods connected to the Instance.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 graphics.gd/classdb/CanvasItem will be drawn behind everything. This behavior can be changed on a per-item basis.

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

Note that properties like transform, modulation, and visibility are only propagated to direct graphics.gd/classdb/CanvasItem child nodes. If there is a non-graphics.gd/classdb/CanvasItem node in between, like graphics.gd/classdb/Node or graphics.gd/classdb/AnimationPlayer, the graphics.gd/classdb/CanvasItem nodes below will have an independent position and Instance.Modulate chain. See also Instance.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 [1]gdclass.CanvasItem

func (Expanded) DrawAnimationSlice

func (self Expanded) 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 (Expanded) DrawArc

func (self Expanded) 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 Instance.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 (Expanded) DrawChar

func (self Expanded) 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 (Expanded) DrawCharOutline

func (self Expanded) 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 (Expanded) DrawCircle

func (self Expanded) 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 Instance.DrawArc, Instance.DrawPolyline, and Instance.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 (Expanded) DrawColoredPolygon

func (self Expanded) 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 Instance.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 graphics.gd/classdb/Geometry2D.TriangulatePolygon and using Instance.DrawMesh, Instance.DrawMultimesh, or graphics.gd/classdb/RenderingServer.CanvasItemAddTriangleArray.

func (Expanded) DrawDashedLine

func (self Expanded) 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 Instance.DrawLine, Instance.DrawMultiline, and Instance.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 (Expanded) DrawLcdTextureRectRegion

func (self Expanded) 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 graphics.gd/classdb/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 (Expanded) DrawLine

func (self Expanded) 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 Instance.DrawDashedLine, Instance.DrawMultiline, and Instance.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 (Expanded) DrawMesh

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

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

func (Expanded) DrawMsdfTextureRectRegion

func (self Expanded) 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 graphics.gd/classdb/FontFile.Instance.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 (Expanded) DrawMultiline

func (self Expanded) 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 Instance.DrawLine calls. To draw interconnected lines, use Instance.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 (Expanded) DrawMultilineColors

func (self Expanded) 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 Instance.DrawLine calls. To draw interconnected lines, use Instance.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 (Expanded) DrawMultilineString

func (self Expanded) 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 (Expanded) DrawMultilineStringOutline

func (self Expanded) 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 (Expanded) DrawPolygon

func (self Expanded) 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 Instance.DrawColoredPolygon, each point's color can be changed individually. The 'points' array is defined in local space. See also Instance.DrawPolyline and Instance.DrawPolylineColors. If you need more flexibility (such as being able to use bones), use graphics.gd/classdb/RenderingServer.CanvasItemAddTriangleArray instead.

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

func (Expanded) DrawPolyline

func (self Expanded) 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 Instance.DrawLine calls. To draw disconnected lines, use Instance.DrawMultiline instead. See also Instance.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 (Expanded) DrawPolylineColors

func (self Expanded) 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 Instance.DrawLine calls. To draw disconnected lines, use Instance.DrawMultilineColors instead. See also Instance.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 (Expanded) DrawPrimitive

func (self Expanded) 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 Instance.DrawLine, Instance.DrawPolyline, Instance.DrawPolygon, and Instance.DrawRect.

func (Expanded) DrawRect

func (self Expanded) 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 Instance.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 (Expanded) DrawSetTransform

func (self Expanded) 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: graphics.gd/classdb/FontFile.Instance.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 graphics.gd/classdb/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, graphics.gd/classdb/SystemFont.Instance.MultichannelSignedDistanceField can be enabled in the inspector.

func (Expanded) DrawString

func (self Expanded) 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()
CanvasItem.Expanded(canvas_item).DrawString(defaultFont, Vector2.New(64, 64), "Hello world", GUI.HorizontalAlignmentLeft, -1, defaultFontSize,
	Color.W3C.White, TextServer.JustificationKashida|TextServer.JustificationWordBound, 0, 0, 0)

See also graphics.gd/classdb/Font.Instance.DrawString.

func (Expanded) DrawStringOutline

func (self Expanded) 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 (Expanded) DrawTexture

func (self Expanded) 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 (Expanded) DrawTextureRect

func (self Expanded) 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 Instance.DrawRect and Instance.DrawTextureRectRegion.

func (Expanded) DrawTextureRectRegion

func (self Expanded) 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 Instance.DrawTextureRect.

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 Instance.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 Instance.DrawArc, Instance.DrawPolyline, and Instance.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 Instance.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 graphics.gd/classdb/Geometry2D.TriangulatePolygon and using Instance.DrawMesh, Instance.DrawMultimesh, or graphics.gd/classdb/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 Instance.DrawLine, Instance.DrawMultiline, and Instance.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 Instance.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 graphics.gd/classdb/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 Instance.DrawDashedLine, Instance.DrawMultiline, and Instance.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 graphics.gd/classdb/Mesh in 2D, using the provided texture. See graphics.gd/classdb/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 graphics.gd/classdb/FontFile.Instance.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 Instance.DrawLine calls. To draw interconnected lines, use Instance.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 Instance.DrawLine calls. To draw interconnected lines, use Instance.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 graphics.gd/classdb/MultiMesh in 2D with the provided texture. See graphics.gd/classdb/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 Instance.DrawColoredPolygon, each point's color can be changed individually. The 'points' array is defined in local space. See also Instance.DrawPolyline and Instance.DrawPolylineColors. If you need more flexibility (such as being able to use bones), use graphics.gd/classdb/RenderingServer.CanvasItemAddTriangleArray instead.

Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with graphics.gd/classdb/Geometry2D.TriangulatePolygon and using Instance.DrawMesh, Instance.DrawMultimesh, or graphics.gd/classdb/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 Instance.DrawLine calls. To draw disconnected lines, use Instance.DrawMultiline instead. See also Instance.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 Instance.DrawLine calls. To draw disconnected lines, use Instance.DrawMultilineColors instead. See also Instance.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 Instance.DrawLine, Instance.DrawPolyline, Instance.DrawPolygon, and Instance.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 Instance.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: graphics.gd/classdb/FontFile.Instance.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 graphics.gd/classdb/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, graphics.gd/classdb/SystemFont.Instance.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()
CanvasItem.Expanded(canvas_item).DrawString(defaultFont, Vector2.New(64, 64), "Hello world", GUI.HorizontalAlignmentLeft, -1, defaultFontSize,
	Color.W3C.White, TextServer.JustificationKashida|TextServer.JustificationWordBound, 0, 0, 0)

See also graphics.gd/classdb/Font.Instance.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 Instance.DrawRect and Instance.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 Instance.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 Instance.GetTransform.

Note: For performance reasons, transform changes are usually accumulated and applied once at the end of the frame. The update propagates through graphics.gd/classdb/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 graphics.gd/classdb/World2D canvas where this node is registered to, used by the graphics.gd/classdb/RenderingServer.

func (Instance) GetCanvasItem

func (self Instance) GetCanvasItem() RID.CanvasItem

Returns the internal canvas item [Resource.ID] used by the graphics.gd/classdb/RenderingServer for this node.

func (Instance) GetCanvasLayerNode

func (self Instance) GetCanvasLayerNode() CanvasLayer.Instance

Returns the graphics.gd/classdb/CanvasLayer that contains this node, or null if the node is not in any graphics.gd/classdb/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 graphics.gd/classdb/Node.Instance.GetViewport.

func (Instance) GetGlobalMousePosition

func (self Instance) GetGlobalMousePosition() Vector2.XY

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

Note: For screen-space coordinates (e.g. when using a non-embedded graphics.gd/classdb/Popup), you can use graphics.gd/classdb/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 graphics.gd/classdb/CanvasItem node. The topmost item is a graphics.gd/classdb/CanvasItem that either has no parent, has non-graphics.gd/classdb/CanvasItem parent or it has Instance.TopLevel enabled.

func (Instance) GetGlobalTransformWithCanvas

func (self Instance) GetGlobalTransformWithCanvas() Transform2D.OriginXY

Returns the transform from the local coordinate system of this graphics.gd/classdb/CanvasItem to the [graphics.gd/classdb/Viewport]s 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 graphics.gd/classdb/CanvasItem using the local coordinate system of this graphics.gd/classdb/CanvasItem.

func (Instance) GetScreenTransform

func (self Instance) GetScreenTransform() Transform2D.OriginXY

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

Equals to Instance.GetGlobalTransform if the window is embedded (see graphics.gd/classdb/Viewport.Instance.GuiEmbedSubwindows).

func (Instance) GetTransform

func (self Instance) GetTransform() Transform2D.OriginXY

Returns the transform matrix of this graphics.gd/classdb/CanvasItem.

func (Instance) GetViewportRect

func (self Instance) GetViewportRect() Rect2.PositionSize

Returns this node's viewport boundaries as a [Rect2.PositionSize]. See also graphics.gd/classdb/Node.Instance.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 graphics.gd/classdb/Viewport.Instance.GetFinalTransform and graphics.gd/classdb/Node.Instance.GetViewport.

func (Instance) GetVisibilityLayerBit

func (self Instance) GetVisibilityLayerBit(layer int) bool

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

func (Instance) GetWorld2d

func (self Instance) GetWorld2d() World2D.Instance

Returns the graphics.gd/classdb/World2D this node is registered to.

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

func (Instance) Hide

func (self Instance) Hide()

Hide the graphics.gd/classdb/CanvasItem if it's currently visible. This is equivalent to setting Instance.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 Instance.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 Instance.SetNotifyTransform.

func (Instance) IsVisibleInTree

func (self Instance) IsVisibleInTree() bool

Returns true if the node is present in the graphics.gd/classdb/SceneTree, its Instance.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 [Interface.Draw]).

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

Note: This method does not take Instance.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 Instance.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 graphics.gd/classdb/CanvasItem's local space. If not possible, returns the same graphics.gd/classdb/InputEvent unchanged.

func (Instance) Material

func (self Instance) Material() Material.Instance

func (Instance) Modulate

func (self Instance) Modulate() Color.RGBA

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 graphics.gd/classdb/Node.Instance.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 graphics.gd/classdb/CanvasItem to redraw. During idle time, if graphics.gd/classdb/CanvasItem is visible, NotificationDraw is sent and [Interface.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 graphics.gd/classdb/ShaderMaterial.Instance.SetShaderParameter to assign a uniform on all instances using the same graphics.gd/classdb/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 graphics.gd/classdb/Bone2D or graphics.gd/classdb/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 graphics.gd/classdb/Camera2D or graphics.gd/classdb/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 graphics.gd/classdb/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 graphics.gd/classdb/CanvasItem if it's currently hidden. This is equivalent to setting Instance.Visible to true.

Note: For controls that inherit graphics.gd/classdb/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 [graphics.gd/classdb/CanvasItem] has been requested to redraw (after [Instance.QueueRedraw] is called, either manually or by the engine).
	//
	// Corresponds to the [NotificationDraw] notification in [graphics.gd/classdb/Object.Instance.Notification].
	Draw()
}

type TextureFilter

type TextureFilter int //gd:CanvasItem.TextureFilter
const (
	// The [graphics.gd/classdb/CanvasItem] will inherit the filter from its parent.
	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 [graphics.gd/classdb/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 [graphics.gd/classdb/Camera2D] zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.
	TextureFilterNearestWithMipmaps TextureFilter = 3
	// The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps (or uses the nearest mipmap if [graphics.gd/classdb/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 [graphics.gd/classdb/Camera2D] zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.
	TextureFilterLinearWithMipmaps TextureFilter = 4
	// The texture filter reads from the nearest pixel and blends between 2 mipmaps (or uses the nearest mipmap if [graphics.gd/classdb/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 [graphics.gd/classdb/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.
	TextureFilterNearestWithMipmapsAnisotropic TextureFilter = 5
	// The texture filter blends between the nearest 4 pixels and blends between 2 mipmaps (or uses the nearest mipmap if [graphics.gd/classdb/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 [graphics.gd/classdb/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.
	TextureFilterLinearWithMipmapsAnisotropic TextureFilter = 6
	// Represents the size of the [TextureFilter] enum.
	TextureFilterMax TextureFilter = 7
)

type TextureRepeat

type TextureRepeat int //gd:CanvasItem.TextureRepeat
const (
	// The [graphics.gd/classdb/CanvasItem] will inherit the filter from its parent.
	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