You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
881 B

2 years ago
class Loader{
dim: p5.Vector;
c: any;
radius: number;
center: p5.Vector;
angle: number;
constructor(dom: any){
this.dim = p.createVector($(dom).width(), $(dom).height());
this.c = p.createGraphics(this.dim.x, this.dim.y, 'p2d');
this.c.parent(dom);
this.radius = p.min([this.dim.x, this.dim.y]) * 0.4;
this.center = p.createVector(this.dim.x / 2, this.dim.y / 2);
$(dom).find('canvas').show();
this.angle = 0;
$(dom).show();
}
update(): void{
this.angle += p.PI / 10;
}
display(): void{
let c = this.c;
c.clear();
c.noFill();
c.stroke(0);
c.strokeWeight(5);
c.arc(this.center.x, this.center.y, this.radius * 2, this.radius * 2, this.angle, this.angle + p.PI + p.HALF_PI);
}
destroy(): void{
this.c.remove()
}
}