reckfellENGINE

CanvasItem

Abstract base class for everything in 2D space.

On this page
class CanvasItemReckfellSharpInherits Entity

Abstract base class for everything in 2D space.

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 Entity2D for 2D game objects. Any CanvasItem can draw. For this, CanvasItem.QueueRedraw is called by the engine, then CanvasItem.NotificationDraw will be received on idle time to request a redraw. Because of this, canvas items don't need to be redrawn on every frame, improving the performance significantly. Several functions for drawing on the CanvasItem are provided (see draw_* functions). However, they can only be used inside CanvasItem.Draw, its corresponding ReckfellObject.Notification or methods connected to the CanvasItem.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 CanvasItem.Modulate or CanvasItem.SelfModulate), change its Z-index, blend mode, and more. Note that properties like transform, modulation, and visibility are only propagated to direct CanvasItem child nodes. If there is a non-CanvasItem node in between, like Entity or AnimationPlayer, the CanvasItem nodes below will have an independent position and CanvasItem.Modulate chain. See also CanvasItem.TopLevel.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Properties16

ClipChildrenProperty
# ClipChildren
C#
public CanvasItem.ClipChildrenMode ClipChildren { get; set; }

The mode in which this node clips its children, acting as a mask. Note: Clipping nodes cannot be nested or placed within a CanvasGroup. If an ancestor of this node clips its children or is a CanvasGroup, then this node's clip mode should be set to CanvasItem.ClipChildrenMode.Disabled to avoid unexpected behavior.

LightMaskProperty
# LightMask
C#
public int LightMask { get; set; }

The rendering layers in which this CanvasItem responds to Light2D nodes.

MaterialProperty
# Material
C#
public Material Material { get; set; }

The 2D item’s own material: CanvasItemMaterial or a ShaderMaterial with a canvas_item program. UseParentMaterial=true selects the parent material instead. Items sharing one ShaderMaterial share its regular uniforms.

ModulateProperty
# Modulate
C#
public Color Modulate { get; set; }

Color multiplier for the item and inheriting CanvasItem descendants. Account for modulation in a custom shader: the example passes vertex-stage COLOR through a varying and multiplies the separately sampled texture by it. Otherwise assigning fragment-stage COLOR can discard the intended multiplication.

OversamplingWithScaleProperty
# OversamplingWithScale
C#
public CanvasItem.OversamplingWithScaleEnum OversamplingWithScale { get; set; }

If enabled, oversampling for this CanvasItem is automatically adjusted with scale. This makes fonts and DpiTexture images automatically re-render to match the actual scale they are drawn at, for crisper visuals. This has a performance impact on the CPU every time the node's scale changes, so it is disabled by default. Note: For Control nodes with Control.OffsetTransformEnabled set to true, scale-based oversampling is only effective if Control.OffsetTransformVisualOnly is false. This ensures there is no performance overhead when using visual-only offset transforms (as often used in animations).

SelfModulateProperty
# SelfModulate
C#
public Color SelfModulate { get; set; }

The color applied to this CanvasItem. This property does not affect child CanvasItems, unlike CanvasItem.Modulate which affects both the node itself and its children. Note: Internal children are also not affected by this property (see the include_internal parameter in Entity.AddChild). For built-in nodes this includes sliders in ColorPicker, and the tab bar in TabContainer.

ShowBehindParentProperty
# ShowBehindParent
C#
public bool ShowBehindParent { get; set; }

If true, this node draws behind its parent.

TextureFilterProperty
# TextureFilter
C#
public CanvasItem.TextureFilterEnum TextureFilter { get; set; }

Texture-filter policy for this item. ParentNode inherits the setting; LinearWithMipmaps uses mipmaps when available. The example prepares an ImageTexture with mipmaps for downscaled images. This property neither enables MSAA nor generates mipmaps.

TextureRepeatProperty
# TextureRepeat
C#
public CanvasItem.TextureRepeatEnum TextureRepeat { get; set; }

The repeating mode used to render this CanvasItem's texture(s). It affects what happens when the texture is sampled outside its extents, for example by setting a Sprite2D.RegionRect that is larger than the texture or assigning Polygon2D UV points outside the texture. Note: TextureRect is not affected by CanvasItem.TextureRepeat, as it uses its own texture repeating implementation.

TopLevelProperty
# TopLevel
C#
public bool TopLevel { get; set; }

Stops inheriting the parent CanvasItem transform. Does not remove the item from the tree, move it to another viewport or disable its canvas transform from a camera or CanvasLayer.

UseParentMaterialProperty
# UseParentMaterial
C#
public bool UseParentMaterial { get; set; }

If true, drawing uses the parent material instead of the item’s own Material. The assigned own resource remains accessible through its getter. Verification shows parent tint overriding child grayscale and false restoring the child shader.

VisibilityLayerProperty
# VisibilityLayer
C#
public uint VisibilityLayer { get; set; }

The rendering layer in which this CanvasItem is rendered by Viewport nodes. A Viewport will render a CanvasItem if it and all its parents share a layer with the Viewport's canvas cull mask. For an easier way to change this value from a script, see CanvasItem.SetVisibilityLayerBit. Note: A CanvasItem does not inherit its parents' visibility layers. This means that if a parent CanvasItem does not have all the same layers as its child, the child may not be visible even if both the parent and child have CanvasItem.Visible set to true. For example, if a parent has layer 1 and a child has layer 2, the child will not be visible in a Viewport with the canvas cull mask set to layer 1 or 2 (see Viewport.CanvasCullMask). To ensure that both the parent and child are visible, the parent must have both layers 1 and 2, or the child must have CanvasItem.TopLevel set to true.

VisibleProperty
# Visible
C#
public bool Visible { get; set; }

If true, this CanvasItem may be drawn. Whether this CanvasItem is actually drawn depends on the visibility of all of its CanvasItem ancestors. In other words: this CanvasItem will be drawn when CanvasItem.IsVisibleInTree returns true and all CanvasItem ancestors share at least one CanvasItem.VisibilityLayer with this CanvasItem. Note: For controls that inherit Popup, the correct way to make them visible is to call one of the multiple popup*() functions instead.

YSortEnabledProperty
# YSortEnabled
C#
public bool YSortEnabled { get; set; }

If true, this and child CanvasItem nodes with a higher Y position are rendered in front of nodes with a lower Y position. If false, this and child CanvasItem nodes are rendered normally in scene tree order. With Y-sorting enabled on a parent node ('A') but disabled on a child node ('B'), the child node ('B') is sorted but its children ('C1', 'C2', etc.) render together on the same Y position as the child node ('B'). This allows you to organize the render order of a scene without changing the scene tree. Nodes sort relative to each other only if they are on the same CanvasItem.ZIndex. Note: Y-sorting does not affect the order in which CanvasItem nodes are processed, or the way input events are handled. This is especially important to keep in mind for Control nodes.

