Skip to content

Commit 423f4db

Browse files
committed
Post go fix
1 parent 75bd643 commit 423f4db

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

image.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,35 +118,35 @@ func (f *Image) biPatch(u, v float64, p [][]tcol.FRGBA) tcol.FRGBA {
118118
col := make([]float64, 4)
119119

120120
// R
121-
for j := 0; j < 4; j++ {
122-
for i := 0; i < 4; i++ {
121+
for j := range 4 {
122+
for i := range 4 {
123123
col[i] = p[i][j].R
124124
}
125125
row[j] = bcclamp(f.interp(v, col))
126126
}
127127
r := bcclamp(f.interp(u, row))
128128

129129
// G
130-
for j := 0; j < 4; j++ {
131-
for i := 0; i < 4; i++ {
130+
for j := range 4 {
131+
for i := range 4 {
132132
col[i] = p[i][j].G
133133
}
134134
row[j] = bcclamp(Cubic(v, col))
135135
}
136136
g := bcclamp(f.interp(u, row))
137137

138138
// B
139-
for j := 0; j < 4; j++ {
140-
for i := 0; i < 4; i++ {
139+
for j := range 4 {
140+
for i := range 4 {
141141
col[i] = p[i][j].B
142142
}
143143
row[j] = bcclamp(f.interp(v, col))
144144
}
145145
b := bcclamp(f.interp(u, row))
146146

147147
// A
148-
for j := 0; j < 4; j++ {
149-
for i := 0; i < 4; i++ {
148+
for j := range 4 {
149+
for i := range 4 {
150150
col[i] = p[i][j].A
151151
}
152152
row[j] = bcclamp(f.interp(v, col))

perlin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ func NewPerlin(seed int64) *Perlin {
2020
res.Seed = seed
2121

2222
// Initialize hash
23-
for i := 0; i < 256; i++ {
23+
for i := range 256 {
2424
res.ph[i] = uint8(i)
2525
}
2626

2727
lr := rand.New(rand.NewSource(seed))
2828
// Scramble hash
2929
lr.Shuffle(256, func(i, j int) { res.ph[i], res.ph[j] = res.ph[j], res.ph[i] })
3030
// And replicate
31-
for i := 0; i < 256; i++ {
31+
for i := range 256 {
3232
res.ph[i+256] = res.ph[i]
3333
}
3434

points.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ func NewWorleyField(points [][]float64, a, b []float64,
6262
scale, offset float64) *WorleyField {
6363
kdtree := datastruct.NewKDTree(2, points...)
6464
kdtree.Dist = d
65-
np := len(b)
66-
if np > len(points) {
67-
np = len(points)
68-
}
65+
np := min(len(b), len(points))
6966
return &WorleyField{"WorleyField", points, a, b, f, scale, offset, kdtree, np}
7067
}
7168

random/wave.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func MakePatternWave() texture.Wave {
1818
nl := rand.Intn(5) + 1
1919
lambdas := make([]float64, nl)
2020
patterns := make([][]float64, nl)
21-
for i := 0; i < nl; i++ {
21+
for i := range nl {
2222
lambdas[i] = PickLambda()
2323
patterns[i] = MakePattern(5)
2424
}
@@ -27,7 +27,7 @@ func MakePatternWave() texture.Wave {
2727

2828
func MakePattern(n int) []float64 {
2929
pat := make([]float64, n)
30-
for i := 0; i < n; i++ {
30+
for i := range n {
3131
pat[i] = rand.Float64()*2 - 1
3232
}
3333
return pat
@@ -38,7 +38,7 @@ func MakeNLWave() texture.Wave {
3838
nl := rand.Intn(5) + 1
3939
lambdas := make([]float64, nl)
4040
nlfs := make([]*texture.NonLinear, nl)
41-
for i := 0; i < nl; i++ {
41+
for i := range nl {
4242
lambdas[i] = PickLambda()
4343
nlfs[i] = MakeNL()
4444
}

wave.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func NewACWave(lambdas []float64, nlfs []*NonLinear, once bool) *ACWave {
217217
res.Lambdas[3] = lambdas[3]
218218
}
219219
sum := 0.0
220-
for i := 0; i < 4; i++ {
220+
for i := range 4 {
221221
sum += res.Lambdas[i]
222222
res.CumLambda[i] = sum
223223
}

0 commit comments

Comments
 (0)