es6 syntax learning
This commit is contained in:
parent
a463c64b01
commit
42f5b4fb63
@ -1,7 +1,6 @@
|
|||||||
import Color from "./color.js";
|
import Color from "./color.js";
|
||||||
|
|
||||||
class Canvas {
|
class Canvas {
|
||||||
element;
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.element = document.createElement("canvas");
|
this.element = document.createElement("canvas");
|
||||||
this.element.width = 1000;
|
this.element.width = 1000;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import Shape from "./shape.js";
|
import Shape from "./shape.js";
|
||||||
|
|
||||||
class Rectangle extends Shape {
|
class Rectangle extends Shape {
|
||||||
className = "Rectangle";
|
|
||||||
|
|
||||||
constructor(x, y, color, width, height) {
|
constructor(x, y, color, width, height) {
|
||||||
super(x, y, color);
|
super(x, y, color);
|
||||||
|
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
import Color from "./color.js";
|
import Color from "./color.js";
|
||||||
|
|
||||||
class Shape {
|
class Shape {
|
||||||
className = "Shape";
|
|
||||||
color;
|
|
||||||
|
|
||||||
constructor(x, y, color) {
|
constructor(x, y, color) {
|
||||||
this._x = x;
|
this._x = x;
|
||||||
this._y = y;
|
this._y = y;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
draw(context) {
|
draw(context) {
|
||||||
throw new Error("A pure virtual method call of a shape " + this.className);
|
throw new Error("A pure virtual method call of a shape " + this.constructor.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static randomOptions() {
|
static randomOptions() {
|
||||||
|
Loading…
Reference in New Issue
Block a user