Browse Source

made some introductions

unknown 3 years ago
parent
commit
8bb674ac2e
2 changed files with 4 additions and 16 deletions
  1. 1 1
      html-css/index.html
  2. 3 15
      javascript/hw.js

+ 1 - 1
html-css/index.html

@@ -19,7 +19,7 @@
 				<option value="rectangle">Rectangle</option>
 				<option value="ellipse">Ellipse</option>
 				<input type="number" id="size" value="10" />
-				<button class="btnDelete" id="delete">Delete...</button>
+				<button class="btnDelete" id="remove">Remove...</button>
 			</select>
 		</div>
 	</body>

+ 3 - 15
javascript/hw.js

@@ -98,7 +98,7 @@ const tools = {
 };
 
 function superHandler(evt) {
-	let t = tools[tool.value];
+	const t = tools[tool.value];
 	if (typeof t[evt.type] === 'function') t[evt.type].call(this, evt);
 }
 
@@ -165,10 +165,6 @@ class Circle extends Drawable {
 	in(x, y) {
 		return this.distanceTo(x, y) < this.radius;
 	}
-
-	inBounds(x, y, w, h) {
-		return this.x >= x && this.x <= x + w && this.y >= y && this.y <= y + h;
-	}
 }
 
 class Line extends Drawable {
@@ -211,10 +207,6 @@ class Line extends Drawable {
 			rotateY >= -this.lineWidth / 2
 		);
 	}
-
-	get length() {
-		return this.distanceTo(this.x + this.width, this.y + this.height);
-	}
 }
 
 class Rectangle extends Drawable {
@@ -284,18 +276,14 @@ class Ellipse extends Drawable {
 	in(x, y) {
 		return this.distanceTo(x, y) < this.radius;
 	}
-
-	inBounds(x, y, w, h) {
-		return this.x >= x && this.x <= x + w && this.y >= y && this.y <= y + h;
-	}
 }
 
-document.getElementById('delete').onclick = () => {
+remove.onclick = () => {
 	Drawable.instances = [];
 	Drawable.drawAll();
 };
 
-document.getElementById('undo').onclick = function () {
+undo.onclick = function () {
 	Drawable.instances.pop();
 	Drawable.drawAll();
 };