ZAsRelativeProperty
# ZAsRelative
C#
public bool ZAsRelative { get; set; }

If true, this node's final Z index is relative to its parent's Z index. For example, if CanvasItem.ZIndex is 2 and its parent's final Z index is 3, then this node's final Z index will be 5 (2 + 3).

ZIndexProperty
# ZIndex
C#
public int ZIndex { get; set; }

The order in which this node is drawn. A node with a higher Z index will display in front of others. Must be between RenderingServer.CanvasItemZMin and RenderingServer.CanvasItemZMax (inclusive). Note: The Z index does not affect the order in which CanvasItem nodes are processed, or the way input events are handled. This is especially important to keep in mind for Control nodes.

Methods114

DrawAnimationSlicevoid
# DrawAnimationSlice
C#
public void DrawAnimationSlice(double animationLength, double sliceBegin, double sliceEnd, double offset = 0d);

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.

Parameters
NameTypeDefault
animationLengthdouble—
sliceBegindouble—
sliceEnddouble—
offsetdouble0d
DrawArcvoid
# DrawArc
C#
public void DrawArc(Vector2 center, float radius, float startAngle, float endAngle, int pointCount, Color color, float width = -1f, bool antialiased = false);

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. For elliptical arcs, see CanvasItem.DrawEllipseArc. See also CanvasItem.DrawCircle. If width is negative, it will be ignored and the arc will be drawn using RenderingServer.PrimitiveType.LineStrip. 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 @C#.TAU radians, then a full circle arc is drawn (i.e. arc will not overlap itself).

Parameters
NameTypeDefault
centerVector2—
radiusfloat—
startAnglefloat—
endAnglefloat—
pointCountint—
colorColor—
widthfloat-1f
antialiasedboolfalse
DrawChar2 overloads
# DrawChar · 1/2
C#
public void DrawChar(Font font, Vector2 pos, string @char, int fontSize, Color? modulate);

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.

Parameters
NameTypeDefault
fontFont—
posVector2—
charstring—
fontSizeint—
modulateColor?—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawChar · 2/2
C#
public void DrawChar(Font font, Vector2 pos, string @char, int fontSize = 16, Color? modulate = default, float oversampling = 0f);

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.

Parameters
NameTypeDefault
fontFont—
posVector2—
charstring—
fontSizeint16
modulateColor?default
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawCharOutline2 overloads
# DrawCharOutline · 1/2
C#
public void DrawCharOutline(Font font, Vector2 pos, string @char, int fontSize, int size, Color? modulate);

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.

Parameters
NameTypeDefault
fontFont—
posVector2—
charstring—
fontSizeint—
sizeint—
modulateColor?—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawCharOutline · 2/2
C#
public void DrawCharOutline(Font font, Vector2 pos, string @char, int fontSize = 16, int size = -1, Color? modulate = default, float oversampling = 0f);

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.

Parameters
NameTypeDefault
fontFont—
posVector2—
charstring—
fontSizeint16
sizeint-1
modulateColor?default
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawCircle2 overloads
# DrawCircle · 1/2
C#
public void DrawCircle(Vector2 position, float radius, Color color);

Draws a circle, with position defined in local space. See also CanvasItem.DrawEllipse, CanvasItem.DrawArc, CanvasItem.DrawPolyline, and CanvasItem.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 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.

Parameters
NameTypeDefault
positionVector2—
radiusfloat—
colorColor—
# DrawCircle · 2/2
C#
public void DrawCircle(Vector2 position, float radius, Color color, bool filled = true, float width = -1f, bool antialiased = false);

Draws a circle, with position defined in local space. See also CanvasItem.DrawEllipse, CanvasItem.DrawArc, CanvasItem.DrawPolyline, and CanvasItem.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 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.

Parameters
NameTypeDefault
positionVector2—
radiusfloat—
colorColor—
filledbooltrue
widthfloat-1f
antialiasedboolfalse
DrawColoredPolygon2 overloads
# DrawColoredPolygon · 1/2
C#
public void DrawColoredPolygon(Vector2[] points, Color color, Vector2[] uvs = null, Texture2D texture = null);

Draws a colored polygon of any number of points, convex or concave. The points in the points array are defined in local space. Unlike CanvasItem.DrawPolygon, a single color must be specified for the whole polygon. Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using CanvasItem.DrawMesh, CanvasItem.DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
pointsVector2[]—
colorColor—
uvsVector2[]null
textureTexture2Dnull
uvs

If the parameter is null, then the default value is Array.Empty<Vector2>().

# DrawColoredPolygon · 2/2
C#
public void DrawColoredPolygon(ReadOnlySpan<Vector2> points, Color color, ReadOnlySpan<Vector2> uvs, Texture2D texture);

Draws a colored polygon of any number of points, convex or concave. The points in the points array are defined in local space. Unlike CanvasItem.DrawPolygon, a single color must be specified for the whole polygon. Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using CanvasItem.DrawMesh, CanvasItem.DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
colorColor—
uvsReadOnlySpan<Vector2>—
textureTexture2D—
DrawDashedLine2 overloads
# DrawDashedLine · 1/2
C#
public void DrawDashedLine(Vector2 from, Vector2 to, Color color, float width, float dash, bool aligned);

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 CanvasItem.DrawLine, CanvasItem.DrawMultiline, and CanvasItem.DrawPolyline. If width is negative, then two-point primitives will be drawn instead of 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.

Parameters
NameTypeDefault
fromVector2—
toVector2—
colorColor—
widthfloat—
dashfloat—
alignedbool—
# DrawDashedLine · 2/2
C#
public void DrawDashedLine(Vector2 from, Vector2 to, Color color, float width = -1f, float dash = 2f, bool aligned = true, bool antialiased = false);

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 CanvasItem.DrawLine, CanvasItem.DrawMultiline, and CanvasItem.DrawPolyline. If width is negative, then two-point primitives will be drawn instead of 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.

Parameters
NameTypeDefault
fromVector2—
toVector2—
colorColor—
widthfloat-1f
dashfloat2f
alignedbooltrue
antialiasedboolfalse
DrawEllipsevoid
# DrawEllipse
C#
public void DrawEllipse(Vector2 position, float major, float minor, Color color, bool filled = true, float width = -1f, bool antialiased = false);

Draws an ellipse with semi-major axis major and semi-minor axis minor. See also CanvasItem.DrawCircle, CanvasItem.DrawEllipseArc, CanvasItem.DrawPolyline, and CanvasItem.DrawPolygon. If filled is true, the ellipse will be filled with the color specified. If filled is false, the ellipse 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 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.

