This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
/
geometry.go
170 lines (149 loc) · 3.66 KB
/
geometry.go
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// +build js,wasm
package wasm
// https://www.w3.org/TR/geometry-1/#idl-index
type (
// https://www.w3.org/TR/geometry-1/#dom-dompointreadonly
DOMPointReadOnly interface {
X() float64
Y() float64
Z() float64
W() float64
MatrixTransform(DOMMatrixReadOnly) DOMPoint
}
// https://www.w3.org/TR/geometry-1/#dom-dompoint
DOMPoint interface {
DOMPointReadOnly
}
// https://www.w3.org/TR/geometry-1/#dom-domrect
DOMRect interface {
DOMRectReadOnly
}
// https://www.w3.org/TR/geometry-1/#dom-domrectreadonly
DOMRectReadOnly interface {
X() float64
Y() float64
Width() float64
Height() float64
Top() float64
Right() float64
Bottom() float64
Left() float64
}
// https://www.w3.org/TR/geometry-1/#dom-domquad
DOMQuad interface {
P1() DOMPoint
P2() DOMPoint
P3() DOMPoint
P4() DOMPoint
Bounds() DOMRectReadOnly
}
// https://www.w3.org/TR/geometry-1/#dom-dommatrixreadonly
DOMMatrixReadOnly interface {
A() float64
B() float64
C() float64
D() float64
E() float64
F() float64
M11() float64
M12() float64
M13() float64
M14() float64
M21() float64
M22() float64
M23() float64
M24() float64
M31() float64
M32() float64
M33() float64
M34() float64
M41() float64
M42() float64
M43() float64
M44() float64
Is2D() bool
IsIdentity() bool
Translate(float64, float64, ...float64) DOMMatrix
Scale(float64, ...float64) DOMMatrix
Scale3d(float64, ...float64) DOMMatrix
ScaleNonUniform(float64, ...float64) DOMMatrix
Rotate(float64, ...float64) DOMMatrix
RotateFromVector(float64, float64) DOMMatrix
RotateAxisAngle(float64, float64, float64, float64) DOMMatrix
SkewX(float64) DOMMatrix
SkewY(float64) DOMMatrix
Multiply(DOMMatrix) DOMMatrix
FlipX() DOMMatrix
FlipY() DOMMatrix
Inverse() DOMMatrix
TransformPoint(...DOMPointInit) DOMPoint
ToFloat32Array() []float32 //Float32Array
ToFloat64Array() []float64 // Float64Array
String() string
}
// https://www.w3.org/TR/geometry-1/#dom-dommatrix
DOMMatrix interface {
DOMMatrixReadOnly
MultiplySelf(DOMMatrix) DOMMatrix
PreMultiplySelf(DOMMatrix) DOMMatrix
TranslateSelf(float64, float64, ...float64) DOMMatrix
ScaleSelf(float64, ...float64) DOMMatrix
Scale3dSelf(float64, ...float64) DOMMatrix
ScaleNonUniformSelf(float64, ...float64) DOMMatrix
RotateSelf(float64, ...float64) DOMMatrix
RotateFromVectorSelf(float64, float64) DOMMatrix
RotateAxisAngleSelf(float64, float64, float64, float64) DOMMatrix
SkewXSelf(float64) DOMMatrix
SkewYSelf(float64) DOMMatrix
InverseSelf() DOMMatrix
SetMatrixValue(string) DOMMatrix
}
)
// -------------8<---------------------------------------
// https://www.w3.org/TR/geometry-1/#dictdef-dompointinit
type DOMPointInit struct {
X float64
Y float64
Z float64
W float64 //default 1
}
func (p DOMPointInit) JSValue() jsValue {
o := jsObject.New()
o.Set("x", p.X)
o.Set("y", p.Y)
o.Set("z", p.Z)
o.Set("w", p.W)
return o
}
// -------------8<---------------------------------------
// https://www.w3.org/TR/geometry-1/#dictdef-domrectinit
type DOMRectInit struct {
X float64
Y float64
Width float64
Height float64
}
func (p DOMRectInit) JSValue() jsValue {
o := jsObject.New()
o.Set("x", p.X)
o.Set("y", p.Y)
o.Set("width", p.Width)
o.Set("height", p.Height)
return o
}
// -------------8<---------------------------------------
//https://drafts.fxtf.org/geometry-1/#dictdef-domquadinit
type DOMQuadInit struct {
P1 DOMPointInit
P2 DOMPointInit
P3 DOMPointInit
P4 DOMPointInit
}
func (p DOMQuadInit) JSValue() jsValue {
o := jsObject.New()
o.Set("p1", p.P1.JSValue())
o.Set("p2", p.P2.JSValue())
o.Set("p3", p.P3.JSValue())
o.Set("p4", p.P4.JSValue())
return o
}