BeveledRectangle returns a rectangle of width w and height h with beveled corners at distance r from the corner.
(w, h, r float64)
| 72 | |
| 73 | // BeveledRectangle returns a rectangle of width w and height h with beveled corners at distance r from the corner. |
| 74 | func BeveledRectangle(w, h, r float64) *Path { |
| 75 | if Equal(w, 0.0) || Equal(h, 0.0) { |
| 76 | return &Path{} |
| 77 | } else if Equal(r, 0.0) { |
| 78 | return Rectangle(w, h) |
| 79 | } |
| 80 | |
| 81 | r = math.Abs(r) |
| 82 | r = math.Min(r, w/2.0) |
| 83 | r = math.Min(r, h/2.0) |
| 84 | |
| 85 | p := &Path{} |
| 86 | p.MoveTo(0.0, r) |
| 87 | p.LineTo(r, 0.0) |
| 88 | p.LineTo(w-r, 0.0) |
| 89 | p.LineTo(w, r) |
| 90 | p.LineTo(w, h-r) |
| 91 | p.LineTo(w-r, h) |
| 92 | p.LineTo(r, h) |
| 93 | p.LineTo(0.0, h-r) |
| 94 | p.Close() |
| 95 | return p |
| 96 | } |
| 97 | |
| 98 | // Circle returns a circle of radius r. |
| 99 | func Circle(r float64) *Path { |