mirror of
https://github.com/RGBCube/color.v
synced 2025-08-01 10:27:45 +00:00
rename PaintBrush to Brush
This commit is contained in:
parent
4f435b8f54
commit
3812a606dd
2 changed files with 9 additions and 9 deletions
|
@ -3,11 +3,11 @@ module main
|
||||||
import color
|
import color
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
p := color.new_brush(
|
brush := color.new_brush(
|
||||||
fg: color.rgb(0, 0, 0)!
|
fg: color.rgb(0, 0, 0)!
|
||||||
bg: color.hex(0xffffff)!
|
bg: color.hex(0xffffff)!
|
||||||
style: [color.bold, color.underline, color.italic]
|
style: [color.bold, color.underline, color.italic]
|
||||||
)!
|
)!
|
||||||
|
|
||||||
p.cprintln('Hello World')
|
brush.cprintln('Hello World')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module color
|
module color
|
||||||
|
|
||||||
[noinit]
|
[noinit]
|
||||||
pub struct PaintBrush {
|
pub struct Brush {
|
||||||
pub:
|
pub:
|
||||||
fg ?Color
|
fg ?Color
|
||||||
bg ?Color
|
bg ?Color
|
||||||
|
@ -11,14 +11,14 @@ __global:
|
||||||
}
|
}
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
pub struct PaintBrushParams {
|
pub struct BrushParams {
|
||||||
fg ?Color
|
fg ?Color
|
||||||
bg ?Color
|
bg ?Color
|
||||||
style []Style
|
style []Style
|
||||||
disabled bool
|
disabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_brush(p PaintBrushParams) !PaintBrush {
|
pub fn new_brush(p BrushParams) !Brush {
|
||||||
mut count := map[Style]int{}
|
mut count := map[Style]int{}
|
||||||
|
|
||||||
for style in p.style {
|
for style in p.style {
|
||||||
|
@ -29,14 +29,14 @@ pub fn new_brush(p PaintBrushParams) !PaintBrush {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PaintBrush{
|
return Brush{
|
||||||
fg: p.fg
|
fg: p.fg
|
||||||
bg: p.bg
|
bg: p.bg
|
||||||
style: p.style
|
style: p.style
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (p &PaintBrush) render(msg string) string {
|
pub fn (p &Brush) render(msg string) string {
|
||||||
if no_color || p.disabled {
|
if no_color || p.disabled {
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,10 @@ pub fn (p &PaintBrush) render(msg string) string {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (p &PaintBrush) cprint(msg string) {
|
pub fn (p &Brush) cprint(msg string) {
|
||||||
print(p.render(msg))
|
print(p.render(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (p &PaintBrush) cprintln(msg string) {
|
pub fn (p &Brush) cprintln(msg string) {
|
||||||
println(p.render(msg))
|
println(p.render(msg))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue