Skip to content

Latest commit

 

History

History
74 lines (49 loc) · 1.7 KB

File metadata and controls

74 lines (49 loc) · 1.7 KB

ColorProvider

Summary

geode.ColorProvider is a shared index of named colors. Mods define colors by id, and texture packs can then change them. Use it for colors you want a texture pack to override. Prefix the id with your mod id.

Colors use plain tables. RGBAColor is { r, g, b, a } and RGBColor is { r, g, b }. Each field is 0 to 255. An unknown id reads as white.

define

geode.ColorProvider.define(id: string, color: RGBAColor) -> RGBAColor

Defines a color for an id. Does nothing if the id is already defined. Returns the current color.

override

geode.ColorProvider.override(id: string, color: RGBAColor) -> RGBAColor

Overrides the current color for an id. Returns the new color.

reset

geode.ColorProvider.reset(id: string) -> RGBAColor

Resets a color back to its defined value. Returns that value.

color and color3b

geode.ColorProvider.color(id: string) -> RGBAColor
geode.ColorProvider.color3b(id: string) -> RGBColor

color returns the current color for an id. color3b is the same but drops the alpha.

Example

local modId = geode.Mod.getID()
local id = modId .. "/accent"

geode.ColorProvider.define(id, { r = 255, g = 128, b = 0, a = 255 })

local c = geode.ColorProvider.color(id)
print(c.r, c.g, c.b) -- 255 128 0

-- Override and restore.
geode.ColorProvider.override(id, { r = 0, g = 200, b = 255, a = 255 })
sprite:setColor(geode.ColorProvider.color3b(id))

local restored = geode.ColorProvider.reset(id)
print(restored.r, restored.g, restored.b, restored.a)

Related

Source

  • src/bindings/geode/GeodeSmallBindings.cpp