Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 1x 128x 64x 64x 64x 1x 1x | /**
* @author Antonio Raúl Guijarro Contreras <alu0101100494@ull.edu.es>
* @file Declaration of the class Point where it represents a mathematical point
* @copyright Antonio Raúl Guijarro Contreras 2020
* @since 05.03.2020
*/
'use strinc'
import Shape from "./Shape.js";
/**
* Representa una coordenada en el plano
*/
class Point extends Shape{
/**
* Constructor de la clase punto
* @param {number} x_ Coordinates of x position
* @param {number} y_ Coordinates of y position
*/
constructor(x_ = 0, y_ = 0) {
super();
this.x = x_;
this.y = y_;
}
/**
* Asigna las coordenadas al punto
* @param {number} x coordenada x
* @param {number} y coordenada y
*/
set(coodinates) {
this.x = coodinates[0];
this.y = coodinates[1];
}
/**
* @return {Array} retorna las coordenadas que almacena la clase punto en forma de array.
*/
get() {
return [this.x, this.y];
}
/* istanbul ignore next */
/**
* Se encarga de dibujar la figura que representa la clase
* @param {Context} ctx Contexto del canvas, preferiblemente '2d'
*/
draw(ctx) {
Iif (ctx != null) {
this.baseDraw(ctx);
ctx.rect(this.x, this.y, 1, 1);
ctx.stroke();
ctx.fill();
}
}
};
export default Point;
|