generator: verified
This commit is contained in:
@@ -39,9 +39,6 @@ func NewBitmapPlotter(bm bitmap.Bitmap, factor float32) (Plotter, error) {
|
||||
}
|
||||
|
||||
func (p Plotter) RandomFreePoint(deadZoneRaduis float32) (float32, float32, error) {
|
||||
if deadZoneRaduis <= 0. {
|
||||
return 0, 0, fmt.Errorf("radius must be positive value: %f", deadZoneRaduis)
|
||||
}
|
||||
fsCount := p.freeCountFn()
|
||||
if fsCount == 0 {
|
||||
return 0, 0, errors.New("RandomFreePoint: no free space left")
|
||||
@@ -51,7 +48,9 @@ func (p Plotter) RandomFreePoint(deadZoneRaduis float32) (float32, float32, erro
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("RandomFreePoint: freeNumberToCoordFn: %s", err)
|
||||
}
|
||||
p.plotDeadZone(x, y, deadZoneRaduis)
|
||||
if deadZoneRaduis > 0 {
|
||||
p.plotDeadZone(x, y, deadZoneRaduis)
|
||||
}
|
||||
planetX := float32(x)*p.factor + rand.Float32()*p.factor
|
||||
planetY := float32(y)*p.factor + rand.Float32()*p.factor
|
||||
return planetX, planetY, nil
|
||||
|
||||
Reference in New Issue
Block a user