Skip to content

Color API

Алексей . edited this page Mar 21, 2026 · 3 revisions

Color API

Source

SFColor

readonly record struct for SA-MP text colors.

Creating Colors

SFColor red = SFColor.FromRgb(255, 0, 0);
SFColor semiTransparent = SFColor.FromArgb(128, 255, 0, 0);
SFColor fromHex = SFColor.FromHex("FF6495ED");     // AARRGGBB
SFColor fromHex2 = SFColor.FromHex("6495ED");      // RRGGBB (full alpha)

Applying to Text

string colored = SFColors.Green.Apply("Success!");
// Produces: "{00FF00}Success!"

SF.Chat.Add(SFColors.Red.Apply("Error: something went wrong"));

Blending

// 50/50 blend via operator
SFColor mixed = SFColors.Cyan | SFColors.Blue;

// Custom weight blend
SFColor warm = SFColors.Red.Blend(SFColors.Yellow, 0.3f);  // 30% yellow

// Modify alpha
SFColor faded = SFColors.White.WithAlpha(128);

Properties

Property Type Description
Argb uint Raw ARGB value (0xAARRGGBB)
Rgba uint RGBA value (0xRRGGBBAA)
A, R, G, B byte Individual components
SampTag string SA-MP format {RRGGBB}

Methods

Method Returns Description
Apply(string text) string Prepend {RRGGBB} tag
Blend(SFColor, float) SFColor Linear interpolation
WithAlpha(byte) SFColor New color with changed alpha

SFColors Presets

Name Hex Preview
White #FFFFFF White
Black #000000 Black
Gray #808080 Gray
LightGray #C0C0C0 Light gray
DarkGray #404040 Dark gray
Red #FF0000 Red
Green #00FF00 Green
Blue #0000FF Blue
Yellow #FFFF00 Yellow
Orange #FFA500 Orange
Cyan #00FFFF Cyan
Purple #800080 Purple
Mint #98FF98 Mint
Ice #D6F5FF Ice
Rose #FF6B6B Rose
Sand #F4D03F Sand
Slate #708090 Slate

Patterns

Chat with mixed colors

SFColor accent = SFColors.Cyan | SFColors.Blue;
SFColor dim = SFColors.Slate;
SF.Chat.Add($"{accent.Apply("Module")} {dim.Apply("|")} {SFColors.Green.Apply("Running")}");

Dialog headers

SFColor headerColor = SFColors.Yellow | SFColors.Sand;
await SF.Dialog.ShowList(
    headerColor.Apply("Title"),
    items,
    $"{SFColors.Cyan.Apply("Column1")}\t{SFColors.Cyan.Apply("Column2")}"
);

Implicit uint conversion

uint chatColor = SFColors.Green;  // implicit conversion to uint (ARGB)

Clone this wiki locally