Index of every page on this site: llms.txt
All skills
jame581 avatar

/2d-essentials

@426e8ab
by Jan Mesarčjame581/godotprompter979 stars
63
Run it yourself

Use when working with 2D-specific systems — TileMaps, parallax scrolling, 2D lights and shadows, canvas layers, particles 2D, custom drawing, and 2D meshes in Godot 4.3+

Use this Skill: https://skilld.dev/gh/jame581/godotprompter/2d-essentials

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescustom-drawing.md

≈780 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Custom Drawing

Reference for skills/2d-essentials/SKILL.md — _draw() method, redrawing patterns, full drawing methods reference, default font usage, editor preview with @tool, line-width tip.

← Back to SKILL.md


6. Custom Drawing

The _draw() Method

Override _draw() on any CanvasItem-derived node (Node2D or Control) for custom rendering.

extends Node2D

func _draw() -> void:
    draw_circle(Vector2.ZERO, 50.0, Color.RED)
    draw_rect(Rect2(-25, -25, 50, 50), Color.BLUE, false, 2.0)
    draw_line(Vector2(-100, 0), Vector2(100, 0), Color.WHITE, 2.0, true)
public partial class CustomDraw : Node2D
{
    public override void _Draw()
    {
        DrawCircle(Vector2.Zero, 50f, Colors.Red);
        DrawRect(new Rect2(-25, -25, 50, 50), Colors.Blue, false, 2f);
        DrawLine(new Vector2(-100, 0), new Vector2(100, 0), Colors.White, 2f, true);
    }
}

Redrawing

_draw() is called once and cached. Call queue_redraw() to trigger a redraw.

@export var radius: float = 50.0:
    set(value):
        radius = value
        queue_redraw()  # Redraw when property changes

func _draw() -> void:
    draw_circle(Vector2.ZERO, radius, Color.RED)
private float _radius = 50f;
[Export]
public float Radius
{
    get => _radius;
    set { _radius = value; QueueRedraw(); }
}

public override void _Draw()
{
    DrawCircle(Vector2.Zero, _radius, Colors.Red);
}

For per-frame animation, call queue_redraw() from _process().

Drawing Methods Reference

Method Description
draw_line(from, to, color, width, antialiased) Single line segment
draw_multiline(points, color, width) Multiple disconnected lines (better performance)
draw_polyline(points, color, width, antialiased) Connected line sequence
draw_polygon(points, colors) Filled polygon (auto-closes)
draw_circle(center, radius, color) Filled circle
draw_arc(center, radius, start, end, segments, color, width, aa) Arc / partial circle
draw_rect(rect, color, filled, width) Rectangle (filled or outline)
draw_texture(texture, position) Draw a texture
draw_string(font, position, text, alignment, width, font_size) Draw text
draw_set_transform(position, rotation, scale) Apply transform for subsequent draws (rotation/scale optional)

Default Font

var font: Font = ThemeDB.fallback_font

func _draw() -> void:
    draw_string(font, Vector2(10, 30), "Score: 100", HORIZONTAL_ALIGNMENT_LEFT, -1, 16)
private Font _font = ThemeDB.FallbackFont;

public override void _Draw()
{
    DrawString(_font, new Vector2(10, 30), "Score: 100", HorizontalAlignment.Left, -1, 16);
}

Editor Preview with @tool

Add @tool (GDScript) or [Tool] (C#) to see custom drawing in the editor. Requires scene reload after adding/removing the annotation.

Line Width Tip

Odd-width lines (1px, 3px): offset start/end positions by 0.5 to center the line on a pixel boundary and avoid subpixel blurriness.


Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts29d3 checks · Risk SAFE
  • Gen Agent Trust Hub29d

    The skill provides legitimate documentation and code examples for 2D game development in Godot 4.3+, covering TileMaps, parallax, lighting, and particles. No security risks were identified.

  • Socket29d

    No alerts

  • Snyk29d

    Risk: LOW · No issues

Signed by skilld at 426e8ab. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 6 days ago.

Activeupdated last month

README badge

README badge for jame581/godotprompter/2d-essentials