NewShapeHatch returns a new shape hatch that repeats the given shape over a rhombus primitive cell with sides of length distance. Thickness is the stroke thickness applied to the shape; stroking is ignored with thickness is zero.
(ifill any, shape *Path, distance, thickness float64)
| 167 | |
| 168 | // NewShapeHatch returns a new shape hatch that repeats the given shape over a rhombus primitive cell with sides of length distance. Thickness is the stroke thickness applied to the shape; stroking is ignored with thickness is zero. |
| 169 | func NewShapeHatch(ifill any, shape *Path, distance, thickness float64) *HatchPattern { |
| 170 | d := distance * math.Sin(60.0*math.Pi/180.0) |
| 171 | cell := SquareCell(1.0) |
| 172 | return NewHatchPattern(ifill, thickness, cell, func(x0, y0, x1, y1 float64) *Path { |
| 173 | p := &Path{} |
| 174 | for y := math.Floor(y0/distance) * distance; y <= y1; y += 2.0 * d { |
| 175 | for x := math.Floor(x0/distance) * distance; x <= x1; x += distance { |
| 176 | p = p.Append(shape.Copy().Translate(x, y)) |
| 177 | } |
| 178 | for x := (math.Floor(x0/distance) + 0.5) * distance; x <= x1; x += distance { |
| 179 | p = p.Append(shape.Copy().Translate(x, y+d)) |
| 180 | } |
| 181 | } |
| 182 | return p |
| 183 | }) |
| 184 | } |
| 185 | |
| 186 | // ImagePattern is an image tiling pattern of an image drawn from an origin with a certain resolution. Higher resolution will give smaller tilings. |
| 187 | //type ImagePattern struct { |
no test coverage detected