GraphicsEditor/addons/graphics_editor/CanvasOutline.gd

28 lines
697 B
GDScript3
Raw Normal View History

2019-08-04 09:57:42 +02:00
tool
extends Control
export var color = Color()
func _ready():
pass
func _draw():
2020-10-25 18:39:10 +01:00
var size = get_parent().get_node("Grids").rect_size
var pos = get_parent().get_node("Grids").rect_position
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
pos -= Vector2(0, 0)
size += Vector2(0, 0)
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
func _process(delta):
2019-11-23 12:33:43 +01:00
update()