Parameters
NameTypeDefault
positionVector2—
majorfloat—
minorfloat—
colorColor—
filledbooltrue
widthfloat-1f
antialiasedboolfalse
DrawEllipseArcvoid
# DrawEllipseArc
C#
public void DrawEllipseArc(Vector2 center, float major, float minor, float startAngle, float endAngle, int pointCount, Color color, float width = -1f, bool antialiased = false);

Draws an unfilled elliptical 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. For circular arcs, see CanvasItem.DrawArc. See also CanvasItem.DrawEllipse. If width is negative, it will be ignored and the arc will be drawn using RenderingServer.PrimitiveType.LineStrip. 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 @C#.TAU radians, then a full ellipse is drawn (i.e. arc will not overlap itself).

Parameters
NameTypeDefault
centerVector2—
majorfloat—
minorfloat—
startAnglefloat—
endAnglefloat—
pointCountint—
colorColor—
widthfloat-1f
antialiasedboolfalse
DrawEndAnimationvoid
# DrawEndAnimation
C#
public void DrawEndAnimation();

After submitting all animations slices via CanvasItem.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.

DrawLcdTextureRectRegionvoid
# DrawLcdTextureRectRegion
C#
public void DrawLcdTextureRectRegion(Texture2D texture, Rect2 rect, Rect2 srcRect, Color? modulate = default);

Draws a textured rectangle region of the font texture with LCD subpixel anti-aliasing at a given position, optionally modulated by a color. The rect is defined in local space. Texture is drawn using the following blend operation, blend mode of the CanvasItemMaterial is ignored:

Text
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);

Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
textureTexture2D—
rectRect2—
srcRectRect2—
modulateColor?default
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawLinevoid
# DrawLine
C#
public void DrawLine(Vector2 from, Vector2 to, Color color, float width = -1f, bool antialiased = false);

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 CanvasItem.DrawDashedLine, CanvasItem.DrawMultiline, and CanvasItem.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.

Parameters
NameTypeDefault
fromVector2—
toVector2—
colorColor—
widthfloat-1f
antialiasedboolfalse
DrawMeshvoid
# DrawMesh
C#
public void DrawMesh(Mesh mesh, Texture2D texture, Transform2D? transform = default, Color? modulate = default);

Draws a Mesh in 2D, using the provided texture. See MeshInstance2D for related documentation. The transform is defined in local space. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
meshMesh—
textureTexture2D—
transformTransform2D?default
modulateColor?default
transform

If the parameter is null, then the default value is Transform2D.Identity.

modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawMsdfTextureRectRegionvoid
# DrawMsdfTextureRectRegion
C#
public void DrawMsdfTextureRectRegion(Texture2D texture, Rect2 rect, Rect2 srcRect, Color? modulate = default, double outline = 0d, double pixelRange = 4d, double scale = 1d);

