Skip to content

Instantly share code, notes, and snippets.

@Shilo
Created March 29, 2024 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shilo/5abc29c73a8bd38cb302a50cdf509a53 to your computer and use it in GitHub Desktop.
Save Shilo/5abc29c73a8bd38cb302a50cdf509a53 to your computer and use it in GitHub Desktop.
Godot 4, PixelDream Line2D node for better line width and anti-aliasing.
@tool
class_name PDLine2D extends Node2D
@export var points: Array[Vector2i] = []:
set(value):
points = value
queue_redraw()
@export var color: Color = Color.WHITE:
set(value):
color = value
queue_redraw()
@export var width: float = -1:
set(value):
width = value
queue_redraw()
@export var antialiasing: bool = false:
set(value):
antialiasing = value
queue_redraw()
func _draw() -> void:
var last_point = null
for point in points:
if last_point != null:
draw_line(last_point, point, color, width, antialiasing)
last_point = point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment