Is it possible to have a Polygon2D with outline?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kakoeimon
:warning: Old Version Published before Godot 3 was released.

Is it possible to have a Polygon2D with outline?

:bust_in_silhouette: Reply From: twinpixel

You could create a script with a draw function, which reads out the polygon segments and draws a line with a certain thickness and color for each.

Thanks, this is a good answer. For some reason I was trying to find another way.

kakoeimon | 2016-05-13 09:01

:bust_in_silhouette: Reply From: kakoeimon

Here the little script I made for this.

extends Polygon2D

export(Color) var OutLine = Color(0,0,0) setget set_color
export(float) var Width = 2.0 setget set_width

func _draw():
	var poly = get_polygon()
	for i in range(1 , poly.size()):
		draw_line(poly[i-1] , poly[i], OutLine , Width)
	draw_line(poly[poly.size() - 1] , poly[0], OutLine , Width)
func set_color(color):
	OutLine = color
func set_width(new_width):
	Width = new_width