GraphicsEditor/addons/graphics_editor/CanvasOutline.gd

30 lines
639 B
GDScript3
Raw Normal View History

2019-08-04 09:57:42 +02:00
tool
extends Control
export var color = Color()
2019-08-04 09:57:42 +02:00
func _ready():
pass
2019-08-04 09:57:42 +02:00
func _draw():
var size = get_parent().rect_size
var pos = Vector2.ZERO #get_parent().rect_global_position
2020-10-25 18:39:10 +01:00
draw_outline_box(pos, size, color, 1)
2019-08-04 09:57:42 +02:00
2020-10-25 18:39:10 +01:00
func draw_outline_box(pos, size, color, width):
2019-08-04 09:57:42 +02:00
#Top line
2020-10-25 18:39:10 +01:00
draw_line(pos, pos + Vector2(size.x, 0), color, width)
2019-08-04 09:57:42 +02:00
#Left line
2020-10-25 18:39:10 +01:00
draw_line(pos, pos + Vector2(0, size.y), color, width)
2019-08-04 09:57:42 +02:00
#Bottom line
2020-10-25 18:39:10 +01:00
draw_line(pos + Vector2(0, size.y), pos + Vector2(size.x, size.y), color, width)
2019-08-04 09:57:42 +02:00
#Right line
2020-10-25 18:39:10 +01:00
draw_line(pos + Vector2(size.x, 0), pos + Vector2(size.x, size.y), color, width)
2019-08-04 09:57:42 +02:00
2019-08-04 09:57:42 +02:00
func _process(delta):
2019-11-23 12:33:43 +01:00
update()