Neverlose
  • Welcome
  • Official Website
  • Useful information
    • 📲Quick start
    • â›Šī¸Common knowledge
    • 🧠Examples
      • âš™ī¸Materials
      • âš™ī¸Color
      • âš™ī¸Vector
      • âš™ī¸ESP
      • âš™ī¸ConVars
      • âš™ī¸UI
  • Documentation
    • 📓Events
    • âš™ī¸Variables
      • 🌎_G
      • đŸ—„ī¸bit
      • 🌈color
      • ⌚common
      • 🎲cvar
      • 💾db
      • 👾entity
      • 👩‍đŸ’ģesp
      • đŸ—ŗī¸events
      • 📂files
      • 📎globals
      • 🔓json
      • ✨materials
      • đŸ”ĸmath
      • đŸ’ģui
      • â˜ī¸network
      • 🌃panorama
      • đŸ’ĸrage
      • 🎨render
      • 🧰utils
      • 📍vector
Powered by GitBook
On this page
  1. Useful information
  2. Examples

Color

Color Pseudocode

-- Colors have a flexible constructor
local foo = color(255, 0, 0, 255)
local bar = color("#00FF00FF")

-- There are 4 fields you can access: "r", "g", "b", and "a"
print(string.format("r: %d, g: %d, b: %d, a: %d", foo.r, foo.g, foo.b, foo.a))

-- You can also set them by manually indexing them like so
foo.r, foo.g, foo.b, foo.a = 0, 0, 255, 200

-- or by initializing it with several functions that our API has to offer
foo:as_fraction(1, 0, 1, 1)

-- There are a lot of built-in ways to interpret colors
print(bar) --> color(0, 255, 0, 255)
print(foo:to_hex()) --> FF0000FF
print(string.format("r: %d, g: %d, b: %d, a: %d", foo:unpack()))

-- Learn more at Variables -> color
PreviousMaterialsNextVector

Last updated 2 years ago

🧠
âš™ī¸