1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/gx/gx.v

100 lines
1.9 KiB
V
Raw Normal View History

2020-01-23 23:04:46 +03:00
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
2019-06-23 05:21:30 +03:00
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
2019-06-22 21:20:28 +03:00
module gx
pub struct Color {
2019-06-22 21:20:28 +03:00
pub:
r int
g int
b int
}
2019-12-03 13:08:57 +03:00
pub const (
blue = Color { r: 0, g: 0, b: 255 }
red = Color { r: 255, g: 0, b: 0 }
2019-11-11 17:18:32 +03:00
green = Color { r: 0, g: 255, b: 0 }
yellow = Color { r: 255, g: 255, b: 0 }
2019-12-03 13:08:57 +03:00
orange = Color { r: 255, g: 165, b: 0 }
purple = Color { r: 128, g: 0, b: 128 }
2019-12-03 13:08:57 +03:00
black = Color { r: 0, g: 0, b: 0 }
gray = Color { r: 128, g: 128, b: 128 }
indigo = Color { r: 75, g: 0, b: 130 }
pink = Color { r: 255, g: 192, b: 203 }
violet = Color { r: 238, g: 130, b: 238 }
2019-11-11 17:18:32 +03:00
white = Color { r: 255, g: 255, b: 255 }
2019-12-03 13:08:57 +03:00
// Shades
dark_blue = Color { r: 0, g: 0, b: 139 }
2019-12-03 13:08:57 +03:00
dark_gray = Color { r: 169, g: 169, b: 169 }
dark_green = Color { r: 0, g: 100, b: 0 }
dark_red = Color { r: 139, g: 0, b: 0 }
light_blue = Color { r: 173, g: 216, b: 230 }
light_gray = Color { r: 211, g: 211, b: 211 }
light_green = Color { r: 144, g: 238, b: 144 }
light_red = Color { r: 255, g: 204, b: 203 }
2019-06-22 21:20:28 +03:00
)
pub const (
2020-04-02 02:45:22 +03:00
align_left = 1
align_right = 4
2019-06-22 21:20:28 +03:00
)
pub struct TextCfg {
2019-06-22 21:20:28 +03:00
pub:
color Color
size int
align int
max_width int
family string
bold bool
mono bool
}
2019-10-27 14:05:50 +03:00
pub struct Image {
2019-06-22 21:20:28 +03:00
mut:
obj voidptr
pub:
id int
width int
height int
}
pub fn (img Image) is_empty() bool {
return isnil(img.obj)
}
pub fn (c Color) str() string {
return '{$c.r, $c.g, $c.b}'
}
pub fn (a Color) eq(b Color) bool {
2019-10-31 12:15:45 +03:00
return a.r == b.r && a.g == b.g && a.b == b.b
2019-06-22 21:20:28 +03:00
}
pub fn rgb(r, g, b int) Color {
res := Color {
2019-10-31 12:15:45 +03:00
r: r
g: g
b: b
2019-06-22 21:20:28 +03:00
}
return res
}
2020-03-07 06:30:35 +03:00
pub fn hex(color int) Color {
res := Color {
r: (color >> 16) & 0xFF
g: (color >> 8) & 0xFF
b: color & 0xFF
}
return res
}
2019-06-22 21:20:28 +03:00
// fn text_width_char(c char) int {
// return text_width(char2string(c))
// // return C.text_width_char(c)
// }