summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorrom <romangraef@gmail.com>2021-04-26 21:26:11 +0200
committerrom <romangraef@gmail.com>2021-04-26 21:26:11 +0200
commit9f0db7bd713739c2da8b2cbfb9acb29b13f940e1 (patch)
tree65fb4c5caf16a0b5c2028ee750c0f77516df026e /components
parent85da9f59bad9ae98e61820f9feaff0dd5968228f (diff)
downloadldjam48-9f0db7bd713739c2da8b2cbfb9acb29b13f940e1.tar.gz
ldjam48-9f0db7bd713739c2da8b2cbfb9acb29b13f940e1.tar.bz2
ldjam48-9f0db7bd713739c2da8b2cbfb9acb29b13f940e1.zip
pathcolor go brr
Diffstat (limited to 'components')
-rw-r--r--components/PathRenderer.gd11
1 files changed, 10 insertions, 1 deletions
diff --git a/components/PathRenderer.gd b/components/PathRenderer.gd
index 14853ce..ab5e19f 100644
--- a/components/PathRenderer.gd
+++ b/components/PathRenderer.gd
@@ -3,6 +3,7 @@ extends Node2D
class_name PathRenderer
export var path_color : Color = Color.brown setget _color
+export var target_color : Color = Color.red setget _target_color
export var stroke_width : int = 6 setget _width
var path : Path2D = null setget _path
@@ -14,6 +15,10 @@ func _color(value):
path_color = value
update()
+func _target_color(value):
+ target_color = value
+ update()
+
func _path(value):
path = value
update()
@@ -23,9 +28,13 @@ func _draw():
return
var last_point = null
var points = path.curve.get_baked_points()
+ var length = path.curve.get_baked_length()
+ var dist = 0
for point in points:
if last_point == null:
last_point = point
continue
- draw_line(last_point, point, path_color, stroke_width, false)
+ dist += (last_point - point).length()
+ var col = lerp(path_color, target_color, dist / length)
+ draw_line(last_point, point, col, stroke_width, false)
last_point = point