Draws a textured rectangle region of the multichannel signed distance field texture at a given position, optionally modulated by a color. The rect is defined in local space. See FontFile.MultichannelSignedDistanceField for more information and caveats about MSDF font rendering. If outline is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the outline radius. Value of the pixel_range should the same that was used during distance field texture generation. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
textureTexture2D—
rectRect2—
srcRectRect2—
modulateColor?default
outlinedouble0d
pixelRangedouble4d
scaledouble1d
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawMultiline4 overloads
# DrawMultiline · 1/4
C#
public void DrawMultiline(Vector2[] points, Color color, float width);

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[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolyline](/en/docs/api/canvasitem#member-drawpolyline-a13ae2e4ee) instead. If widthis negative, then two-point primitives will be drawn instead of 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 positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.

Parameters
NameTypeDefault
pointsVector2[]—
colorColor—
widthfloat—
# DrawMultiline · 2/4
C#
public void DrawMultiline(Vector2[] points, Color color, float width = -1f, bool antialiased = false);

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[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolyline](/en/docs/api/canvasitem#member-drawpolyline-a13ae2e4ee) instead. If widthis negative, then two-point primitives will be drawn instead of 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 positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.

Parameters
NameTypeDefault
pointsVector2[]—
colorColor—
widthfloat-1f
antialiasedboolfalse
# DrawMultiline · 3/4
C#
public void DrawMultiline(ReadOnlySpan<Vector2> points, Color color, float width);

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[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolyline](/en/docs/api/canvasitem#member-drawpolyline-a13ae2e4ee) instead. If widthis negative, then two-point primitives will be drawn instead of 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 positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
colorColor—
widthfloat—
# DrawMultiline · 4/4
C#
public void DrawMultiline(ReadOnlySpan<Vector2> points, Color color, float width, bool antialiased);

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[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolyline](/en/docs/api/canvasitem#member-drawpolyline-a13ae2e4ee) instead. If widthis negative, then two-point primitives will be drawn instead of 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 positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
colorColor—
widthfloat—
antialiasedbool—
DrawMultilineColors4 overloads
# DrawMultilineColors · 1/4
C#
public void DrawMultilineColors(Vector2[] points, Color[] colors, float width);

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[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolylineColors](/en/docs/api/canvasitem#member-drawpolylinecolors-4e239fff36) instead. If widthis negative, then two-point primitives will be drawn instead of 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 positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.

Parameters
NameTypeDefault
pointsVector2[]—
colorsColor[]—
widthfloat—
# DrawMultilineColors · 2/4
C#
public void DrawMultilineColors(Vector2[] points, Color[] colors, float width = -1f, bool antialiased = false);

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[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolylineColors](/en/docs/api/canvasitem#member-drawpolylinecolors-4e239fff36) instead. If widthis negative, then two-point primitives will be drawn instead of 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 positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.

Parameters
NameTypeDefault
pointsVector2[]—
colorsColor[]—
widthfloat-1f
antialiasedboolfalse
# DrawMultilineColors · 3/4
C#
public void DrawMultilineColors(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, float width);

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[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolylineColors](/en/docs/api/canvasitem#member-drawpolylinecolors-4e239fff36) instead. If widthis negative, then two-point primitives will be drawn instead of 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 positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
colorsReadOnlySpan<Color>—
widthfloat—
# DrawMultilineColors · 4/4
C#
public void DrawMultilineColors(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, float width, bool antialiased);

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[CanvasItem.DrawLine](/en/docs/api/canvasitem#member-drawline-6049f7c36b) calls. To draw interconnected lines, use [CanvasItem.DrawPolylineColors](/en/docs/api/canvasitem#member-drawpolylinecolors-4e239fff36) instead. If widthis negative, then two-point primitives will be drawn instead of 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 positivewidthlike1.0. **Note:** antialiasedis only effective ifwidthis greater than0.0`.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
colorsReadOnlySpan<Color>—
widthfloat—
antialiasedbool—
DrawMultilineString2 overloads
# DrawMultilineString · 1/2
C#
public void DrawMultilineString(Font font, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, int maxLines, Color? modulate, TextServer.LineBreakFlag brkFlags, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation orientation);

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 CanvasItem.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.

Parameters
NameTypeDefault
fontFont—
posVector2—
textstring—
alignmentHorizontalAlignment—
widthfloat—
fontSizeint—
maxLinesint—
modulateColor?—
brkFlagsTextServer.LineBreakFlag—
justificationFlagsTextServer.JustificationFlag—
directionTextServer.Direction—
orientationTextServer.Orientation—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawMultilineString · 2/2
C#
public void DrawMultilineString(Font font, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int maxLines = -1, Color? modulate = default, TextServer.LineBreakFlag brkFlags = TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);

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 CanvasItem.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.

Parameters
NameTypeDefault
fontFont—
posVector2—
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
maxLinesint-1
modulateColor?default
brkFlagsTextServer.LineBreakFlagTextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawMultilineStringOutline2 overloads
# DrawMultilineStringOutline · 1/2
C#
public void DrawMultilineStringOutline(Font font, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, int maxLines, int size, Color? modulate, TextServer.LineBreakFlag brkFlags, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation orientation);

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 CanvasItem.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.

Parameters
NameTypeDefault
fontFont—
posVector2—
textstring—
alignmentHorizontalAlignment—
widthfloat—
fontSizeint—
maxLinesint—
sizeint—
modulateColor?—
brkFlagsTextServer.LineBreakFlag—
justificationFlagsTextServer.JustificationFlag—
directionTextServer.Direction—
orientationTextServer.Orientation—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawMultilineStringOutline · 2/2
C#
public void DrawMultilineStringOutline(Font font, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int maxLines = -1, int size = 1, Color? modulate = default, TextServer.LineBreakFlag brkFlags = TextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);

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 CanvasItem.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.

Parameters
NameTypeDefault
fontFont—
posVector2—
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
maxLinesint-1
sizeint1
modulateColor?default
brkFlagsTextServer.LineBreakFlagTextServer.LineBreakFlag.Mandatory | TextServer.LineBreakFlag.WordBound
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawMultimeshvoid
# DrawMultimesh
C#
public void DrawMultimesh(MultiMesh multimesh, Texture2D texture);

Draws a MultiMesh in 2D with the provided texture. See MultiMeshInstance2D for related documentation. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
multimeshMultiMesh—
textureTexture2D—
DrawPolygon2 overloads
# DrawPolygon · 1/2
C#
public void DrawPolygon(Vector2[] points, Color[] colors, Vector2[] uvs = null, Texture2D texture = null);

Draws a solid polygon of any number of points, convex or concave. Unlike CanvasItem.DrawColoredPolygon, each point's color can be changed individually. The points array is defined in local space. See also CanvasItem.DrawPolyline and CanvasItem.DrawPolylineColors. If you need more flexibility (such as being able to use bones), use RenderingServer.CanvasItemAddTriangleArray instead. Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using CanvasItem.DrawMesh, CanvasItem.DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
pointsVector2[]—
colorsColor[]—
uvsVector2[]null
textureTexture2Dnull
uvs

If the parameter is null, then the default value is Array.Empty<Vector2>().

# DrawPolygon · 2/2
C#
public void DrawPolygon(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, ReadOnlySpan<Vector2> uvs, Texture2D texture);

Draws a solid polygon of any number of points, convex or concave. Unlike CanvasItem.DrawColoredPolygon, each point's color can be changed individually. The points array is defined in local space. See also CanvasItem.DrawPolyline and CanvasItem.DrawPolylineColors. If you need more flexibility (such as being able to use bones), use RenderingServer.CanvasItemAddTriangleArray instead. Note: If you frequently redraw the same polygon with a large number of vertices, consider pre-calculating the triangulation with Geometry2D.TriangulatePolygon and using CanvasItem.DrawMesh, CanvasItem.DrawMultimesh, or RenderingServer.CanvasItemAddTriangleArray. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
colorsReadOnlySpan<Color>—
uvsReadOnlySpan<Vector2>—
textureTexture2D—
DrawPolyline2 overloads
# DrawPolyline · 1/2
C#
public void DrawPolyline(Vector2[] points, Color color, float width = -1f, bool antialiased = false);

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 CanvasItem.DrawLine calls. To draw disconnected lines, use CanvasItem.DrawMultiline instead. See also CanvasItem.DrawPolygon. If width is negative, it will be ignored and the polyline will be drawn using RenderingServer.PrimitiveType.LineStrip. 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.

Parameters
NameTypeDefault
pointsVector2[]—
colorColor—
widthfloat-1f
antialiasedboolfalse
# DrawPolyline · 2/2
C#
public void DrawPolyline(ReadOnlySpan<Vector2> points, Color color, float width, bool antialiased);

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 CanvasItem.DrawLine calls. To draw disconnected lines, use CanvasItem.DrawMultiline instead. See also CanvasItem.DrawPolygon. If width is negative, it will be ignored and the polyline will be drawn using RenderingServer.PrimitiveType.LineStrip. 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.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
colorColor—
widthfloat—
antialiasedbool—
DrawPolylineColors2 overloads
# DrawPolylineColors · 1/2
C#
public void DrawPolylineColors(Vector2[] points, Color[] colors, float width = -1f, bool antialiased = false);

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 CanvasItem.DrawLine calls. To draw disconnected lines, use CanvasItem.DrawMultilineColors instead. See also CanvasItem.DrawPolygon. If width is negative, it will be ignored and the polyline will be drawn using RenderingServer.PrimitiveType.LineStrip. 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.

Parameters
NameTypeDefault
pointsVector2[]—
colorsColor[]—
widthfloat-1f
antialiasedboolfalse
# DrawPolylineColors · 2/2
C#
public void DrawPolylineColors(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, float width, bool antialiased);

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 CanvasItem.DrawLine calls. To draw disconnected lines, use CanvasItem.DrawMultilineColors instead. See also CanvasItem.DrawPolygon. If width is negative, it will be ignored and the polyline will be drawn using RenderingServer.PrimitiveType.LineStrip. 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.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
colorsReadOnlySpan<Color>—
widthfloat—
antialiasedbool—
DrawPrimitive2 overloads
# DrawPrimitive · 1/2
C#
public void DrawPrimitive(Vector2[] points, Color[] colors, Vector2[] uvs, Texture2D texture = null);

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 CanvasItem.DrawLine, CanvasItem.DrawPolyline, CanvasItem.DrawPolygon, and CanvasItem.DrawRect. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
pointsVector2[]—
colorsColor[]—
uvsVector2[]—
textureTexture2Dnull
# DrawPrimitive · 2/2
C#
public void DrawPrimitive(ReadOnlySpan<Vector2> points, ReadOnlySpan<Color> colors, ReadOnlySpan<Vector2> uvs, Texture2D texture);

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 CanvasItem.DrawLine, CanvasItem.DrawPolyline, CanvasItem.DrawPolygon, and CanvasItem.DrawRect. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
pointsReadOnlySpan<Vector2>—
colorsReadOnlySpan<Color>—
uvsReadOnlySpan<Vector2>—
textureTexture2D—
DrawRect2 overloads
# DrawRect · 1/2
C#
public void DrawRect(Rect2 rect, Color color, bool filled, float width);

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 CanvasItem.DrawTextureRect. If width is negative, then two-point primitives will be drawn instead of 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).

Parameters
NameTypeDefault
rectRect2—
colorColor—
filledbool—
widthfloat—
# DrawRect · 2/2
C#
public void DrawRect(Rect2 rect, Color color, bool filled = true, float width = -1f, bool antialiased = false);

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 CanvasItem.DrawTextureRect. If width is negative, then two-point primitives will be drawn instead of 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).

Parameters
NameTypeDefault
rectRect2—
colorColor—
filledbooltrue
widthfloat-1f
antialiasedboolfalse
DrawSetTransformvoid
# DrawSetTransform
C#
public void DrawSetTransform(Vector2 position, float rotation = 0f, Vector2? scale = default);

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

Parameters
NameTypeDefault
positionVector2—
rotationfloat0f
scaleVector2?default
scale

If the parameter is null, then the default value is new Vector2(1.0f, 1.0f).

DrawSetTransformMatrixvoid
# DrawSetTransformMatrix
C#
public void DrawSetTransformMatrix(Transform2D xform);

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

Parameters
NameTypeDefault
xformTransform2D—
DrawString2 overloads
# DrawString · 1/2
C#
public void DrawString(Font font, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, Color? modulate, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation orientation);

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 CanvasItem.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:

C#
DrawString(ThemeDB.FallbackFont, new Vector2(64, 64), "Hello world", HorizontalAlignment.Left, -1, ThemeDB.FallbackFontSize);

See also Font.DrawString.

Parameters
NameTypeDefault
fontFont—
posVector2—
textstring—
alignmentHorizontalAlignment—
widthfloat—
fontSizeint—
modulateColor?—
justificationFlagsTextServer.JustificationFlag—
directionTextServer.Direction—
orientationTextServer.Orientation—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawString · 2/2
C#
public void DrawString(Font font, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, Color? modulate = default, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);

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 CanvasItem.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:

C#
DrawString(ThemeDB.FallbackFont, new Vector2(64, 64), "Hello world", HorizontalAlignment.Left, -1, ThemeDB.FallbackFontSize);

See also Font.DrawString.

Parameters
NameTypeDefault
fontFont—
posVector2—
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
modulateColor?default
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawStringOutline2 overloads
# DrawStringOutline · 1/2
C#
public void DrawStringOutline(Font font, Vector2 pos, string text, HorizontalAlignment alignment, float width, int fontSize, int size, Color? modulate, TextServer.JustificationFlag justificationFlags, TextServer.Direction direction, TextServer.Orientation orientation);

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 CanvasItem.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.

Parameters
NameTypeDefault
fontFont—
posVector2—
textstring—
alignmentHorizontalAlignment—
widthfloat—
fontSizeint—
sizeint—
modulateColor?—
justificationFlagsTextServer.JustificationFlag—
directionTextServer.Direction—
orientationTextServer.Orientation—
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

# DrawStringOutline · 2/2
C#
public void DrawStringOutline(Font font, Vector2 pos, string text, HorizontalAlignment alignment = HorizontalAlignment.Left, float width = -1f, int fontSize = 16, int size = 1, Color? modulate = default, TextServer.JustificationFlag justificationFlags = TextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound, TextServer.Direction direction = TextServer.Direction.Auto, TextServer.Orientation orientation = TextServer.Orientation.Horizontal, float oversampling = 0f);

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 CanvasItem.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.

Parameters
NameTypeDefault
fontFont—
posVector2—
textstring—
alignmentHorizontalAlignmentHorizontalAlignment.Left
widthfloat-1f
fontSizeint16
sizeint1
modulateColor?default
justificationFlagsTextServer.JustificationFlagTextServer.JustificationFlag.Kashida | TextServer.JustificationFlag.WordBound
directionTextServer.DirectionTextServer.Direction.Auto
orientationTextServer.OrientationTextServer.Orientation.Horizontal
oversamplingfloat0f
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawStyleBoxvoid
# DrawStyleBox
C#
public void DrawStyleBox(StyleBox styleBox, Rect2 rect);

Draws a styled rectangle. The rect is defined in local space. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
styleBoxStyleBox—
rectRect2—
DrawTexturevoid
# DrawTexture
C#
public void DrawTexture(Texture2D texture, Vector2 position, Color? modulate = default);

Draws a texture at a given position. The position is defined in local space. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
textureTexture2D—
positionVector2—
modulateColor?default
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawTextureRectvoid
# DrawTextureRect
C#
public void DrawTextureRect(Texture2D texture, Rect2 rect, bool tile, Color? modulate = default, bool transpose = false);

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 CanvasItem.DrawRect and CanvasItem.DrawTextureRectRegion. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
textureTexture2D—
rectRect2—
tilebool—
modulateColor?default
transposeboolfalse
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

DrawTextureRectRegionvoid
# DrawTextureRectRegion
C#
public void DrawTextureRectRegion(Texture2D texture, Rect2 rect, Rect2 srcRect, Color? modulate = default, bool transpose = false, bool clipUV = true);

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 CanvasItem.DrawTextureRect. Note: Styleboxes, textures, and meshes stored only inside local variables should not be used with this method in C#, because the drawing operation doesn't begin immediately once this method is called. In C#, when the function with the local variables ends, the local variables get destroyed before the rendering takes place.

Parameters
NameTypeDefault
textureTexture2D—
rectRect2—
srcRectRect2—
modulateColor?default
transposeboolfalse
clipUVbooltrue
modulate

If the parameter is null, then the default value is new Color(1.0f, 1.0f, 1.0f, 1.0f).

ForceUpdateTransformvoid
# ForceUpdateTransform
C#
public void ForceUpdateTransform();

Forces the node's transform to update. Fails if the node is not inside the tree. See also CanvasItem.GetTransform. Note: For performance reasons, transform changes are usually accumulated and applied once at the end of the frame. The update propagates through CanvasItem children, as well. Therefore, use this method only when you need an up-to-date transform (such as during physics operations).

GetCanvasRid
# GetCanvas
C#
public Rid GetCanvas();

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

Returns Rid
GetCanvasItemRid
# GetCanvasItem
C#
public Rid GetCanvasItem();

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

Returns Rid
GetCanvasLayerEntityCanvasLayer
# GetCanvasLayerEntity
C#
public CanvasLayer GetCanvasLayerEntity();

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

Returns CanvasLayer
GetCanvasTransformTransform2D
# GetCanvasTransform
C#
public Transform2D GetCanvasTransform();

Returns the effective canvas transform: the CanvasLayer final transform or the viewport CanvasTransform. Requires the item in the tree; excludes the item's own local transform and final window stretch.

Returns Transform2D

Effective canvas transform, excluding the item-local matrix.

GetClipChildrenModeCanvasItem.ClipChildrenMode
# GetClipChildrenMode
C#
public CanvasItem.ClipChildrenMode GetClipChildrenMode();
Returns CanvasItem.ClipChildrenMode
GetGlobalMousePositionVector2
# GetGlobalMousePosition
C#
public Vector2 GetGlobalMousePosition();

Returns mouse cursor's global position relative to the CanvasLayer that contains this node. Note: For screen-space coordinates (e.g. when using a non-embedded Popup), you can use DisplayServer.MouseGetPosition.

Returns Vector2
GetGlobalTransformTransform2D
# GetGlobalTransform
C#
public Transform2D GetGlobalTransform();

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 CanvasItem.TopLevel enabled.

Returns Transform2D
GetGlobalTransformWithCanvasTransform2D
# GetGlobalTransformWithCanvas
C#
public Transform2D GetGlobalTransformWithCanvas();

Composes a CanvasItem-local to canvas/viewport transform using its hierarchy and CanvasLayer or viewport canvas. Its inverse converts a point from the same viewport into local coordinates when invertible.

Returns Transform2D

Composed Transform2D. An off-tree object without CanvasLayer uses only its global object transform; this is not a complete mapping to a future viewport.

GetInstanceShaderParameterVariant
# GetInstanceShaderParameter
C#
public Variant GetInstanceShaderParameter(StringName name);

Reads the CanvasItem instance registry current value. After material preparation and Nil reset the declared default is available; an absent entry returns Nil. This is distinct from a shared ShaderMaterial parameter.

Parameters
NameTypeDefault
nameStringName—
name

Exact case-sensitive parameter name.

Returns Variant

Current known instance value, or Nil.

GetLightMaskint
# GetLightMask
C#
public int GetLightMask();
Returns int
GetLocalMousePositionVector2
# GetLocalMousePosition
C#
public Vector2 GetLocalMousePosition();

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

Returns Vector2
GetMaterialMaterial
# GetMaterial
C#
public Material GetMaterial();

Returns the assigned own resource rather than resolving the effective material under UseParentMaterial.

Returns Material

Own Material, or null. Check UseParentMaterial if readback is correct but rendering uses different settings.

GetModulateColor
# GetModulate
C#
public Color GetModulate();
Returns Color
GetOversamplingWithScaleCanvasItem.OversamplingWithScaleEnum
# GetOversamplingWithScale
C#
public CanvasItem.OversamplingWithScaleEnum GetOversamplingWithScale();
Returns CanvasItem.OversamplingWithScaleEnum
GetScreenTransformTransform2D
# GetScreenTransform
C#
public Transform2D GetScreenTransform();

Returns the transform of this CanvasItem in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins. Equivalent to CanvasItem.GetGlobalTransformWithCanvas if the window is embedded (see Viewport.GuiEmbedSubwindows).

Returns Transform2D
GetSelfModulateColor
# GetSelfModulate
C#
public Color GetSelfModulate();
Returns Color
GetTextureFilterCanvasItem.TextureFilterEnum
# GetTextureFilter
C#
public CanvasItem.TextureFilterEnum GetTextureFilter();

Reads the item’s stored policy. It can return ParentNode rather than the resolved filter after following inheritance.

Returns CanvasItem.TextureFilterEnum

Stored TextureFilterEnum. Selecting a mipmap mode does not establish that a particular texture contains mipmap data.

GetTextureRepeatCanvasItem.TextureRepeatEnum
# GetTextureRepeat
C#
public CanvasItem.TextureRepeatEnum GetTextureRepeat();
Returns CanvasItem.TextureRepeatEnum
GetTransformTransform2D
# GetTransform
C#
public Transform2D GetTransform();

Returns the transform matrix of this CanvasItem.

Returns Transform2D
GetUseParentMaterialbool
# GetUseParentMaterial
C#
public bool GetUseParentMaterial();

Reads the parent-material selection flag rather than the material itself.

Returns bool

Current UseParentMaterial value. Use GetMaterial to read the assigned own resource.

GetViewportRectRect2
# GetViewportRect
C#
public Rect2 GetViewportRect();

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

Returns Rect2
GetViewportTransformTransform2D
# GetViewportTransform
C#
public Transform2D GetViewportTransform();

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

Returns Transform2D
GetVisibilityLayeruint
# GetVisibilityLayer
C#
public uint GetVisibilityLayer();
Returns uint
GetVisibilityLayerBitbool
# GetVisibilityLayerBit
C#
public bool GetVisibilityLayerBit(uint layer);

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

Parameters
NameTypeDefault
layeruint—
Returns bool
GetWorld2DWorld2D
# GetWorld2D
C#
public World2D GetWorld2D();

Returns the World2D this node is registered to. Usually, this is the same as this node's viewport (see Entity.GetViewport and Viewport.FindWorld2D).

Returns World2D
GetZIndexint
# GetZIndex
C#
public int GetZIndex();
Returns int
Hidevoid
# Hide
C#
public void Hide();

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

IsDrawBehindParentEnabledbool
# IsDrawBehindParentEnabled
C#
public bool IsDrawBehindParentEnabled();
Returns bool
IsLocalTransformNotificationEnabledbool
# IsLocalTransformNotificationEnabled
C#
public bool IsLocalTransformNotificationEnabled();

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

Returns bool
IsSetAsTopLevelbool
# IsSetAsTopLevel
C#
public bool IsSetAsTopLevel();
Returns bool
IsTransformNotificationEnabledbool
# IsTransformNotificationEnabled
C#
public bool IsTransformNotificationEnabled();

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

Returns bool
IsVisiblebool
# IsVisible
C#
public bool IsVisible();
Returns bool
IsVisibleInTreebool
# IsVisibleInTree
C#
public bool IsVisibleInTree();

Returns true if the node is present in the EntityTree, its CanvasItem.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 CanvasItem.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 Entity, AnimationPlayer, or Entity3D), it is assumed to be visible. Note: This method does not take CanvasItem.VisibilityLayer into account, so even if this method returns true, the node might end up not being rendered.

Returns bool
IsYSortEnabledbool
# IsYSortEnabled
C#
public bool IsYSortEnabled();
Returns bool
IsZRelativebool
# IsZRelative
C#
public bool IsZRelative();
Returns bool
MakeCanvasPositionLocalVector2
# MakeCanvasPositionLocal
C#
public Vector2 MakeCanvasPositionLocal(Vector2 viewportPoint);

Converts a logical viewport point to item-local coordinates by affine-inverting canvas transform times GlobalTransform. Requires the item in the tree and an invertible basis; the input must not be an OS screen position.

Parameters
NameTypeDefault
viewportPointVector2—
viewportPoint

Logical point in the same viewport at the canvas stage.

Returns Vector2

Point in the item's local space.

MakeInputLocalInputEvent
# MakeInputLocal
C#
public InputEvent MakeInputLocal(InputEvent @event);

Returns an event transformed by the inverse canvas and item transform; leaves the original event unchanged. Use for input in the same viewport's logical coordinates, not already-local GUI callback coordinates. Requires the item in the tree and an invertible basis.

Parameters
NameTypeDefault
eventInputEvent—
event

Event in the same viewport's logical coordinates; the original object is preserved.

Returns InputEvent

Transformed event; the original event remains unchanged.

MoveToFrontvoid
# MoveToFront
C#
public void 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 Entity.MoveChild.

QueueRedrawvoid
# QueueRedraw
C#
public void QueueRedraw();

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

SetAsTopLevelvoid
# SetAsTopLevel
C#
public void SetAsTopLevel(bool enable);
Parameters
NameTypeDefault
enablebool—
SetClipChildrenModevoid
# SetClipChildrenMode
C#
public void SetClipChildrenMode(CanvasItem.ClipChildrenMode mode);
Parameters
NameTypeDefault
modeCanvasItem.ClipChildrenMode—
SetDrawBehindParentvoid
# SetDrawBehindParent
C#
public void SetDrawBehindParent(bool enable);
Parameters
NameTypeDefault
enablebool—
SetInstanceShaderParametervoid
# SetInstanceShaderParameter
C#
public void SetInstanceShaderParameter(StringName name, Variant value);

Sets an instance uniform for one CanvasItem without copying its shared material. Nil resolves and assigns the declared default. Name and type must match the shader instance uniform.

Parameters
NameTypeDefault
nameStringName—
valueVariant—
name

Exact case-sensitive parameter name.

value

Value of the declared instance type; Nil restores the declared default.

SetLightMaskvoid
# SetLightMask
C#
public void SetLightMask(int lightMask);
Parameters
NameTypeDefault
lightMaskint—
SetMaterialvoid
# SetMaterial
C#
public void SetMaterial(Material material);

Assigns the item’s own material. With UseParentMaterial=true it does not determine current appearance: check inheritance first. null clears the own assignment.

Parameters
NameTypeDefault
materialMaterial—
material

Suitable 2D Material, or null. For a text shader, use ShaderMaterial with shader_type canvas_item.

SetModulatevoid
# SetModulate
C#
public void SetModulate(Color modulate);
Parameters
NameTypeDefault
modulateColor—
SetNotifyLocalTransformvoid
# SetNotifyLocalTransform
C#
public void SetNotifyLocalTransform(bool enable);

If true, the node will receive CanvasItem.NotificationLocalTransformChanged whenever its local transform changes. Note: Many canvas items such as Bone2D or CollisionShape2D automatically enable this in order to function correctly.

Parameters
NameTypeDefault
enablebool—
SetNotifyTransformvoid
# SetNotifyTransform
C#
public void SetNotifyTransform(bool enable);

If true, the node will receive CanvasItem.NotificationTransformChanged whenever its global transform changes. Note: Many canvas items such as Camera2D or Light2D automatically enable this in order to function correctly.

Parameters
NameTypeDefault
enablebool—
SetOversamplingWithScalevoid
# SetOversamplingWithScale
C#
public void SetOversamplingWithScale(CanvasItem.OversamplingWithScaleEnum enabled);
Parameters
NameTypeDefault
enabledCanvasItem.OversamplingWithScaleEnum—
SetSelfModulatevoid
# SetSelfModulate
C#
public void SetSelfModulate(Color selfModulate);
Parameters
NameTypeDefault
selfModulateColor—
SetTextureFiltervoid
# SetTextureFilter
C#
public void SetTextureFilter(CanvasItem.TextureFilterEnum mode);

Sets the 2D texture-filter policy and updates inheritance. Pixel art commonly needs Nearest; downscaled photography benefits from linear filtering with prepared mipmaps. Choose for the asset rather than treating maximum filtering as universal.

Parameters
NameTypeDefault
modeCanvasItem.TextureFilterEnum—
mode

A TextureFilterEnum value. ParentNode requests inheritance; Max is an enum bound, not a filtering mode.

SetTextureRepeatvoid
# SetTextureRepeat
C#
public void SetTextureRepeat(CanvasItem.TextureRepeatEnum mode);
Parameters
NameTypeDefault
modeCanvasItem.TextureRepeatEnum—
SetUseParentMaterialvoid
# SetUseParentMaterial
C#
public void SetUseParentMaterial(bool enable);

Switches parent-material selection for drawing. Does not remove the own Material or copy uniform values between resources.

Parameters
NameTypeDefault
enablebool—
enable

true selects the parent material; false restores use of the own assignment.

SetVisibilityLayervoid
# SetVisibilityLayer
C#
public void SetVisibilityLayer(uint layer);
Parameters
NameTypeDefault
layeruint—
SetVisibilityLayerBitvoid
# SetVisibilityLayerBit
C#
public void SetVisibilityLayerBit(uint layer, bool enabled);

Set/clear individual bits on the rendering visibility layer (layer is between 0 and 31). This simplifies editing this CanvasItem's visibility layer compared to assigning the CanvasItem.VisibilityLayer property directly.

Parameters
NameTypeDefault
layeruint—
enabledbool—
SetVisiblevoid
# SetVisible
C#
public void SetVisible(bool visible);
Parameters
NameTypeDefault
visiblebool—
SetYSortEnabledvoid
# SetYSortEnabled
C#
public void SetYSortEnabled(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetZAsRelativevoid
# SetZAsRelative
C#
public void SetZAsRelative(bool enable);
Parameters
NameTypeDefault
enablebool—
SetZIndexvoid
# SetZIndex
C#
public void SetZIndex(int zIndex);
Parameters
NameTypeDefault
zIndexint—
Showvoid
# Show
C#
public void Show();

Show the CanvasItem if it's currently hidden. This is equivalent to setting CanvasItem.Visible to true. Note: For controls that inherit Popup, the correct way to make them visible is to call one of the multiple popup*() functions instead.

_Drawvoid
# _Draw
C#
public virtual void _Draw();

Called when CanvasItem has been requested to redraw (after CanvasItem.QueueRedraw is called, either manually or by the engine). Corresponds to the CanvasItem.NotificationDraw notification in ReckfellObject.Notification.

Signals and events4

DrawEvent
# Draw
C#
public event Action Draw;

Called when CanvasItem has been requested to redraw (after CanvasItem.QueueRedraw is called, either manually or by the engine). Corresponds to the CanvasItem.NotificationDraw notification in ReckfellObject.Notification.

HiddenEvent
# Hidden
C#
public event Action Hidden;

Emitted when this node becomes hidden, i.e. it's no longer visible in the tree (see CanvasItem.IsVisibleInTree).

ItemRectChangedEvent
# ItemRectChanged
C#
public event Action ItemRectChanged;

Emitted when the CanvasItem's boundaries (position or size) change, or when an action took place that may have affected these boundaries (e.g. changing Sprite2D.Texture).

VisibilityChangedEvent
# VisibilityChanged
C#
public event Action VisibilityChanged;

Emitted when the CanvasItem's visibility changes, either because its own CanvasItem.Visible property changed or because its visibility in the tree changed (see CanvasItem.IsVisibleInTree). This signal is emitted after the related CanvasItem.NotificationVisibilityChanged notification.

Fields and constants7

NotificationDrawField
# NotificationDraw
C#
public const long NotificationDraw = 30;

The CanvasItem is requested to draw (see CanvasItem.Draw).

NotificationEnterCanvasField
# NotificationEnterCanvas
C#
public const long NotificationEnterCanvas = 32;

The CanvasItem has entered the canvas.

NotificationExitCanvasField
# NotificationExitCanvas
C#
public const long NotificationExitCanvas = 33;

The CanvasItem has exited the canvas. This notification is sent in reversed order.

NotificationLocalTransformChangedField
# NotificationLocalTransformChanged
C#
public const long NotificationLocalTransformChanged = 35;

Notification received when this node's transform changes, if CanvasItem.IsLocalTransformNotificationEnabled is true. This is not received when a parent Entity2D's transform changes. See also CanvasItem.SetNotifyLocalTransform. Note: Many canvas items such as Camera2D or CollisionShape2D automatically enable this in order to function correctly.

NotificationTransformChangedField
# NotificationTransformChanged
C#
public const long NotificationTransformChanged = 2000;

Notification received when this node's global transform changes, if CanvasItem.IsTransformNotificationEnabled is true. See also CanvasItem.SetNotifyTransform and CanvasItem.GetTransform. Note: Many canvas items such as Camera2D or CollisionObject2D automatically enable this in order to function correctly.

NotificationVisibilityChangedField
# NotificationVisibilityChanged
C#
public const long NotificationVisibilityChanged = 31;

Notification received when this node's visibility changes (see CanvasItem.Visible and CanvasItem.IsVisibleInTree). This notification is received before the related CanvasItem.VisibilityChanged signal.

NotificationWorld2DChangedField
# NotificationWorld2DChanged
C#
public const long NotificationWorld2DChanged = 36;

Notification received when this CanvasItem is registered to a new World2D (see CanvasItem.GetWorld2D).

CanvasItem.ClipChildrenMode

ValueDescription
AndDraw = 2

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.

Disabled = 0

Children are drawn over this node and are not clipped.

Max = 3

Represents the size of the CanvasItem.ClipChildrenMode enum.

Only = 1

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.

CanvasItem.OversamplingWithScaleEnum

ValueDescription
Disabled = 1

The oversampling is not affected by CanvasItem scale, and is equal to the Viewport oversampling.

Enabled = 2

The oversampling is a product of CanvasItem scale and Viewport oversampling.

Max = 3

Represents the size of the CanvasItem.OversamplingWithScaleEnum enum.

ParentNode = 0

The CanvasItem will inherit the oversampling mode from its parent.

CanvasItem.TextureFilterEnum

ValueDescription
Linear = 2

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

LinearWithMipmaps = 4

The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps (or uses the nearest mipmap if ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter is true). This makes the texture look smooth from up close, and smooth from a distance. Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to Camera2D zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.

LinearWithMipmapsAnisotropic = 6

The texture filter blends between the nearest 4 pixels and blends between 2 mipmaps (or uses the nearest mipmap if ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter is true) based on the angle between the surface and the camera view. This makes the texture look smooth from up close, and smooth from a distance. Anisotropic filtering improves texture quality on surfaces that are almost in line with the camera, but is slightly slower. The anisotropic filtering level can be changed by adjusting ProjectSettings.rendering/textures/default_filters/anisotropic_filtering_level. Note: This texture filter is rarely useful in 2D projects. CanvasItem.TextureFilterEnum.LinearWithMipmaps is usually more appropriate in this case.

Max = 7

Represents the size of the CanvasItem.TextureFilterEnum enum.

Nearest = 1

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

NearestWithMipmaps = 3

The texture filter reads from the nearest pixel and blends between the nearest 2 mipmaps (or uses the nearest mipmap if ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter is true). This makes the texture look pixelated from up close, and smooth from a distance. Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to Camera2D zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.

NearestWithMipmapsAnisotropic = 5

The texture filter reads from the nearest pixel and blends between 2 mipmaps (or uses the nearest mipmap if ProjectSettings.rendering/textures/default_filters/use_nearest_mipmap_filter is true) based on the angle between the surface and the camera view. This makes the texture look pixelated from up close, and smooth from a distance. Anisotropic filtering improves texture quality on surfaces that are almost in line with the camera, but is slightly slower. The anisotropic filtering level can be changed by adjusting ProjectSettings.rendering/textures/default_filters/anisotropic_filtering_level. Note: This texture filter is rarely useful in 2D projects. CanvasItem.TextureFilterEnum.NearestWithMipmaps is usually more appropriate in this case.

ParentNode = 0

The CanvasItem will inherit the filter from its parent.

CanvasItem.TextureRepeatEnum

ValueDescription
Disabled = 1

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.

Enabled = 2

The texture repeats when exceeding the texture's size.

Max = 4

Represents the size of the CanvasItem.TextureRepeatEnum enum.

Mirror = 3

The texture repeats when the exceeding the texture's size in a "2×2 tiled mode". Repeated textures at even positions are mirrored.

ParentNode = 0

The CanvasItem will inherit the repeat mode from its parent.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.