TestMultiFunction tests a Dasher's ability to function as a filler, stroker, and dasher by invoking the corresponding anonymous structs
(t *testing.T)
| 569 | // TestMultiFunction tests a Dasher's ability to function |
| 570 | // as a filler, stroker, and dasher by invoking the corresponding anonymous structs |
| 571 | func TestMultiFunction(t *testing.T) { |
| 572 | |
| 573 | var ( |
| 574 | wx, wy = 512, 512 |
| 575 | img = image.NewRGBA(image.Rect(0, 0, wx, wy)) |
| 576 | scanner = scan.NewScanner(scan.NewImgSpanner(img), wx, wy) |
| 577 | ) |
| 578 | |
| 579 | scanner.SetColor(colors.Uniform(colors.Cornflowerblue)) |
| 580 | d := NewDasher(wx, wy, scanner) |
| 581 | d.SetStroke(10*64, 4*64, RoundCap, nil, RoundGap, ArcClip, []float32{33, 12}, 0) |
| 582 | // p is in the shape of a capital Q |
| 583 | p := GetTestPath() |
| 584 | |
| 585 | f := &d.Filler // This is the anon Filler in the Dasher. It also satisfies |
| 586 | // the Rasterizer interface, and will only perform a fill on the path. |
| 587 | |
| 588 | p.AddTo(f) |
| 589 | |
| 590 | extentR := scanner.GetPathExtent() |
| 591 | x := int(extentR.Max.X) |
| 592 | y := int(extentR.Max.Y) |
| 593 | if x != 13445 && y != 15676 { |
| 594 | t.Error("test extent Max value not as expected") |
| 595 | } |
| 596 | f.Draw() |
| 597 | f.Clear() |
| 598 | |
| 599 | scanner.SetColor(colors.Uniform(colors.Cornsilk)) |
| 600 | |
| 601 | s := &d.Stroker // This is the anon Stroke in the Dasher. It also satisfies |
| 602 | // the Rasterizer interface, but will perform a fill on the path. |
| 603 | p.AddTo(s) |
| 604 | s.Draw() |
| 605 | s.Clear() |
| 606 | |
| 607 | scanner.SetColor(colors.Uniform(colors.Darkolivegreen)) |
| 608 | |
| 609 | // Now lets use the Dasher itself; it will perform a dashed stroke if dashes are set |
| 610 | // in the SetStroke method. |
| 611 | p.AddTo(d) |
| 612 | d.Draw() |
| 613 | d.Clear() |
| 614 | |
| 615 | imagex.Assert(t, img, "tmf") |
| 616 | } |
nothing calls this directly
no test coverage detected