mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-03-14 13:03:44 +03:00
Add initialization options for scaled ramps
This commit is contained in:
parent
0f06d78b92
commit
6a768905a6
@ -26,20 +26,30 @@ func WithDefaultRamp() Option {
|
|||||||
|
|
||||||
// WithRamp sets a gradient fill blending between two colors.
|
// WithRamp sets a gradient fill blending between two colors.
|
||||||
func WithRamp(colorA, colorB string) Option {
|
func WithRamp(colorA, colorB string) Option {
|
||||||
a, _ := colorful.Hex(colorA)
|
|
||||||
b, _ := colorful.Hex(colorB)
|
|
||||||
return func(m *Model) {
|
return func(m *Model) {
|
||||||
m.useRamp = true
|
m.setRamp(colorA, colorB, false)
|
||||||
m.rampColorA = a
|
|
||||||
m.rampColorB = b
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithDefaultScaledRamp sets a gradient with default colors, and scales the
|
||||||
|
// gradient to fit the filled portion of the ramp.
|
||||||
|
func WithDefaultScaledRamp() Option {
|
||||||
|
return WithScaledRamp("#00dbde", "#fc00ff")
|
||||||
|
}
|
||||||
|
|
||||||
// WithScaledRamp scales the gradient to fit the width of the filled portion of
|
// WithScaledRamp scales the gradient to fit the width of the filled portion of
|
||||||
// the progress bar.
|
// the progress bar.
|
||||||
func WithScaledRamp() Option {
|
func WithScaledRamp(colorA, colorB string) Option {
|
||||||
return func(m *Model) {
|
return func(m *Model) {
|
||||||
m.scaleRamp = true
|
m.setRamp(colorA, colorB, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSoildFill sets the progress to use a solid fill with the given color.
|
||||||
|
func WithSolidFill(color string) Option {
|
||||||
|
return func(m *Model) {
|
||||||
|
m.FullColor = color
|
||||||
|
m.useRamp = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,3 +150,12 @@ func (m Model) bar(percent float64, textWidth int) string {
|
|||||||
|
|
||||||
return b.String()
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Model) setRamp(colorA, colorB string, scaled bool) {
|
||||||
|
a, _ := colorful.Hex(colorA)
|
||||||
|
b, _ := colorful.Hex(colorB)
|
||||||
|
m.useRamp = true
|
||||||
|
m.scaleRamp = scaled
|
||||||
|
m.rampColorA = a
|
||||||
|
m.rampColorB = b
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user