Same returns true if p and q are equal shapes within tolerance Epsilon. Path q may start at an offset into path p or may be in the reverse direction.
(q *Path)
| 210 | |
| 211 | // Same returns true if p and q are equal shapes within tolerance Epsilon. Path q may start at an offset into path p or may be in the reverse direction. |
| 212 | func (p *Path) Same(q *Path) bool { |
| 213 | // TODO: improve, does not handle subpaths or Close vs LineTo |
| 214 | if len(p.d) != len(q.d) { |
| 215 | return false |
| 216 | } |
| 217 | qr := q.Reverse() // TODO: can we do without? |
| 218 | for j := 0; j < len(q.d); { |
| 219 | equal := true |
| 220 | for i := 0; i < len(p.d); i++ { |
| 221 | if !Equal(p.d[i], q.d[(j+i)%len(q.d)]) { |
| 222 | equal = false |
| 223 | break |
| 224 | } |
| 225 | } |
| 226 | if equal { |
| 227 | return true |
| 228 | } |
| 229 | |
| 230 | // backwards |
| 231 | equal = true |
| 232 | for i := 0; i < len(p.d); i++ { |
| 233 | if !Equal(p.d[i], qr.d[(j+i)%len(qr.d)]) { |
| 234 | equal = false |
| 235 | break |
| 236 | } |
| 237 | } |
| 238 | if equal { |
| 239 | return true |
| 240 | } |
| 241 | j += cmdLen(q.d[j]) |
| 242 | } |
| 243 | return false |
| 244 | } |
| 245 | |
| 246 | // Closed returns true if the last subpath of p is a closed path. |
| 247 | func (p *Path) Closed() bool { |