Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Godot 4+ specific ignores
.godot/
/android/
22 changes: 0 additions & 22 deletions addons/antialiased_line2d/antialiased_line2d.gd

This file was deleted.

33 changes: 33 additions & 0 deletions addons/antialiased_line2d/antialiased_line_2d.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@tool
@icon("antialiased_line_2d.svg")
class_name AntialiasedLine2D
extends Line2D

const TEXTURE = preload("antialiased_texture.res")

@export_storage var _is_instantiated := false


func _ready() -> void:
if _is_instantiated:
return

texture = TEXTURE
texture_mode = Line2D.LINE_TEXTURE_TILE
texture_filter = TextureFilter.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC

_is_instantiated = true


func _property_can_revert(property: StringName) -> bool:
return property in [&"texture", &"texture_mode", &"texture_filter"]


func _property_get_revert(property: StringName) -> Variant:
if property == &"texture":
return TEXTURE
elif property == &"texture_mode":
return Line2D.LINE_TEXTURE_TILE
elif property == &"texture_filter":
return TextureFilter.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC
return null
1 change: 1 addition & 0 deletions addons/antialiased_line2d/antialiased_line_2d.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://dn534defa6rgl
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,34 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://guodfckewtpv"
path="res://.godot/imported/antialiased_line2d.svg-9243613cd101e058db6c37ff468932c4.ctex"
path="res://.godot/imported/antialiased_line_2d.svg-e464e33122bc77a73cfbb4456f98b08b.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/antialiased_line2d/antialiased_line2d.svg"
dest_files=["res://.godot/imported/antialiased_line2d.svg-9243613cd101e058db6c37ff468932c4.ctex"]
source_file="res://addons/antialiased_line2d/antialiased_line_2d.svg"
dest_files=["res://.godot/imported/antialiased_line_2d.svg-e464e33122bc77a73cfbb4456f98b08b.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
Expand Down
55 changes: 0 additions & 55 deletions addons/antialiased_line2d/antialiased_polygon2d.gd

This file was deleted.

58 changes: 58 additions & 0 deletions addons/antialiased_line2d/antialiased_polygon_2d.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This is a convenience node that automatically synchronizes an AntialiasedLine2D
# with a Polygon2D.
@tool
@icon("antialiased_polygon_2d.svg")
class_name AntialiasedPolygon2D
extends Polygon2D

@export var stroke_color := Color.BLACK:
set = set_stroke_color
@export_range(0.0, 1000.0) var stroke_width: float = 10.0:
set = set_stroke_width
@export var stroke_joint_mode: Line2D.LineJointMode = Line2D.LINE_JOINT_SHARP:
set = set_stroke_joint_mode
@export_range(0.0, 1000.0) var stroke_sharp_limit: float = 2.0:
set = set_stroke_sharp_limit
@export_range(1, 32) var stroke_round_precision: int = 8:
set = set_stroke_round_precision

var antialiased_line_2d := AntialiasedLine2D.new()


func _ready() -> void:
draw.connect(func() -> void: antialiased_line_2d.points = polygon)

antialiased_line_2d.closed = true
add_child(antialiased_line_2d, false, Node.INTERNAL_MODE_FRONT)
antialiased_line_2d.owner = self

stroke_color = stroke_color
stroke_width = stroke_width
stroke_joint_mode = stroke_joint_mode
stroke_sharp_limit = stroke_sharp_limit
stroke_round_precision = stroke_round_precision


func set_stroke_color(p_stroke_color: Color) -> void:
stroke_color = p_stroke_color
antialiased_line_2d.default_color = stroke_color


func set_stroke_width(p_stroke_width: float) -> void:
stroke_width = p_stroke_width
antialiased_line_2d.width = stroke_width


func set_stroke_joint_mode(p_stroke_joint_mode: Line2D.LineJointMode) -> void:
stroke_joint_mode = p_stroke_joint_mode
antialiased_line_2d.joint_mode = stroke_joint_mode


func set_stroke_sharp_limit(p_stroke_sharp_limit: float) -> void:
stroke_sharp_limit = p_stroke_sharp_limit
antialiased_line_2d.sharp_limit = stroke_sharp_limit


func set_stroke_round_precision(p_stroke_round_precision: int) -> void:
stroke_round_precision = p_stroke_round_precision
antialiased_line_2d.round_precision = stroke_round_precision
1 change: 1 addition & 0 deletions addons/antialiased_line2d/antialiased_polygon_2d.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://cffrqtfahnwmy
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,34 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bkfc7y0qnfi4a"
path="res://.godot/imported/antialiased_polygon2d.svg-d9d32c42c22022e4f4053cee124a07c0.ctex"
path="res://.godot/imported/antialiased_polygon_2d.svg-551511e1467fb80a5d4a598652644318.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/antialiased_line2d/antialiased_polygon2d.svg"
dest_files=["res://.godot/imported/antialiased_polygon2d.svg-d9d32c42c22022e4f4053cee124a07c0.ctex"]
source_file="res://addons/antialiased_line2d/antialiased_polygon_2d.svg"
dest_files=["res://.godot/imported/antialiased_polygon_2d.svg-551511e1467fb80a5d4a598652644318.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
Expand Down
82 changes: 0 additions & 82 deletions addons/antialiased_line2d/antialiased_regular_polygon2d.gd

This file was deleted.

53 changes: 53 additions & 0 deletions addons/antialiased_line2d/antialiased_regular_polygon_2d.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This is a convenience node that automatically synchronizes an AntialiasedLine2D
# with a Polygon2D, while also generating a regular Polygon2D shape (hexagon, octagon, …).
@tool
@icon("antialiased_regular_polygon_2d.svg")
class_name AntialiasedRegularPolygon2D
extends AntialiasedPolygon2D

@export_custom(PROPERTY_HINT_LINK, "suffix:px") var size := Vector2(64.0, 64.0):
set = set_size
@export_range(3, 128, 1, "or_greater") var sides := 32:
set = set_sides
@export_range(-360, 360.0, 0.01, "radians_as_degrees", "prefer_slider") var arc := TAU:
set = set_arc


func _ready() -> void:
super()
for connection: Dictionary in draw.get_connections():
draw.disconnect(connection.callable)
_update_points()


func _update_points() -> void:
polygon = build_polygon(size, sides, arc)
antialiased_line_2d.points = polygon


func set_size(p_size: Vector2) -> void:
size = p_size
_update_points()


func set_sides(p_sides: int) -> void:
sides = p_sides
_update_points()


func set_arc(p_arc: float) -> void:
arc = clampf(p_arc, -TAU, TAU)
_update_points()


static func build_polygon(size: Vector2, sides := 32, arc := TAU, has_point_at_origin := true) -> PackedVector2Array:
var result := PackedVector2Array()
var half_size := size * 0.5
for side: int in range(sides):
result.push_back(Vector2.RIGHT.rotated(side / float(sides) * arc) * half_size)

if not is_equal_approx(absf(arc), TAU):
result.push_back(Vector2.RIGHT.rotated(arc) * half_size)
if has_point_at_origin:
result.push_back(Vector2.ZERO)
return result
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://do0g7nebwevll
Loading