Packages

A Gleam library for building Discord webhook payloads safely.

Current section

Files

Jump to
kitazith src kitazith@color.erl
Raw

src/kitazith@color.erl

-module(kitazith@color).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/kitazith/color.gleam").
-export([from_rgb/3]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/kitazith/color.gleam", 9).
?DOC(
" Converts RGB components to a single color integer for Discord color fields.\n"
"\n"
" ## Examples\n"
"\n"
" ```gleam\n"
" from_rgb(red: 255, green: 0, blue: 0)\n"
" // -> 0xFF0000 (== 16711680)\n"
" ```\n"
).
-spec from_rgb(integer(), integer(), integer()) -> integer().
from_rgb(Red, Green, Blue) ->
((Red * 65536) + (Green * 256)) + Blue.