(t *testing.T)
| 358 | } |
| 359 | |
| 360 | func TestPathBounds(t *testing.T) { |
| 361 | var tts = []struct { |
| 362 | p string |
| 363 | bounds Rect |
| 364 | }{ |
| 365 | {"", Rect{}}, |
| 366 | {"Q50 100 100 0", Rect{0, 0, 100, 50}}, |
| 367 | {"Q100 50 0 100", Rect{0, 0, 50, 100}}, |
| 368 | {"Q0 0 100 0", Rect{0, 0, 100, 0}}, |
| 369 | {"Q100 0 100 0", Rect{0, 0, 100, 0}}, |
| 370 | {"Q100 0 100 100", Rect{0, 0, 100, 100}}, |
| 371 | {"C0 0 100 0 100 0", Rect{0, 0, 100, 0}}, |
| 372 | {"C0 100 100 100 100 0", Rect{0, 0, 100, 75}}, |
| 373 | {"C0 0 100 90 100 0", Rect{0, 0, 100, 40}}, |
| 374 | {"C0 90 100 0 100 0", Rect{0, 0, 100, 40}}, |
| 375 | {"C100 100 0 100 100 0", Rect{0, 0, 100, 75}}, |
| 376 | {"C66.667 0 100 33.333 100 100", Rect{0, 0, 100, 100}}, |
| 377 | {"M3.1125 1.7812C3.4406 1.7812 3.5562 1.5938 3.4578 1.2656", Rect{3.1125, 1.2656, 3.1125 + 0.379252, 1.2656 + 0.515599}}, |
| 378 | {"A100 100 0 0 0 100 100", Rect{0, 0, 100, 100}}, |
| 379 | {"A50 100 90 0 0 200 0", Rect{0, 0, 200, 50}}, |
| 380 | {"A100 100 0 1 0 -100 100", Rect{-200, -100, 0, 100}}, // hit xmin, ymin |
| 381 | {"A100 100 0 1 1 -100 100", Rect{-100, 0, 100, 200}}, // hit xmax, ymax |
| 382 | } |
| 383 | origEpsilon := Epsilon |
| 384 | for _, tt := range tts { |
| 385 | t.Run(tt.p, func(t *testing.T) { |
| 386 | Epsilon = origEpsilon |
| 387 | bounds := MustParseSVGPath(tt.p).Bounds() |
| 388 | Epsilon = 1e-6 |
| 389 | test.T(t, bounds, tt.bounds) |
| 390 | }) |
| 391 | } |
| 392 | Epsilon = origEpsilon |
| 393 | } |
| 394 | |
| 395 | // for quadratic Bézier use https://www.wolframalpha.com/input/?i=length+of+the+curve+%7Bx%3D2*(1-t)*t*50.00+%2B+t%5E2*100.00,+y%3D2*(1-t)*t*66.67+%2B+t%5E2*0.00%7D+from+0+to+1 |
| 396 | // for cubic Bézier use https://www.wolframalpha.com/input/?i=length+of+the+curve+%7Bx%3D3*(1-t)%5E2*t*0.00+%2B+3*(1-t)*t%5E2*100.00+%2B+t%5E3*100.00,+y%3D3*(1-t)%5E2*t*66.67+%2B+3*(1-t)*t%5E2*66.67+%2B+t%5E3*0.00%7D+from+0+to+1 |
nothing calls this directly
no test coverage detected