-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathcoretypes.js
127 lines (119 loc) · 2.04 KB
/
coretypes.js
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// author Adam G. Freeman, [email protected] 01/26/2019
// Of course this is just a tiny subset of all the junkola ...
export class CvScalar {
constructor(v0val, v1val, v2val, v3val) {
let v0, v1, v2, v3
if (v3val) {
v3 = v3val
}
else {
v3 = 0.0
}
if (v2val) {
v2 = v2val
}
else {
v2 = 0.0
}
if (v1val) {
v1 = v1val
}
else {
v1 = 0.0
}
if (v0val) {
v0 = v0val
}
else {
v0 = 0.0
}
this.vals = [v0,v1,v2,v3]
}
static all(allval) {
let res = new CvScalar()
res.vals = [allval,allval,allval,allval]
return res
}
set = (vals) => {
let v0, v1, v2, v3
if (vals) {
v0 = vals.length > 0 ? vals[0] : 0.0
v1 = vals.length > 1 ? vals[1] : 0.0
v2 = vals.length > 2 ? vals[2] : 0.0
v3 = vals.length > 3 ? vals[3] : 0.0
}
else {
v0 = v1 = v2 = v3 = 0.0
}
this.vals = [v0,v1,v2,v3]
}
}
export class CvPoint {
constructor(xval, yval) {
if (xval && yval) {
this.x = xval
this.y = yval
}
else {
this.x = 0.0
this.y = 0.0
}
}
set = (vals) => {
if (vals) {
this.x = vals.length > 0 ? vals[0] : 0.0
this.y = vals.length > 1 ? vals[1] : 0.0
}
else {
this.x = 0.0
this.y = 0.0
}
}
dot = (otherPt) => {
return (this.x * otherPt.x + this.y * otherPt.y)
}
}
export class CvSize {
constructor(width, height) {
if (width) {
this.width = width
}
else {
this.width = 0.0
}
if (height) {
this.height = height
}
else {
this.height = 0.0
}
}
}
export class CvRect {
constructor(top, left, width, height) {
if (top) {
this.top = top
}
else {
this.top = 0.0
}
if (left) {
this.left = left
}
else {
this.left = 0.0
}
if (width) {
this.width = width
}
else {
this.width = 0.0
}
if (height) {
this.height = height
}
else {
this.height = 0.0
}
}
}