Created
March 29, 2024 02:37
-
-
Save Shilo/5abc29c73a8bd38cb302a50cdf509a53 to your computer and use it in GitHub Desktop.
Godot 4, PixelDream Line2D node for better line width and anti-aliasing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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