im making a tycoon game about mining bitcoin, to show the value of bitcoin over time i wanted to use a Line2D as a line graph, the problem is that the graph keeps expanding but the older points dont go away (they exist off screen) im not too sure if this will cause preformance drops at a certain point or if i can just ignore it, but just in case i would like to find a way to clear only the older points of the line 2d

code so far:

var x = 0
var lineX = 0

func _process(delta):
	x+=20
	
	$Line2D.add_point(Vector2(x, randi_range(20, 280)), 0)
	
	if x >= 500:
		lineX -= 20
		$Line2D.position = Vector2(lineX, 0)

I would think the simplest way is to delete the points that go offscreen.

if the 2d line has its own code you can tell it in the _process(delta) function:
func _process(delta):
if points.size() >100:
remove_point(0)

the value after size refers to the number of points in the line and remove_point(0) refers to the point to be removed (i.e. the first one).

    turtleguy955 by doing

    	if $Line2D.points.size() > 100:
    		$Line2D.remove_point(100)

    im able to get the effect i want