MCPcopy
hub / github.com/tdewolff/canvas / NewHatchPattern

Function NewHatchPattern

patterns.go:58–78  ·  view source on GitHub ↗

NewHatchPattern returns a new hatch pattern.

(ifill any, thickness float64, cell Matrix, hatch Hatcher)

Source from the content-addressed store, hash-verified

56
57// NewHatchPattern returns a new hatch pattern.
58func NewHatchPattern(ifill any, thickness float64, cell Matrix, hatch Hatcher) *HatchPattern {
59 var fill Paint
60 if paint, ok := ifill.(Paint); ok {
61 fill = paint
62 } else if pattern, ok := ifill.(Pattern); ok {
63 fill = Paint{Pattern: pattern}
64 } else if gradient, ok := ifill.(Gradient); ok {
65 fill = Paint{Gradient: gradient}
66 } else if col, ok := ifill.(color.Color); ok {
67 fill = Paint{Color: rgbaColor(col)}
68 }
69 if fill.IsPattern() {
70 panic("hatch paint cannot be pattern")
71 }
72 return &HatchPattern{
73 Fill: fill,
74 Thickness: thickness,
75 cell: cell,
76 hatch: hatch,
77 }
78}
79
80// Transform sets the view. Automatically called by Canvas for coordinate system transformations.
81func (p *HatchPattern) Transform(view Matrix) Pattern {

Callers 3

NewLineHatchFunction · 0.85
NewCrossHatchFunction · 0.85
NewShapeHatchFunction · 0.85

Calls 2

IsPatternMethod · 0.95
rgbaColorFunction · 0.85

Tested by

no test coverage detected