TypeError: np_d.changed is not a function

i have this error and i don;t know how fix it.

code:

	var np;
	var r = 300;
	var t;
	var alp;
	var point1 = [];
 function setup() {
   createCanvas(windowWidth, windowHeight);
	 np_d = document.getElementById("points");
	 t_d = document.getElementById("times");
	 alp_d = document.getElementById("alp");
	 np_d.changed(np_f); // error
	 t_d.changed(t_f);
	 alp_d.changed(alp_f);
 }
 function np_f(){np=Number(np_d.value);}
 function t_f(){t=Number(t_d.value);}
 function alp_f(){alp=10*Number(alp_f.value);}
function draw(){
	background(255, 0, 200);
	translate(width/2,height/2);
	cirs();
 }
function point2(angle){
		this.x = r * cos(angle);
		this.y = r * sin(angle);
}
function circ(){
	point1 = [];
	for (var i = 0 ;i < np; i++)
	{
	point1.push(new point2(map(i,0,np,0,TWO_PI)));
	}
	for (var i = 0 ;i < np; i++)
	{
	stroke(255,alp);
	strokeWeight(1);
	line(point1[i].x,point1[i].y,point1[(t*i)%np].x,point1[(t*i)%np].y);
	}
}

Method changed() belongs to class p5.Element:

However, the datatype of the object returned by method Document::getElementById() is an Element instead:


In order to get a p5.Element, replace Document::getElementById() w/ method p5::select():

3 Likes