Base class of anything 2D.
Base class of anything 2D. Canvas items are laid out in a tree and children inherit and extend the transform of their parent. CanvasItem is extended by [Control], for anything GUI related, and by [Node2D] for anything 2D engine related. Any CanvasItem can draw. For this, the "update" function must be called, then NOTIFICATION_DRAW will be received on idle time to request redraw. Because of this, canvas items don't need to be redraw on every frame, improving the performance significantly. Several functions for drawing on the CanvasItem are provided (see draw_* functions). They can only be used inside the notification, signal or _draw() overrides function, though. Canvas items are draw in tree order. By default, children are on top of their parents so a root CanvasItem will be drawn behind everything (this can be changed per item though). Canvas items can also be hidden (hiding also their subtree). They provide many means for changing standard parameters such as opacity (for it and the subtree) and self opacity, blend mode. Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
Called (if exists) to draw the canvas item.
Draw a string character using a custom font. Returns the advance, depending on the char width and kerning with an optional next char.
Draw a colored circle.
Draw a colored polygon of any amount of points, convex or concave.
Draw a line from a 2D point to another, with a given color and width. It can be optionally antialiased.
Draw a polygon of any amount of points, convex or concave.
Draw a custom primitive, 1 point for a point, 2 points for a line, 3 points for a triangle and 4 points for a quad.
Draw a colored rectangle.
Set a custom transform for drawing. Anything drawn afterwards will be transformed by this.
Draw a string using a custom font.
Draw a styled rectangle.
Draw a texture at a given position.
Draw a textured rectangle at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
Draw a textured rectangle region at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
Used for editing, returns an opaque value representing the transform state.
Used for editing, handle rotation.
Set the transform state of this CanvasItem. For [Node2D], this is an [Array] with (in order) a [Vector2] for position, a float for rotation (radians) and another [Vector2] for scale. For [Control] this is a [Rect2] with the position and size.
Return the [RID] of the [World2D] canvas where this item is in.
Return the canvas item RID used by [VisualServer] for this item.
Get the transform matrix of this item's canvas.
Get the global position of the mouse.
Get the global transform matrix of this item.
Get the global transform matrix of this item in relation to the canvas.
Get a [Rect2] with the boundaries of this item and its children.
Return a rect containing the editable boundaries of the item.
Get this item's light mask number.
Get the mouse position relative to this item's position.
Get the material of this item.
Get the modulate of the CanvasItem, which affects children items too.
Get the self-modulate of the CanvasItem.
Get the transform matrix of this item.
Get whether this item uses its parent's material.
Get the viewport's boundaries as a [Rect2].
Get this item's transform in relation to the viewport.
Get the [World2D] where this item is in.
Hide the CanvasItem currently visible.
Return whether the item is drawn behind its parent.
Return if set as toplevel. See [method set_as_toplevel].
Return true if this CanvasItem is visible. It may be invisible because itself or a parent canvas item is hidden.
Set as top level. This means that it will not inherit transform from parent canvas items.
Set whether the canvas item is drawn behind its parent.
Set the ligtht mask number of this item.
Set the material of this item.
Set the modulate of the CanvasItem. This [i]affects[/i] the modulation of children items.
Set the self-modulate of the CanvasItem. This does not affect the modulation of children items.
Set whether or not this item should use its parent's material.
Set whether this item should be visible or not. Note that a hidden CanvasItem will make all children hidden too, so no matter what is set here this item won't be shown if its parent or grandparents nodes are hidden.
Show the CanvasItem currently hidden.
Queue the CanvasItem for update. [code]NOTIFICATION_DRAW[/code] will be called on idle time to request redraw.
Emitted when the CanvasItem must redraw. This can only be connected realtime, as deferred will not allow drawing.
Emitted when becoming hidden.
Emitted when the item rect has changed.
Emitted when the visibility (hidden/visible) changes.
Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value.
Additive blending mode.
Subtractive blending mode.
Multiplicative blending mode.
Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value.
Canvas item transform has changed. Only received if requested.
CanvasItem is requested to draw.
Canvas item visibility has changed.
Canvas item has entered the canvas.
Canvas item has exited the canvas.