validArea validates the provided area.
(ar image.Rectangle)
| 112 | |
| 113 | // validArea validates the provided area. |
| 114 | func validArea(ar image.Rectangle) error { |
| 115 | if ar.Min.X < 0 || ar.Min.Y < 0 { |
| 116 | return fmt.Errorf("the start coordinates cannot be negative, got: %v", ar) |
| 117 | } |
| 118 | if ar.Max.X < 0 || ar.Max.Y < 0 { |
| 119 | return fmt.Errorf("the end coordinates cannot be negative, got: %v", ar) |
| 120 | } |
| 121 | if ar.Dx() < 1 || ar.Dy() < 1 { |
| 122 | return fmt.Errorf("the area for the segment must be at least 1x1 pixels, got %vx%v in area:%v", ar.Dx(), ar.Dy(), ar) |
| 123 | } |
| 124 | return nil |
| 125 | } |
| 126 | |
| 127 | // HV draws a horizontal or a vertical display segment, filling the provided area. |
| 128 | // The segment will have slopes on both of its ends. |