forked from emprcl/runal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstroke.go
More file actions
97 lines (83 loc) · 2.19 KB
/
stroke.go
File metadata and controls
97 lines (83 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package runal
// Background sets the background character and colors for the entire canvas.
func (c *Canvas) Background(text, fg, bg string) {
c.BackgroundText(text)
c.BackgroundBg(bg)
c.BackgroundFg(fg)
}
// BackgroundText sets the character used for the background fill.
func (c *Canvas) BackgroundText(text string) {
c.backgroundIndex = 0
if len(text) == 0 {
c.backgroundText = defaultBackgroundText
return
}
c.backgroundText = text
}
// BackgroundFg sets the foreground (text) color used by the background fill.
func (c *Canvas) BackgroundFg(fg string) {
c.backgroundFg = color(fg)
}
// BackgroundBg sets the background color used by the background fill.
func (c *Canvas) BackgroundBg(bg string) {
c.backgroundBg = color(bg)
}
// Fill sets the fill character and its foreground and background colors.
func (c *Canvas) Fill(text, fg, bg string) {
c.FillText(text)
c.FillBg(bg)
c.FillFg(fg)
}
// FillText sets the character used for fill operations.
func (c *Canvas) FillText(text string) {
c.fill = true
if len(text) == 0 {
c.fillText = defaultFillText
return
}
c.fillText = text
}
// FillFg sets the foreground color used for fill operations.
func (c *Canvas) FillFg(fg string) {
c.fill = true
c.fillFg = color(fg)
}
// FillBg sets the background color used for fill operations.
func (c *Canvas) FillBg(bg string) {
c.fill = true
c.fillBg = color(bg)
}
// Stroke sets the stroke (outline) character and colors.
func (c *Canvas) Stroke(text, fg, bg string) {
c.StrokeText(text)
c.StrokeBg(bg)
c.StrokeFg(fg)
}
// StrokeText sets the character used for strokes.
func (c *Canvas) StrokeText(text string) {
c.stroke = true
c.strokeIndex = 0
if len(text) == 0 {
c.strokeText = defaultStrokeText
return
}
c.strokeText = text
}
// StrokeFg sets the foreground color for strokes.
func (c *Canvas) StrokeFg(fg string) {
c.stroke = true
c.strokeFg = color(fg)
}
// StrokeBg sets the background color for strokes.
func (c *Canvas) StrokeBg(bg string) {
c.stroke = true
c.strokeBg = color(bg)
}
// NoStroke disables stroke for subsequent shapes.
func (c *Canvas) NoStroke() {
c.stroke = false
}
// NoFill disables fill for subsequent shapes.
func (c *Canvas) NoFill() {
c.fill = false
}