Skip to content

Commit b4583f4

Browse files
committed
Truncate to 5 in Vec String output
1 parent d449d09 commit b4583f4

4 files changed

Lines changed: 49 additions & 49 deletions

File tree

triangle_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func ExampleT() {
132132
Log("%v\n%v\n%v", t[0], t[1], t[2])
133133

134134
// Output:
135-
// {gfx.V(1, 2) {255 0 0 255} gfx.V(0, 0) 0}
136-
// {gfx.V(3, 4) {0 255 0 255} gfx.V(1, 1) 0}
137-
// {gfx.V(5, 6) {0 0 255 255} gfx.V(0, 0) 0.5}
135+
// {gfx.V(1.00000000, 2.00000000) {255 0 0 255} gfx.V(0.00000000, 0.00000000) 0}
136+
// {gfx.V(3.00000000, 4.00000000) {0 255 0 255} gfx.V(1.00000000, 1.00000000) 0}
137+
// {gfx.V(5.00000000, 6.00000000) {0 0 255 255} gfx.V(0.00000000, 0.00000000) 0.5}
138138
}

vec2.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ import (
1010
//
1111
// Create vectors with the V constructor:
1212
//
13-
// u := gfx.V(1, 2)
14-
// v := gfx.V(8, -3)
13+
// u := gfx.V(1, 2)
14+
// v := gfx.V(8, -3)
1515
//
1616
// Use various methods to manipulate them:
1717
//
18-
// w := u.Add(v)
19-
// fmt.Println(w) // gfx.V(9, -1)
20-
// fmt.Println(u.Sub(v)) // gfx.V(-7, 5)
21-
// u = gfx.V(2, 3)
22-
// v = gfx.V(8, 1)
23-
// if u.X < 0 {
24-
// fmt.Println("this won't happen")
25-
// }
26-
// x := u.Unit().Dot(v.Unit())
18+
// w := u.Add(v)
19+
// fmt.Println(w) // gfx.V(9, -1)
20+
// fmt.Println(u.Sub(v)) // gfx.V(-7, 5)
21+
// u = gfx.V(2, 3)
22+
// v = gfx.V(8, 1)
23+
// if u.X < 0 {
24+
// fmt.Println("this won't happen")
25+
// }
26+
// x := u.Unit().Dot(v.Unit())
2727
type Vec struct {
2828
X, Y float64
2929
}
@@ -56,11 +56,11 @@ func Unit(angle float64) Vec {
5656

5757
// String returns the string representation of the vector u.
5858
//
59-
// u := gfx.V(4.5, -1.3)
60-
// u.String() // returns "gfx.V(4.5, -1.3)"
61-
// fmt.Println(u) // gfx.V(4.5, -1.3)
59+
// u := gfx.V(4.5, -1.3)
60+
// u.String() // returns "gfx.V(4.5, -1.3)"
61+
// fmt.Println(u) // gfx.V(4.5, -1.3)
6262
func (u Vec) String() string {
63-
return fmt.Sprintf("gfx.V(%v, %v)", u.X, u.Y)
63+
return fmt.Sprintf("gfx.V(%.8f, %.8f)", u.X, u.Y)
6464
}
6565

6666
// XY returns the components of the vector in two return values.
@@ -212,8 +212,8 @@ func (u Vec) Project(v Vec) Vec {
212212
// Map applies the function f to both x and y components of the vector u and returns the modified
213213
// vector.
214214
//
215-
// u := gfx.V(10.5, -1.5)
216-
// v := u.Map(math.Floor) // v is gfx.V(10, -2), both components of u floored
215+
// u := gfx.V(10.5, -1.5)
216+
// v := u.Map(math.Floor) // v is gfx.V(10, -2), both components of u floored
217217
func (u Vec) Map(f func(float64) float64) Vec {
218218
return Vec{
219219
f(u.X),

vec2_test.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ func ExampleVecAdd() {
8484
)
8585

8686
// Output:
87-
// gfx.V(3, 4)
88-
// gfx.V(2, 1)
87+
// gfx.V(3.00000000, 4.00000000)
88+
// gfx.V(2.00000000, 1.00000000)
8989
}
9090

9191
func ExampleVecAddXY() {
@@ -95,8 +95,8 @@ func ExampleVecAddXY() {
9595
)
9696

9797
// Output:
98-
// gfx.V(3, 4)
99-
// gfx.V(2, 1)
98+
// gfx.V(3.00000000, 4.00000000)
99+
// gfx.V(2.00000000, 1.00000000)
100100
}
101101

102102
func ExampleVecSub() {
@@ -106,8 +106,8 @@ func ExampleVecSub() {
106106
)
107107

108108
// Output:
109-
// gfx.V(-1, -2)
110-
// gfx.V(4, 5)
109+
// gfx.V(-1.00000000, -2.00000000)
110+
// gfx.V(4.00000000, 5.00000000)
111111
}
112112

113113
func ExampleVecTo() {
@@ -117,8 +117,8 @@ func ExampleVecTo() {
117117
)
118118

119119
// Output:
120-
// gfx.V(1, 2)
121-
// gfx.V(-4, -5)
120+
// gfx.V(1.00000000, 2.00000000)
121+
// gfx.V(-4.00000000, -5.00000000)
122122
}
123123

124124
func ExampleVecMod() {
@@ -128,8 +128,8 @@ func ExampleVecMod() {
128128
)
129129

130130
// Output:
131-
// gfx.V(1, 1)
132-
// gfx.V(0, 2.5)
131+
// gfx.V(1.00000000, 1.00000000)
132+
// gfx.V(0.00000000, 2.50000000)
133133
}
134134

135135
func ExampleVecAbs() {
@@ -140,9 +140,9 @@ func ExampleVecAbs() {
140140
)
141141

142142
// Output:
143-
// gfx.V(1, 1)
144-
// gfx.V(2, 2)
145-
// gfx.V(3, 6)
143+
// gfx.V(1.00000000, 1.00000000)
144+
// gfx.V(2.00000000, 2.00000000)
145+
// gfx.V(3.00000000, 6.00000000)
146146
}
147147

148148
func ExampleVecMax() {
@@ -152,8 +152,8 @@ func ExampleVecMax() {
152152
)
153153

154154
// Output:
155-
// gfx.V(2.5, 3)
156-
// gfx.V(2, 5.5)
155+
// gfx.V(2.50000000, 3.00000000)
156+
// gfx.V(2.00000000, 5.50000000)
157157
}
158158

159159
func ExampleVecMin() {
@@ -163,8 +163,8 @@ func ExampleVecMin() {
163163
)
164164

165165
// Output:
166-
// gfx.V(1, 1)
167-
// gfx.V(2, 3)
166+
// gfx.V(1.00000000, 1.00000000)
167+
// gfx.V(2.00000000, 3.00000000)
168168
}
169169

170170
func ExampleVecDot() {
@@ -196,8 +196,8 @@ func ExampleVecProject() {
196196
)
197197

198198
// Output:
199-
// gfx.V(0.9016393442622951, 1.0819672131147542)
200-
// gfx.V(3.153846153846153, 4.73076923076923)
199+
// gfx.V(0.90163934, 1.08196721)
200+
// gfx.V(3.15384615, 4.73076923)
201201
}
202202

203203
func ExampleVecMap() {
@@ -207,8 +207,8 @@ func ExampleVecMap() {
207207
)
208208

209209
// Output:
210-
// gfx.V(2, 1)
211-
// gfx.V(1, 3)
210+
// gfx.V(2.00000000, 1.00000000)
211+
// gfx.V(1.00000000, 3.00000000)
212212
}
213213

214214
func ExampleVecVec3() {
@@ -289,11 +289,11 @@ func ExampleVecLerp() {
289289
)
290290

291291
// Output:
292-
// gfx.V(1, 2)
293-
// gfx.V(3.9, 5.8)
294-
// gfx.V(15.5, 21)
295-
// gfx.V(27.1, 36.2)
296-
// gfx.V(30, 40)
292+
// gfx.V(1.00000000, 2.00000000)
293+
// gfx.V(3.90000000, 5.80000000)
294+
// gfx.V(15.50000000, 21.00000000)
295+
// gfx.V(27.10000000, 36.20000000)
296+
// gfx.V(30.00000000, 40.00000000)
297297
}
298298

299299
func ExampleCentroid() {
@@ -303,6 +303,6 @@ func ExampleCentroid() {
303303
)
304304

305305
// Output:
306-
// gfx.V(3.3333333333333335, 2)
307-
// gfx.V(5, 3.3333333333333335)
306+
// gfx.V(3.33333333, 2.00000000)
307+
// gfx.V(5.00000000, 3.33333333)
308308
}

vertex_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ func ExampleVx() {
66
Dump(vx)
77

88
// Output:
9-
// {Position:gfx.V(6, 122) Color:{R:255 G:255 B:255 A:255} Picture:gfx.V(1, 1) Intensity:0.5}
9+
// {Position:gfx.V(6.00000000, 122.00000000) Color:{R:255 G:255 B:255 A:255} Picture:gfx.V(1.00000000, 1.00000000) Intensity:0.5}
1010
}

0 commit comments

Comments
 (0)