GraphicsEditor/addons/Godoxel/CanvasOutline.gd

32 lines
678 B
GDScript3
Raw Permalink 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):
if not is_visible_in_tree():
return
2019-11-23 12:33:43 +01:00
update()