Skip to content

Commit

Permalink
feat: allow creation of colors from parts
Browse files Browse the repository at this point in the history
  • Loading branch information
leostera committed Dec 21, 2023
1 parent bf577e0 commit 83db5e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tty/color.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ let rgb str =
let ansi i = ANSI i
let ansi256 i = ANSI256 i
let no_color = No_color
let cap_rgb x = Int.(min (max 0 x) 255)
let of_rgb (r, g, b) = RGB (cap_rgb r, cap_rgb g, cap_rgb b)

let make str =
if String.starts_with ~prefix:"#" str then rgb str
Expand Down
1 change: 1 addition & 0 deletions tty/color.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type t = private
| No_color

val make : string -> t
val of_rgb : (int * int * int) -> t

exception Invalid_color of string
exception Invalid_color_param of string
Expand Down

0 comments on commit 83db5e6

Please sign in to comment.