-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
93 lines (78 loc) · 1.56 KB
/
test.js
File metadata and controls
93 lines (78 loc) · 1.56 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const boxes = [
redBox = {
color: 'red',
initial_pos: {x: 500, y: 500},
movementFn: {x: 1, y: -.3}
},
blueBox = {
color: 'blue',
initial_pos: {x: 100, y: 200},
movementFn: {x: .5, y: 1}
},
greenBox = {
color: 'green',
initial_pos: {x: 1, y: 450},
movementFn: {x: 2, y: -1}
},
purpleBox = {
color: 'purple',
initial_pos: {x: 800, y: 23},
movementFn: {x: 2, y: -2}
}
]
//boxes.forEach((box) => {
// console.log(box)
//})
function testObj({x, y}){
return {x, y}
}
class Cursor {
constructor() {
this.positon = {x: 0, y: 0};
}
setPosition({x, y}) {
this.positon = {x, y}
}
}
cursor = new Cursor();
cursor.setPosition({x:1, y:5})
const TestInterface = {
pos: {x: 0, y: 0},
method1() {
throw new Error('method1 not implmeneted')
}
};
class testI {
constructor() {
Object.assign(this, TestInterface);
}
showPos() {
console.log(this.pos);
}
}
class Coord1 {
constructor() {
this.a1 = 1;
this.a2 = 2;
}
getXY() {
return {a1: this.x, a2: this.y};
}
remapReturn(func, keys = {x: 'someX', y: 'someY'}) {
const boundFunc = func.bind(this);
const {x, y} = boundFunc();
return {
[keys.x]: x,
[keys.y]: y
}
}
}
const x = 1135.21385
console.log((Math.floor(x / 200) * 200 + 200))
function test() {
return {x: 1, y:2}
}
function rename({x, y}, keys = {xKey: 'newX', yKey: 'newY'}) {
return {[keys.xKey]: x, [keys.yKey]: y}
}
console.log(rename(test(), keys = {xKey: 'otherX', yKey: 'otherY'}))