Hop til indhold
Stavox

RGP To Closest name lol


Trixx

Recommended Posts

Clrs = table( # Skal være et globalt var
    "r"+oe()+"d" = vec(255, 0, 0),
    "orange" = vec(255, 128, 0),
    "gul" = vec(255, 255,0),
    "lime gr"+oe()+"n" = vec(128, 255, 0),
    "gro"+oe()+"n" = vec(0, 255, 0),
    "lime bl"+aa() = vec(0, 255, 128),
    "lyse bl"+aa() = vec(0, 255, 255),
    "bl"+aa() = vec(0,0,255),
    "hvid" = vec(255,255,255),
    "gr"+aa() = vec(64, 64, 64),
    "lilla" = vec(200, 0, 200),
    "gr"+oe()+"n" = vec(0, 255, 0)
)
function string vector:rgpToName() {
    local Closest = 0
    local BestC = "LOL"
    foreach(Farve:string, V:vector = Clrs) {
        local A = 1000
        A-=abs(V:x() - This:x())
        A-=abs(V:y() - This:y())
        A-=abs(V:z() - This:z())
        
        if(A>Closest) {
            Closest=A
            BestC=Farve   
        }
    }
    return BestC
}
printColor(vec(255,0,0), vec(255,0,0):rgpToName()) # Skriver roed

 

formatere rgb vectors til nærmeste farve navne looooooooooool

Link til kommentar

Arkiveret

Dette emne er nu arkiveret og er lukket for yderligere svar

×
×
  • Tilføj...

COOKIE- OG PRIVATLIVSPOLITIK PÅ STAVOX.DK

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privatlivspolitik - Vilkår for brug.