Tile tiles the hatch pattern within the clipping path.
(clip *Path)
| 98 | |
| 99 | // Tile tiles the hatch pattern within the clipping path. |
| 100 | func (p *HatchPattern) Tile(clip *Path) *Path { |
| 101 | dst := clip.FastBounds() |
| 102 | |
| 103 | // find extremes along cell axes |
| 104 | invCell := p.cell.Inv() |
| 105 | points := []Point{ |
| 106 | invCell.Dot(Point{dst.X0 - p.Thickness, dst.Y0 - p.Thickness}), |
| 107 | invCell.Dot(Point{dst.X1 + p.Thickness, dst.Y0 - p.Thickness}), |
| 108 | invCell.Dot(Point{dst.X1 + p.Thickness, dst.Y1 + p.Thickness}), |
| 109 | invCell.Dot(Point{dst.X0 - p.Thickness, dst.Y1 + p.Thickness}), |
| 110 | } |
| 111 | x0, x1 := points[0].X, points[0].X |
| 112 | y0, y1 := points[0].Y, points[0].Y |
| 113 | for _, point := range points[1:] { |
| 114 | x0 = math.Min(x0, point.X) |
| 115 | x1 = math.Max(x1, point.X) |
| 116 | y0 = math.Min(y0, point.Y) |
| 117 | y1 = math.Max(y1, point.Y) |
| 118 | } |
| 119 | |
| 120 | hatch := p.hatch(x0, y0, x1, y1) |
| 121 | hatch = hatch.Transform(p.cell) |
| 122 | hatch = hatch.And(clip) |
| 123 | if p.Thickness != 0.0 { |
| 124 | hatch = hatch.Stroke(p.Thickness, ButtCap, MiterJoin, 0.01) |
| 125 | } |
| 126 | return hatch |
| 127 | } |
| 128 | |
| 129 | // RenderTo tiles the hatch pattern to the clipping path and renders it to the renderer. |
| 130 | func (p *HatchPattern) RenderTo(r Renderer, clip *Path) { |