MCPcopy Index your code
hub / github.com/fogleman/primitive / Mutate

Method Mutate

primitive/rectangle.go:120–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118}
119
120func (r *RotatedRectangle) Mutate() {
121 w := r.Worker.W
122 h := r.Worker.H
123 rnd := r.Worker.Rnd
124 switch rnd.Intn(3) {
125 case 0:
126 r.X = clampInt(r.X+int(rnd.NormFloat64()*16), 0, w-1)
127 r.Y = clampInt(r.Y+int(rnd.NormFloat64()*16), 0, h-1)
128 case 1:
129 r.Sx = clampInt(r.Sx+int(rnd.NormFloat64()*16), 1, w-1)
130 r.Sy = clampInt(r.Sy+int(rnd.NormFloat64()*16), 1, h-1)
131 case 2:
132 r.Angle = r.Angle + int(rnd.NormFloat64()*32)
133 }
134 // for !r.Valid() {
135 // r.Sx = clampInt(r.Sx+int(rnd.NormFloat64()*16), 0, w-1)
136 // r.Sy = clampInt(r.Sy+int(rnd.NormFloat64()*16), 0, h-1)
137 // }
138}
139
140func (r *RotatedRectangle) Valid() bool {
141 a, b := r.Sx, r.Sy

Callers 1

Calls 1

clampIntFunction · 0.85

Tested by

no test coverage detected