Documentation
¶
Overview ¶
Package CanvasItem provides methods for working with CanvasItem object instances.
Index ¶
- Constants
- type Advanced
- type Any
- type ClipChildrenMode
- type Expanded
- func (self Expanded) DrawAnimationSlice(animation_length Float.X, slice_begin Float.X, slice_end Float.X, ...)
- func (self Expanded) DrawArc(center Vector2.XY, radius Float.X, start_angle Angle.Radians, ...)
- func (self Expanded) DrawChar(font Font.Instance, pos Vector2.XY, char string, font_size int, ...)
- func (self Expanded) DrawCharOutline(font Font.Instance, pos Vector2.XY, char string, font_size int, size int, ...)
- func (self Expanded) DrawCircle(position Vector2.XY, radius Float.X, color Color.RGBA, filled bool, ...)
- func (self Expanded) DrawColoredPolygon(points []Vector2.XY, color Color.RGBA, uvs []Vector2.XY, ...)
- func (self Expanded) DrawDashedLine(from Vector2.XY, to Vector2.XY, color Color.RGBA, width Float.X, dash Float.X, ...)
- func (self Expanded) DrawLcdTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, ...)
- func (self Expanded) DrawLine(from Vector2.XY, to Vector2.XY, color Color.RGBA, width Float.X, ...)
- func (self Expanded) DrawMesh(mesh Mesh.Instance, texture Texture2D.Instance, transform Transform2D.OriginXY, ...)
- func (self Expanded) DrawMsdfTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, ...)
- func (self Expanded) DrawMultiline(points []Vector2.XY, color Color.RGBA, width Float.X, antialiased bool)
- func (self Expanded) DrawMultilineColors(points []Vector2.XY, colors []Color.RGBA, width Float.X, antialiased bool)
- func (self Expanded) DrawMultilineString(font Font.Instance, pos Vector2.XY, text string, ...)
- func (self Expanded) DrawMultilineStringOutline(font Font.Instance, pos Vector2.XY, text string, ...)
- func (self Expanded) DrawPolygon(points []Vector2.XY, colors []Color.RGBA, uvs []Vector2.XY, ...)
- func (self Expanded) DrawPolyline(points []Vector2.XY, color Color.RGBA, width Float.X, antialiased bool)
- func (self Expanded) DrawPolylineColors(points []Vector2.XY, colors []Color.RGBA, width Float.X, antialiased bool)
- func (self Expanded) DrawPrimitive(points []Vector2.XY, colors []Color.RGBA, uvs []Vector2.XY, ...)
- func (self Expanded) DrawRect(rect Rect2.PositionSize, color Color.RGBA, filled bool, width Float.X, ...)
- func (self Expanded) DrawSetTransform(position Vector2.XY, rotation Angle.Radians, scale Vector2.XY)
- func (self Expanded) DrawString(font Font.Instance, pos Vector2.XY, text string, ...)
- func (self Expanded) DrawStringOutline(font Font.Instance, pos Vector2.XY, text string, ...)
- func (self Expanded) DrawTexture(texture Texture2D.Instance, position Vector2.XY, modulate Color.RGBA)
- func (self Expanded) DrawTextureRect(texture Texture2D.Instance, rect Rect2.PositionSize, tile bool, ...)
- func (self Expanded) DrawTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, ...)
- type Extension
- type ID
- type Implementation
- type Instance
- func (self Instance) AsCanvasItem() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) ClipChildren() ClipChildrenMode
- func (self Instance) DrawAnimationSlice(animation_length Float.X, slice_begin Float.X, slice_end Float.X)
- func (self Instance) DrawArc(center Vector2.XY, radius Float.X, start_angle Angle.Radians, ...)
- func (self Instance) DrawChar(font Font.Instance, pos Vector2.XY, char string)
- func (self Instance) DrawCharOutline(font Font.Instance, pos Vector2.XY, char string)
- func (self Instance) DrawCircle(position Vector2.XY, radius Float.X, color Color.RGBA)
- func (self Instance) DrawColoredPolygon(points []Vector2.XY, color Color.RGBA)
- func (self Instance) DrawDashedLine(from Vector2.XY, to Vector2.XY, color Color.RGBA)
- func (self Instance) DrawEndAnimation()
- func (self Instance) DrawLcdTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, ...)
- func (self Instance) DrawLine(from Vector2.XY, to Vector2.XY, color Color.RGBA)
- func (self Instance) DrawMesh(mesh Mesh.Instance, texture Texture2D.Instance)
- func (self Instance) DrawMsdfTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, ...)
- func (self Instance) DrawMultiline(points []Vector2.XY, color Color.RGBA)
- func (self Instance) DrawMultilineColors(points []Vector2.XY, colors []Color.RGBA)
- func (self Instance) DrawMultilineString(font Font.Instance, pos Vector2.XY, text string)
- func (self Instance) DrawMultilineStringOutline(font Font.Instance, pos Vector2.XY, text string)
- func (self Instance) DrawMultimesh(multimesh MultiMesh.Instance, texture Texture2D.Instance)
- func (self Instance) DrawPolygon(points []Vector2.XY, colors []Color.RGBA)
- func (self Instance) DrawPolyline(points []Vector2.XY, color Color.RGBA)
- func (self Instance) DrawPolylineColors(points []Vector2.XY, colors []Color.RGBA)
- func (self Instance) DrawPrimitive(points []Vector2.XY, colors []Color.RGBA, uvs []Vector2.XY)
- func (self Instance) DrawRect(rect Rect2.PositionSize, color Color.RGBA)
- func (self Instance) DrawSetTransform(position Vector2.XY)
- func (self Instance) DrawSetTransformMatrix(xform Transform2D.OriginXY)
- func (self Instance) DrawString(font Font.Instance, pos Vector2.XY, text string)
- func (self Instance) DrawStringOutline(font Font.Instance, pos Vector2.XY, text string)
- func (self Instance) DrawTexture(texture Texture2D.Instance, position Vector2.XY)
- func (self Instance) DrawTextureRect(texture Texture2D.Instance, rect Rect2.PositionSize, tile bool)
- func (self Instance) DrawTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, ...)
- func (self Instance) ForceUpdateTransform()
- func (self Instance) GetCanvas() RID.Canvas
- func (self Instance) GetCanvasItem() RID.CanvasItem
- func (self Instance) GetCanvasLayerNode() CanvasLayer.Instance
- func (self Instance) GetCanvasTransform() Transform2D.OriginXY
- func (self Instance) GetGlobalMousePosition() Vector2.XY
- func (self Instance) GetGlobalTransform() Transform2D.OriginXY
- func (self Instance) GetGlobalTransformWithCanvas() Transform2D.OriginXY
- func (self Instance) GetInstanceShaderParameter(name string) any
- func (self Instance) GetLocalMousePosition() Vector2.XY
- func (self Instance) GetScreenTransform() Transform2D.OriginXY
- func (self Instance) GetTransform() Transform2D.OriginXY
- func (self Instance) GetViewportRect() Rect2.PositionSize
- func (self Instance) GetViewportTransform() Transform2D.OriginXY
- func (self Instance) GetVisibilityLayerBit(layer int) bool
- func (self Instance) GetWorld2d() World2D.Instance
- func (self Instance) Hide()
- func (self Instance) ID() ID
- func (self Instance) IsLocalTransformNotificationEnabled() bool
- func (self Instance) IsTransformNotificationEnabled() bool
- func (self Instance) IsVisibleInTree() bool
- func (self Instance) LightMask() int
- func (self Instance) MakeCanvasPositionLocal(viewport_point Vector2.XY) Vector2.XY
- func (self Instance) MakeInputLocal(event InputEvent.Instance) InputEvent.Instance
- func (self Instance) Material() Material.Instance
- func (self Instance) Modulate() Color.RGBA
- func (self Instance) MoveToFront()
- func (self Instance) OnDraw(cb func(), flags ...Signal.Flags)
- func (self Instance) OnHidden(cb func(), flags ...Signal.Flags)
- func (self Instance) OnItemRectChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) OnVisibilityChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) QueueRedraw()
- func (self Instance) SelfModulate() Color.RGBA
- func (self Instance) SetClipChildren(value ClipChildrenMode)
- func (self Instance) SetInstanceShaderParameter(name string, value any)
- func (self Instance) SetLightMask(value int)
- func (self Instance) SetMaterial(value Material.Instance)
- func (self Instance) SetModulate(value Color.RGBA)
- func (self Instance) SetNotifyLocalTransform(enable bool)
- func (self Instance) SetNotifyTransform(enable bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetSelfModulate(value Color.RGBA)
- func (self Instance) SetShowBehindParent(value bool)
- func (self Instance) SetTextureFilter(value TextureFilter)
- func (self Instance) SetTextureRepeat(value TextureRepeat)
- func (self Instance) SetTopLevel(value bool)
- func (self Instance) SetUseParentMaterial(value bool)
- func (self Instance) SetVisibilityLayer(value int)
- func (self Instance) SetVisibilityLayerBit(layer int, enabled bool)
- func (self Instance) SetVisible(value bool)
- func (self Instance) SetYSortEnabled(value bool)
- func (self Instance) SetZAsRelative(value bool)
- func (self Instance) SetZIndex(value int)
- func (self Instance) Show()
- func (self Instance) ShowBehindParent() bool
- func (self Instance) TextureFilter() TextureFilter
- func (self Instance) TextureRepeat() TextureRepeat
- func (self Instance) TopLevel() bool
- func (self Instance) UseParentMaterial() bool
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) VisibilityLayer() int
- func (self Instance) Visible() bool
- func (self Instance) YSortEnabled() bool
- func (self Instance) ZAsRelative() bool
- func (self Instance) ZIndex() int
- type Interface
- type TextureFilter
- type TextureRepeat
Constants ¶
const NotificationDraw Object.Notification = 30 //gd:CanvasItem.NOTIFICATION_DRAW
const NotificationEnterCanvas Object.Notification = 32 //gd:CanvasItem.NOTIFICATION_ENTER_CANVAS
const NotificationExitCanvas Object.Notification = 33 //gd:CanvasItem.NOTIFICATION_EXIT_CANVAS
const NotificationLocalTransformChanged Object.Notification = 35 //gd:CanvasItem.NOTIFICATION_LOCAL_TRANSFORM_CHANGED
const NotificationTransformChanged Object.Notification = 2000 //gd:CanvasItem.NOTIFICATION_TRANSFORM_CHANGED
const NotificationVisibilityChanged Object.Notification = 31 //gd:CanvasItem.NOTIFICATION_VISIBILITY_CHANGED
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 ClipChildrenMode ¶
type ClipChildrenMode int //gd:CanvasItem.ClipChildrenMode
const ( /*Child draws over parent and is not clipped.*/ ClipChildrenDisabled ClipChildrenMode = 0 /*Parent is used for the purposes of clipping only. Child is clipped to the parent's visible area, parent is not drawn.*/ ClipChildrenOnly ClipChildrenMode = 1 /*Parent is used for clipping child, but parent is also drawn underneath child as normal before clipping child to its visible area.*/ ClipChildrenAndDraw ClipChildrenMode = 2 /*Represents the size of the [enum 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 [param color] and [param width] and optional antialiasing (supported only for positive [param width]). The larger the value of [param point_count], the smoother the curve. See also [method draw_circle]. If [param width] is negative, it will be ignored and the arc will be drawn using [constant RenderingServer.PRIMITIVE_LINE_STRIP]. This means that when the CanvasItem is scaled, the arc will remain thin. If this behavior is not desired, then pass a positive [param width] like [code]1.0[/code]. The arc is drawn from [param start_angle] towards the value of [param end_angle] so in clockwise direction if [code]start_angle < end_angle[/code] and counter-clockwise otherwise. Passing the same angles but in reversed order will produce the same arc. If absolute difference of [param start_angle] and [param end_angle] is greater than [constant @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)
Draws a string first character using a custom font.
func (Expanded) DrawCharOutline ¶
func (self Expanded) DrawCharOutline(font Font.Instance, pos Vector2.XY, char string, font_size int, size int, modulate Color.RGBA)
Draws a string first character outline using a custom font.
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. See also [method draw_arc], [method draw_polyline], and [method draw_polygon]. If [param filled] is [code]true[/code], the circle will be filled with the [param color] specified. If [param filled] is [code]false[/code], the circle will be drawn as a stroke with the [param color] and [param width] specified. If [param 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 [param width] like [code]1.0[/code]. If [param antialiased] is [code]true[/code], half transparent "feathers" will be attached to the boundary, making outlines smooth. [b]Note:[/b] [param width] is only effective if [param filled] is [code]false[/code].
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. Unlike [method draw_polygon], a single color must be specified for the whole polygon. [b]Note:[/b] If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with [method Geometry2D.triangulate_polygon] and using [method draw_mesh], [method draw_multimesh], or [method RenderingServer.canvas_item_add_triangle_array].
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. See also [method draw_line], [method draw_multiline], and [method draw_polyline]. If [param 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 [param width] like [code]1.0[/code]. [param dash] is the length of each dash in pixels, with the gap between each dash being the same length. If [param aligned] is [code]true[/code], 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 [param from] and [param to]. Both ends are always symmetrical when [param aligned] is [code]true[/code]. If [param aligned] is [code]false[/code], 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 [param aligned] is [code]false[/code]. If [param antialiased] is [code]true[/code], half transparent "feathers" will be attached to the boundary, making outlines smooth. [b]Note:[/b] [param antialiased] is only effective if [param width] is greater than [code]0.0[/code].
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. Texture is drawn using the following blend operation, blend mode of the [CanvasItemMaterial] is ignored: [codeblock] 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); [/codeblock]
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. See also [method draw_dashed_line], [method draw_multiline], and [method draw_polyline]. If [param 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 [param width] like [code]1.0[/code].
func (Expanded) DrawMesh ¶
func (self Expanded) 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.
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 multi-channel signed distance field texture at a given position, optionally modulated by a color. See [member FontFile.multichannel_signed_distance_field] for more information and caveats about MSDF font rendering. If [param outline] is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the [param outline] radius. Value of the [param 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 [param width] and [param color]. Each line is defined by two consecutive points from [param points] array, i.e. i-th segment consists of [code]points[2 * i][/code], [code]points[2 * i + 1][/code] endpoints. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw interconnected lines, use [method draw_polyline] instead. If [param 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 [param width] like [code]1.0[/code]. [b]Note:[/b] [param antialiased] is only effective if [param width] is greater than [code]0.0[/code].
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 [param width] and segment-by-segment coloring. Each segment is defined by two consecutive points from [param points] array and a corresponding color from [param colors] array, i.e. i-th segment consists of [code]points[2 * i][/code], [code]points[2 * i + 1][/code] endpoints and has [code]colors[i][/code] color. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw interconnected lines, use [method draw_polyline_colors] instead. If [param 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 [param width] like [code]1.0[/code]. [b]Note:[/b] [param antialiased] is only effective if [param width] is greater than [code]0.0[/code].
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)
Breaks [param text] into lines and draws it using the specified [param font] at the [param pos] (top-left corner). The text will have its color multiplied by [param modulate]. If [param width] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
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)
Breaks [param text] to the lines and draws text outline using the specified [param font] at the [param pos] (top-left corner). The text will have its color multiplied by [param modulate]. If [param width] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
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 [method draw_colored_polygon], each point's color can be changed individually. See also [method draw_polyline] and [method draw_polyline_colors]. If you need more flexibility (such as being able to use bones), use [method RenderingServer.canvas_item_add_triangle_array] instead. [b]Note:[/b] If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with [method Geometry2D.triangulate_polygon] and using [method draw_mesh], [method draw_multimesh], or [method RenderingServer.canvas_item_add_triangle_array].
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 [param color] and [param width] and optional antialiasing (supported only for positive [param width]). When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw disconnected lines, use [method draw_multiline] instead. See also [method draw_polygon]. If [param width] is negative, it will be ignored and the polyline will be drawn using [constant RenderingServer.PRIMITIVE_LINE_STRIP]. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive [param width] like [code]1.0[/code].
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 [param width], point-by-point coloring, and optional antialiasing (supported only for positive [param width]). Colors assigned to line points match by index between [param points] and [param colors], i.e. each line segment is filled with a gradient between the colors of the endpoints. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw disconnected lines, use [method draw_multiline_colors] instead. See also [method draw_polygon]. If [param width] is negative, it will be ignored and the polyline will be drawn using [constant RenderingServer.PRIMITIVE_LINE_STRIP]. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive [param width] like [code]1.0[/code].
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. See also [method draw_line], [method draw_polyline], [method draw_polygon], and [method draw_rect].
func (Expanded) DrawRect ¶
func (self Expanded) DrawRect(rect Rect2.PositionSize, color Color.RGBA, filled bool, width Float.X, antialiased bool)
Draws a rectangle. If [param filled] is [code]true[/code], the rectangle will be filled with the [param color] specified. If [param filled] is [code]false[/code], the rectangle will be drawn as a stroke with the [param color] and [param width] specified. See also [method draw_texture_rect]. If [param 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 [param width] like [code]1.0[/code]. If [param antialiased] is [code]true[/code], half transparent "feathers" will be attached to the boundary, making outlines smooth. [b]Note:[/b] [param width] is only effective if [param filled] is [code]false[/code]. [b]Note:[/b] Unfilled rectangles drawn with a negative [param width] may not display perfectly. For example, corners may be missing or brighter due to overlapping lines (for a translucent [param color]).
func (Expanded) DrawSetTransform ¶
func (self Expanded) DrawSetTransform(position Vector2.XY, rotation Angle.Radians, scale Vector2.XY)
Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this. [b]Note:[/b] [member FontFile.oversampling] does [i]not[/i] take [param 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 [member ProjectSettings.gui/theme/default_font_multichannel_signed_distance_field] (applies to the default project font only), or enabling [b]Multichannel Signed Distance Field[/b] in the import options of a DynamicFont for custom fonts. On system fonts, [member SystemFont.multichannel_signed_distance_field] 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)
Draws [param text] using the specified [param font] at the [param pos] (bottom-left corner using the baseline of the font). The text will have its color multiplied by [param modulate]. If [param width] is greater than or equal to 0, the text will be clipped if it exceeds the specified width. [b]Example:[/b] Draw "Hello world", using the project's default font: [codeblocks] [gdscript] # 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 default_font = ThemeDB.fallback_font var default_font_size = ThemeDB.fallback_font_size draw_string(default_font, Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, default_font_size) [/gdscript] [csharp] // 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. Font defaultFont = ThemeDB.FallbackFont; int defaultFontSize = ThemeDB.FallbackFontSize; DrawString(defaultFont, new Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, defaultFontSize); [/csharp] [/codeblocks] See also [method Font.draw_string].
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)
Draws [param text] outline using the specified [param font] at the [param pos] (bottom-left corner using the baseline of the font). The text will have its color multiplied by [param modulate]. If [param width] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
func (Expanded) DrawTexture ¶
func (self Expanded) DrawTexture(texture Texture2D.Instance, position Vector2.XY, modulate Color.RGBA)
Draws a texture at a given position.
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. If [param transpose] is [code]true[/code], the texture will have its X and Y coordinates swapped. See also [method draw_rect] and [method draw_texture_rect_region].
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 [param src_rect]) at a given position, optionally modulated by a color. If [param transpose] is [code]true[/code], the texture will have its X and Y coordinates swapped. See also [method draw_texture_rect].
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsCanvasItem ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
type Instance [1]gdclass.CanvasItem
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, [method queue_redraw] is called by the engine, then [constant NOTIFICATION_DRAW] 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 [code]draw_*[/code] functions). However, they can only be used inside [method _draw], its corresponding [method Object._notification] or methods connected to the [signal draw] 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 [member modulate] or [member self_modulate]), change its Z-index, blend mode, and more. Note that properties like transform, modulation, and visibility are only propagated to [i]direct[/i] [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 [member modulate] chain. See also [member top_level].
See [Interface] for methods that can be overridden by a [Class] that extends it.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsCanvasItem ¶
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 [param color] and [param width] and optional antialiasing (supported only for positive [param width]). The larger the value of [param point_count], the smoother the curve. See also [method draw_circle]. If [param width] is negative, it will be ignored and the arc will be drawn using [constant RenderingServer.PRIMITIVE_LINE_STRIP]. This means that when the CanvasItem is scaled, the arc will remain thin. If this behavior is not desired, then pass a positive [param width] like [code]1.0[/code]. The arc is drawn from [param start_angle] towards the value of [param end_angle] so in clockwise direction if [code]start_angle < end_angle[/code] and counter-clockwise otherwise. Passing the same angles but in reversed order will produce the same arc. If absolute difference of [param start_angle] and [param end_angle] is greater than [constant @GDScript.TAU] radians, then a full circle arc is drawn (i.e. arc will not overlap itself).
func (Instance) DrawCharOutline ¶
Draws a string first character outline using a custom font.
func (Instance) DrawCircle ¶
Draws a circle. See also [method draw_arc], [method draw_polyline], and [method draw_polygon]. If [param filled] is [code]true[/code], the circle will be filled with the [param color] specified. If [param filled] is [code]false[/code], the circle will be drawn as a stroke with the [param color] and [param width] specified. If [param 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 [param width] like [code]1.0[/code]. If [param antialiased] is [code]true[/code], half transparent "feathers" will be attached to the boundary, making outlines smooth. [b]Note:[/b] [param width] is only effective if [param filled] is [code]false[/code].
func (Instance) DrawColoredPolygon ¶
Draws a colored polygon of any number of points, convex or concave. Unlike [method draw_polygon], a single color must be specified for the whole polygon. [b]Note:[/b] If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with [method Geometry2D.triangulate_polygon] and using [method draw_mesh], [method draw_multimesh], or [method RenderingServer.canvas_item_add_triangle_array].
func (Instance) DrawDashedLine ¶
Draws a dashed line from a 2D point to another, with a given color and width. See also [method draw_line], [method draw_multiline], and [method draw_polyline]. If [param 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 [param width] like [code]1.0[/code]. [param dash] is the length of each dash in pixels, with the gap between each dash being the same length. If [param aligned] is [code]true[/code], 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 [param from] and [param to]. Both ends are always symmetrical when [param aligned] is [code]true[/code]. If [param aligned] is [code]false[/code], 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 [param aligned] is [code]false[/code]. If [param antialiased] is [code]true[/code], half transparent "feathers" will be attached to the boundary, making outlines smooth. [b]Note:[/b] [param antialiased] is only effective if [param width] is greater than [code]0.0[/code].
func (Instance) DrawEndAnimation ¶
func (self Instance) DrawEndAnimation()
After submitting all animations slices via [method draw_animation_slice], 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. Texture is drawn using the following blend operation, blend mode of the [CanvasItemMaterial] is ignored: [codeblock] 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); [/codeblock]
func (Instance) DrawLine ¶
Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. See also [method draw_dashed_line], [method draw_multiline], and [method draw_polyline]. If [param 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 [param width] like [code]1.0[/code].
func (Instance) DrawMesh ¶
Draws a [Mesh] in 2D, using the provided texture. See [MeshInstance2D] for related documentation.
func (Instance) DrawMsdfTextureRectRegion ¶
func (self Instance) DrawMsdfTextureRectRegion(texture Texture2D.Instance, rect Rect2.PositionSize, src_rect Rect2.PositionSize)
Draws a textured rectangle region of the multi-channel signed distance field texture at a given position, optionally modulated by a color. See [member FontFile.multichannel_signed_distance_field] for more information and caveats about MSDF font rendering. If [param outline] is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the [param outline] radius. Value of the [param pixel_range] should the same that was used during distance field texture generation.
func (Instance) DrawMultiline ¶
Draws multiple disconnected lines with a uniform [param width] and [param color]. Each line is defined by two consecutive points from [param points] array, i.e. i-th segment consists of [code]points[2 * i][/code], [code]points[2 * i + 1][/code] endpoints. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw interconnected lines, use [method draw_polyline] instead. If [param 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 [param width] like [code]1.0[/code]. [b]Note:[/b] [param antialiased] is only effective if [param width] is greater than [code]0.0[/code].
func (Instance) DrawMultilineColors ¶
Draws multiple disconnected lines with a uniform [param width] and segment-by-segment coloring. Each segment is defined by two consecutive points from [param points] array and a corresponding color from [param colors] array, i.e. i-th segment consists of [code]points[2 * i][/code], [code]points[2 * i + 1][/code] endpoints and has [code]colors[i][/code] color. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw interconnected lines, use [method draw_polyline_colors] instead. If [param 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 [param width] like [code]1.0[/code]. [b]Note:[/b] [param antialiased] is only effective if [param width] is greater than [code]0.0[/code].
func (Instance) DrawMultilineString ¶
Breaks [param text] into lines and draws it using the specified [param font] at the [param pos] (top-left corner). The text will have its color multiplied by [param modulate]. If [param width] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
func (Instance) DrawMultilineStringOutline ¶
Breaks [param text] to the lines and draws text outline using the specified [param font] at the [param pos] (top-left corner). The text will have its color multiplied by [param modulate]. If [param width] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
func (Instance) DrawMultimesh ¶
Draws a [MultiMesh] in 2D with the provided texture. See [MultiMeshInstance2D] for related documentation.
func (Instance) DrawPolygon ¶
Draws a solid polygon of any number of points, convex or concave. Unlike [method draw_colored_polygon], each point's color can be changed individually. See also [method draw_polyline] and [method draw_polyline_colors]. If you need more flexibility (such as being able to use bones), use [method RenderingServer.canvas_item_add_triangle_array] instead. [b]Note:[/b] If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with [method Geometry2D.triangulate_polygon] and using [method draw_mesh], [method draw_multimesh], or [method RenderingServer.canvas_item_add_triangle_array].
func (Instance) DrawPolyline ¶
Draws interconnected line segments with a uniform [param color] and [param width] and optional antialiasing (supported only for positive [param width]). When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw disconnected lines, use [method draw_multiline] instead. See also [method draw_polygon]. If [param width] is negative, it will be ignored and the polyline will be drawn using [constant RenderingServer.PRIMITIVE_LINE_STRIP]. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive [param width] like [code]1.0[/code].
func (Instance) DrawPolylineColors ¶
Draws interconnected line segments with a uniform [param width], point-by-point coloring, and optional antialiasing (supported only for positive [param width]). Colors assigned to line points match by index between [param points] and [param colors], i.e. each line segment is filled with a gradient between the colors of the endpoints. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw disconnected lines, use [method draw_multiline_colors] instead. See also [method draw_polygon]. If [param width] is negative, it will be ignored and the polyline will be drawn using [constant RenderingServer.PRIMITIVE_LINE_STRIP]. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive [param width] like [code]1.0[/code].
func (Instance) DrawPrimitive ¶
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. See also [method draw_line], [method draw_polyline], [method draw_polygon], and [method draw_rect].
func (Instance) DrawRect ¶
func (self Instance) DrawRect(rect Rect2.PositionSize, color Color.RGBA)
Draws a rectangle. If [param filled] is [code]true[/code], the rectangle will be filled with the [param color] specified. If [param filled] is [code]false[/code], the rectangle will be drawn as a stroke with the [param color] and [param width] specified. See also [method draw_texture_rect]. If [param 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 [param width] like [code]1.0[/code]. If [param antialiased] is [code]true[/code], half transparent "feathers" will be attached to the boundary, making outlines smooth. [b]Note:[/b] [param width] is only effective if [param filled] is [code]false[/code]. [b]Note:[/b] Unfilled rectangles drawn with a negative [param width] may not display perfectly. For example, corners may be missing or brighter due to overlapping lines (for a translucent [param color]).
func (Instance) DrawSetTransform ¶
Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this. [b]Note:[/b] [member FontFile.oversampling] does [i]not[/i] take [param 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 [member ProjectSettings.gui/theme/default_font_multichannel_signed_distance_field] (applies to the default project font only), or enabling [b]Multichannel Signed Distance Field[/b] in the import options of a DynamicFont for custom fonts. On system fonts, [member SystemFont.multichannel_signed_distance_field] can be enabled in the inspector.
func (Instance) DrawSetTransformMatrix ¶
func (self Instance) DrawSetTransformMatrix(xform Transform2D.OriginXY)
Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
func (Instance) DrawString ¶
Draws [param text] using the specified [param font] at the [param pos] (bottom-left corner using the baseline of the font). The text will have its color multiplied by [param modulate]. If [param width] is greater than or equal to 0, the text will be clipped if it exceeds the specified width. [b]Example:[/b] Draw "Hello world", using the project's default font: [codeblocks] [gdscript] # 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 default_font = ThemeDB.fallback_font var default_font_size = ThemeDB.fallback_font_size draw_string(default_font, Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, default_font_size) [/gdscript] [csharp] // 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. Font defaultFont = ThemeDB.FallbackFont; int defaultFontSize = ThemeDB.FallbackFontSize; DrawString(defaultFont, new Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, defaultFontSize); [/csharp] [/codeblocks] See also [method Font.draw_string].
func (Instance) DrawStringOutline ¶
Draws [param text] outline using the specified [param font] at the [param pos] (bottom-left corner using the baseline of the font). The text will have its color multiplied by [param modulate]. If [param width] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
func (Instance) DrawTexture ¶
Draws a texture at a given position.
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. If [param transpose] is [code]true[/code], the texture will have its X and Y coordinates swapped. See also [method draw_rect] and [method draw_texture_rect_region].
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 [param src_rect]) at a given position, optionally modulated by a color. If [param transpose] is [code]true[/code], the texture will have its X and Y coordinates swapped. See also [method draw_texture_rect].
func (Instance) ForceUpdateTransform ¶
func (self Instance) ForceUpdateTransform()
Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.
func (Instance) GetCanvasItem ¶
func (self Instance) GetCanvasItem() RID.CanvasItem
Returns the canvas item RID used by [RenderingServer] for this item.
func (Instance) GetCanvasLayerNode ¶
func (self Instance) GetCanvasLayerNode() CanvasLayer.Instance
Returns the [CanvasLayer] that contains this node, or [code]null[/code] if the node is not in any [CanvasLayer].
func (Instance) GetCanvasTransform ¶
func (self Instance) GetCanvasTransform() Transform2D.OriginXY
Returns the transform from the coordinate system of the canvas, this item is in, to the [Viewport]s coordinate system.
func (Instance) GetGlobalMousePosition ¶
Returns the mouse's position in the [CanvasLayer] that this [CanvasItem] is in using the coordinate system of the [CanvasLayer]. [b]Note:[/b] For screen-space coordinates (e.g. when using a non-embedded [Popup]), you can use [method DisplayServer.mouse_get_position].
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 [member top_level] enabled.
func (Instance) GetGlobalTransformWithCanvas ¶
func (self Instance) GetGlobalTransformWithCanvas() Transform2D.OriginXY
Returns the transform from the local coordinate system of this [CanvasItem] to the [Viewport]s coordinate system.
func (Instance) GetInstanceShaderParameter ¶
Get the value of a shader parameter as set on this instance.
func (Instance) GetLocalMousePosition ¶
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 [method get_global_transform] if the window is embedded (see [member Viewport.gui_embed_subwindows]).
func (Instance) GetTransform ¶
func (self Instance) GetTransform() Transform2D.OriginXY
Returns the transform matrix of this item.
func (Instance) GetViewportRect ¶
func (self Instance) GetViewportRect() Rect2.PositionSize
Returns the viewport's boundaries as a [Rect2].
func (Instance) GetViewportTransform ¶
func (self Instance) GetViewportTransform() Transform2D.OriginXY
Returns the transform from the coordinate system of the canvas, this item is in, to the [Viewport]s embedders coordinate system.
func (Instance) GetVisibilityLayerBit ¶
Returns an individual bit on the rendering visibility layer.
func (Instance) GetWorld2d ¶
Returns the [World2D] where this item is in.
func (Instance) Hide ¶
func (self Instance) Hide()
Hide the [CanvasItem] if it's currently visible. This is equivalent to setting [member visible] to [code]false[/code].
func (Instance) IsLocalTransformNotificationEnabled ¶
Returns [code]true[/code] if local transform notifications are communicated to children.
func (Instance) IsTransformNotificationEnabled ¶
Returns [code]true[/code] if global transform notifications are communicated to children.
func (Instance) IsVisibleInTree ¶
Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] 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 [method _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. [b]Note:[/b] This method does not take [member visibility_layer] into account, so even if this method returns [code]true[/code], the node might end up not being rendered.
func (Instance) MakeCanvasPositionLocal ¶
Transforms [param viewport_point] from the viewport's coordinates to this node's local coordinates. For the opposite operation, use [method get_global_transform_with_canvas]. [codeblock] var viewport_point = get_global_transform_with_canvas() * local_point [/codeblock]
func (Instance) MakeInputLocal ¶
func (self Instance) MakeInputLocal(event InputEvent.Instance) InputEvent.Instance
Transformations issued by [param event]'s inputs are applied in local space instead of global space.
func (Instance) MoveToFront ¶
func (self Instance) MoveToFront()
Moves this node to display on top of its siblings. Internally, the node is moved to the bottom of parent's child list. The method has no effect on nodes without a parent.
func (Instance) OnItemRectChanged ¶
func (Instance) OnVisibilityChanged ¶
func (Instance) QueueRedraw ¶
func (self Instance) QueueRedraw()
Queues the [CanvasItem] to redraw. During idle time, if [CanvasItem] is visible, [constant NOTIFICATION_DRAW] is sent and [method _draw] is called. This only occurs [b]once[/b] per frame, even if this method has been called multiple times.
func (Instance) SelfModulate ¶
func (Instance) SetClipChildren ¶
func (self Instance) SetClipChildren(value ClipChildrenMode)
func (Instance) SetInstanceShaderParameter ¶
Set the value of a shader uniform for this instance only ([url=$DOCS_URL/tutorials/shaders/shader_reference/shading_language.html#per-instance-uniforms]per-instance uniform[/url]). See also [method ShaderMaterial.set_shader_parameter] to assign a uniform on all instances using the same [ShaderMaterial]. [b]Note:[/b] For a shader uniform to be assignable on a per-instance basis, it [i]must[/i] be defined with [code]instance uniform ...[/code] rather than [code]uniform ...[/code] in the shader code. [b]Note:[/b] [param 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 (Instance) SetMaterial ¶
func (Instance) SetModulate ¶
func (Instance) SetNotifyLocalTransform ¶
If [param enable] is [code]true[/code], this node will receive [constant NOTIFICATION_LOCAL_TRANSFORM_CHANGED] when its local transform changes.
func (Instance) SetNotifyTransform ¶
If [param enable] is [code]true[/code], this node will receive [constant NOTIFICATION_TRANSFORM_CHANGED] when its global transform changes.
func (Instance) SetSelfModulate ¶
func (Instance) SetShowBehindParent ¶
func (Instance) SetTextureFilter ¶
func (self Instance) SetTextureFilter(value TextureFilter)
func (Instance) SetTextureRepeat ¶
func (self Instance) SetTextureRepeat(value TextureRepeat)
func (Instance) SetTopLevel ¶
func (Instance) SetUseParentMaterial ¶
func (Instance) SetVisibilityLayer ¶
func (Instance) SetVisibilityLayerBit ¶
Set/clear individual bits on the rendering visibility layer. This simplifies editing this [CanvasItem]'s visibility layer.
func (Instance) SetVisible ¶
func (Instance) SetYSortEnabled ¶
func (Instance) SetZAsRelative ¶
func (Instance) Show ¶
func (self Instance) Show()
Show the [CanvasItem] if it's currently hidden. This is equivalent to setting [member visible] to [code]true[/code]. For controls that inherit [Popup], the correct way to make them visible is to call one of the multiple [code]popup*()[/code] functions instead.
func (Instance) ShowBehindParent ¶
func (Instance) TextureFilter ¶
func (self Instance) TextureFilter() TextureFilter
func (Instance) TextureRepeat ¶
func (self Instance) TextureRepeat() TextureRepeat
func (Instance) UseParentMaterial ¶
func (Instance) VisibilityLayer ¶
func (Instance) YSortEnabled ¶
func (Instance) ZAsRelative ¶
type Interface ¶
type Interface interface { //Called when [CanvasItem] has been requested to redraw (after [method queue_redraw] is called, either manually or by the engine). //Corresponds to the [constant NOTIFICATION_DRAW] notification in [method Object._notification]. Draw() }
type TextureFilter ¶
type TextureFilter int //gd:CanvasItem.TextureFilter
const ( /*The [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 [member ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter] is [code]true[/code]). 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.*/ TextureFilterNearestWithMipmaps TextureFilter = 3 /*The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps (or uses the nearest mipmap if [member ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter] is [code]true[/code]). 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.*/ TextureFilterLinearWithMipmaps TextureFilter = 4 /*The texture filter reads from the nearest pixel and blends between 2 mipmaps (or uses the nearest mipmap if [member ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter] is [code]true[/code]) 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 [member ProjectSettings.rendering/textures/default_filters/anisotropic_filtering_level]. [b]Note:[/b] This texture filter is rarely useful in 2D projects. [constant TEXTURE_FILTER_NEAREST_WITH_MIPMAPS] 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 [member ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter] is [code]true[/code]) 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 [member ProjectSettings.rendering/textures/default_filters/anisotropic_filtering_level]. [b]Note:[/b] This texture filter is rarely useful in 2D projects. [constant TEXTURE_FILTER_LINEAR_WITH_MIPMAPS] is usually more appropriate in this case.*/ TextureFilterLinearWithMipmapsAnisotropic TextureFilter = 6 /*Represents the size of the [enum TextureFilter] enum.*/ TextureFilterMax TextureFilter = 7 )
type TextureRepeat ¶
type TextureRepeat int //gd:CanvasItem.TextureRepeat
const ( /*The [CanvasItem] will inherit the filter from its parent.*/ TextureRepeatParentNode TextureRepeat = 0 /*Texture will not repeat.*/ TextureRepeatDisabled TextureRepeat = 1 /*Texture will repeat normally.*/ TextureRepeatEnabled TextureRepeat = 2 /*Texture will repeat in a 2×2 tiled mode, where elements at even positions are mirrored.*/ TextureRepeatMirror TextureRepeat = 3 /*Represents the size of the [enum TextureRepeat] enum.*/ TextureRepeatMax TextureRepeat = 4 )