MCPcopy
hub / github.com/mum4k/termdash / HV

Function HV

private/segdisp/segment/segment.go:129–162  ·  view source on GitHub ↗

HV draws a horizontal or a vertical display segment, filling the provided area. The segment will have slopes on both of its ends.

(bc *braille.Canvas, ar image.Rectangle, st Type, opts ...Option)

Source from the content-addressed store, hash-verified

127// HV draws a horizontal or a vertical display segment, filling the provided area.
128// The segment will have slopes on both of its ends.
129func HV(bc *braille.Canvas, ar image.Rectangle, st Type, opts ...Option) error {
130 if err := validArea(ar); err != nil {
131 return err
132 }
133
134 opt := &options{}
135 for _, o := range opts {
136 o.set(opt)
137 }
138
139 var nextLine nextHVLineFn
140 var lines int
141 switch st {
142 case Horizontal:
143 lines = ar.Dy()
144 nextLine = nextHorizLine
145
146 case Vertical:
147 lines = ar.Dx()
148 nextLine = nextVertLine
149
150 default:
151 return fmt.Errorf("unsupported segment type %v(%d)", st, st)
152 }
153
154 for i := 0; i < lines; i++ {
155 start, end := nextLine(i, ar, opt)
156 if err := draw.BrailleLine(bc, start, end, draw.BrailleLineCellOpts(opt.cellOpts...)); err != nil {
157 return err
158 }
159
160 }
161 return nil
162}
163
164// nextHVLineFn is a function that determines the start and end points of a line
165// number num in a horizontal or a vertical segment.

Callers 4

MustHVFunction · 0.92
DrawMethod · 0.92
DrawMethod · 0.92
TestHVFunction · 0.85

Calls 4

BrailleLineFunction · 0.92
BrailleLineCellOptsFunction · 0.92
validAreaFunction · 0.85
setMethod · 0.65

Tested by 1

TestHVFunction · 0.68