mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
renew message UI, proper sunlight sim, lightlevel back to 24bit, using CharArray for MSBs and ByteArray for LSBs
Former-commit-id: 1ae49640ac07e8102dd535ef49baa646cb59a947 Former-commit-id: febee94f8e5405733c7361853ba018131316a745
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
MUL = 40
|
||||
MUL_2 = MUL ** 2
|
||||
MAX_STEP = MUL - 1
|
||||
MAX_F = 39.0
|
||||
|
||||
def getch(eightbit):
|
||||
return int(round(eightbit / 255.0 * MAX_STEP))
|
||||
@@ -25,12 +26,21 @@ def getB40(raw):
|
||||
def intFromCol(r, g, b):
|
||||
return int(r * MUL_2 + g * MUL + b)
|
||||
def intFromRGB24(r24, g24, b24):
|
||||
roundR = round(r24 / 255.0 * 39)
|
||||
roundG = round(g24 / 255.0 * 39)
|
||||
roundB = round(b24 / 255.0 * 39)
|
||||
roundR = round(r24 / 255.0 * MAX_STEP)
|
||||
roundG = round(g24 / 255.0 * MAX_STEP)
|
||||
roundB = round(b24 / 255.0 * MAX_STEP)
|
||||
return intFromCol(roundR, roundG, roundB)
|
||||
def colFromNum(raw):
|
||||
return getR40(raw), getG40(raw), getB40(raw)
|
||||
def to24B(num):
|
||||
return int((getR40(num)) / MAX_F * 255.0), \
|
||||
int((getG40(num)) / MAX_F * 255.0),\
|
||||
int((getB40(num)) / MAX_F * 255.0)
|
||||
def to24BHex(num):
|
||||
r, g, b = to24B(num)
|
||||
return hex(r)+hex(g)+hex(b)
|
||||
def to24BInt(num):
|
||||
r, g, b = to24B(num)
|
||||
return r << 16 | g << 8 | b
|
||||
|
||||
print(intFromRGB24(111, 0, 255))
|
||||
print(colFromNum(27239))
|
||||
print(to24BInt(27239))
|
||||
|
||||
Reference in New Issue
Block a user