Adjust the colors

This commit is contained in:
Miloslav Číž 2018-09-27 13:23:27 +02:00
parent b4958c4295
commit d15aa7f60b
2 changed files with 76 additions and 98 deletions

View file

@ -6,27 +6,6 @@
import sys
from PIL import Image
# old code, kept just in case :)
"""
def rgbToIndex(r, g, b):
return (r & 0b00000111) | ((g & 0b00000111) << 3) | ((b & 0b00000011) << 6)
"""
def encodeHSV(hue, saturation, value):
result = 0
if value > 15:
if saturation > 85:
result = ((saturation / 86 - 1) << 7) | ((hue / 32) << 4) | ((value - 16) / 15)
# "normal" color, as 0bSHHHVVVV, VVVV != 0
else:
result = value / 16
# saturation near 0 => gray, as 0bVVVV0000, VVVV != 0
return result & 0b11111111
# value near 0 => black, as 0b00000000
def findClosest(pixel, palettePixels):
result = 0
closestDist = 255 * 255 * 255
@ -45,7 +24,6 @@ def findClosest(pixel, palettePixels):
return result
image = Image.open(sys.argv[1])
#image = image.convert("HSV")
pixels = image.load()
pal = Image.open(sys.argv[2])
@ -63,8 +41,6 @@ for x in range(image.size[0]):
p = pixels[x,y]
#sys.stdout.write(",0x{:02x}".format(rgbToIndex(p[0] / 32, p[1] / 32, p[2] / 85)))
#sys.stdout.write(",0x{:02x}".format(encodeHSV(p[0],p[1],p[2])))
sys.stdout.write(",0x{:02x}".format(findClosest(p,palPixels)))
count += 1

150
demo1.cpp
View file

@ -13,6 +13,8 @@
//#define COMPUTE_WALL_TEXCOORDS 0
// ^ this turns off textures
#define SUBSAMPLE 1
// redefine some parameters
#define FPS 255
#define GRAVITY_ACCELERATION (RCL_UNITS_PER_SQUARE * 3)
@ -207,80 +209,80 @@ const unsigned char texture1[] =
const unsigned char texture2[] =
{ 32, 32 // width, height
,0x19,0x18,0x92,0x16,0x95,0x94,0x81,0x95,0x97,0x1b,0x1b,0x95,0x18,0x18
,0x1b,0x17,0x96,0x95,0x15,0x1a,0x18,0x19,0x96,0x1c,0x1e,0x1b,0x1a,0x1d
,0x1e,0x1f,0x1c,0x1d,0x18,0x15,0x95,0x1b,0x1b,0x1a,0x1f,0x1e,0x1d,0x1c
,0x1a,0x1b,0x14,0x19,0x94,0x91,0x1c,0x1b,0x91,0x95,0x83,0x92,0x16,0x1b
,0x1e,0x1f,0x1e,0x1f,0x1d,0x1b,0x1c,0x1b,0x17,0x19,0x17,0x1d,0x1d,0x1d
,0x1d,0x1e,0x1c,0x1f,0x1f,0x1a,0x15,0x94,0x14,0x1e,0x1b,0x1d,0x1f,0x1c
,0x16,0x16,0x1b,0x1e,0x1c,0x1f,0x1c,0x1f,0x1d,0x19,0x1b,0x18,0x19,0x15
,0x95,0x1b,0x1c,0x1e,0x1f,0x1f,0x1f,0x1e,0x1f,0x18,0x18,0x92,0x1a,0x1d
,0x1f,0x1d,0x1d,0x1b,0x1c,0x15,0x1a,0x1c,0x1f,0x1b,0x1e,0x1d,0x18,0x19
,0x18,0x1b,0x18,0x19,0x96,0x1b,0x1a,0x1e,0x1b,0x1c,0x1c,0x19,0x1d,0x1a
,0x19,0x95,0x1a,0x1f,0x1c,0x1b,0x17,0x1e,0x1a,0x18,0x95,0x1d,0x1d,0x1c
,0x1a,0x1b,0x1b,0x19,0x1c,0x16,0x16,0x93,0x92,0x19,0x19,0x18,0x1d,0x1c
,0x1d,0x1b,0x1b,0x1a,0x15,0x16,0x19,0x1a,0x1c,0x1b,0x1b,0x1b,0x1b,0x16
,0x93,0x99,0x1e,0x1b,0x1f,0x1a,0x19,0x15,0x18,0x18,0x94,0x97,0x94,0x16
,0x1c,0x1a,0x18,0x1a,0x17,0x1b,0x17,0x1b,0x15,0x19,0x16,0x1b,0x1b,0x19
,0x1b,0x19,0x1a,0x19,0x13,0x1c,0x1c,0x1e,0x1c,0x19,0x15,0x1a,0x18,0x82
,0x94,0x99,0x17,0x94,0x91,0x19,0x1c,0x18,0x19,0x18,0x18,0x1b,0x16,0x97
,0x97,0x18,0x1a,0x18,0x15,0x18,0x15,0x96,0x82,0x19,0x1b,0x19,0x19,0x18
,0x17,0x17,0x82,0x94,0x16,0x15,0x19,0x16,0x14,0x13,0x18,0x19,0x17,0x1c
,0x18,0x19,0x19,0x19,0x94,0x82,0x16,0x16,0x19,0x94,0x91,0x95,0x16,0x14
,0x83,0x18,0x16,0x19,0x95,0x17,0x19,0x16,0x19,0x84,0x19,0x19,0x17,0x93
,0x15,0x17,0x18,0x1b,0x19,0x17,0x14,0x16,0x95,0x1a,0x1a,0x92,0x94,0x92
,0x16,0x1b,0x1d,0x1a,0x1b,0x16,0x93,0x92,0x13,0x16,0x1a,0x18,0x17,0x18
,0x1b,0x1a,0x19,0x1c,0x16,0x92,0x17,0x18,0x16,0x18,0x95,0x92,0x18,0x1b
,0x1f,0x1a,0x17,0x16,0x1c,0x1c,0x1d,0x1e,0x1f,0x1d,0x1a,0x1b,0x1c,0x1c
,0x1d,0x1c,0x94,0x94,0x1b,0x1b,0x1b,0x19,0x14,0x17,0x18,0x15,0x19,0x17
,0x95,0x19,0x1b,0x1e,0x1f,0x1e,0x1a,0x17,0x1a,0x1d,0x1f,0x1b,0x1d,0x1f
,0x1b,0x1c,0x1e,0x1c,0x1c,0x18,0x16,0x1d,0x1c,0x1f,0x1f,0x1d,0x1b,0x96
,0x94,0x92,0x95,0x95,0x18,0x1b,0x1c,0x1b,0x1a,0x1c,0x1c,0x19,0x15,0x1a
,0x1a,0x1a,0x1b,0x19,0x1f,0x1c,0x1b,0x1c,0x1b,0x16,0x95,0x1f,0x1d,0x1d
,0x1f,0x18,0x1d,0x16,0x1a,0x1f,0x1e,0x1d,0x1e,0x1f,0x1d,0x1b,0x1d,0x1e
,0x1c,0x1c,0x14,0x18,0x19,0x1a,0x1b,0x1a,0x1b,0x1b,0x1c,0x1a,0x1b,0x17
,0x92,0x1b,0x1d,0x1b,0x1b,0x1b,0x1a,0x17,0x1d,0x1b,0x1d,0x1f,0x1b,0x1f
,0x1c,0x1e,0x1c,0x1c,0x1b,0x1f,0x15,0x16,0x18,0x1a,0x18,0x19,0x1b,0x19
,0x1c,0x98,0x18,0x94,0x16,0x1e,0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x14,0x1f,0x1f,0x1d,0x1d,0x1f,0x1f,0x1c,0x1b,0x19,0x15
,0x16,0x18,0x17,0x18,0x17,0x16,0x17,0x14,0x92,0x17,0x1b,0x1d,0x1c,0x1c
,0x1c,0x17,0x1a,0x1b,0x1b,0x1a,0x17,0x92,0x1b,0x1d,0x1d,0x1f,0x1d,0x1e
,0x1e,0x1c,0x1a,0x94,0x92,0x15,0x17,0x15,0x19,0x15,0x84,0x92,0x18,0x98
,0x95,0x1a,0x1b,0x1b,0x1e,0x1b,0x19,0x19,0x19,0x1c,0x94,0x15,0x1b,0x1c
,0x19,0x1c,0x1d,0x1d,0x1d,0x1d,0x18,0x1b,0x16,0x94,0x91,0x95,0x92,0x19
,0x1b,0x1e,0x1a,0x1a,0x16,0x87,0x1b,0x19,0x1a,0x1a,0x19,0x1b,0x1b,0x16
,0x16,0x94,0x18,0x1a,0x1a,0x1b,0x1d,0x1c,0x1c,0x1c,0x19,0x18,0x94,0x19
,0x19,0x1d,0x1e,0x1e,0x1f,0x1d,0x1f,0x1f,0x1f,0x94,0x93,0x18,0x1c,0x1c
,0x18,0x19,0x16,0x19,0x19,0x95,0x19,0x1a,0x18,0x1b,0x1b,0x19,0x1a,0x1a
,0x19,0x17,0x13,0x1a,0x1d,0x1f,0x1c,0x1e,0x1c,0x1b,0x1e,0x1f,0x1c,0x1b
,0x13,0x16,0x1a,0x18,0x1a,0x18,0x1a,0x16,0x94,0x18,0x1a,0x1b,0x1a,0x1b
,0x17,0x19,0x1c,0x19,0x15,0x18,0x16,0x1a,0x1d,0x1a,0x1f,0x1d,0x1f,0x1c
,0x1a,0x1b,0x19,0x17,0x14,0x92,0x1d,0x1b,0x18,0x17,0x16,0x14,0x16,0x19
,0x19,0x19,0x1a,0x18,0x1b,0x1a,0x18,0x19,0x1a,0x18,0x92,0x18,0x1e,0x1d
,0x1b,0x1d,0x1a,0x1a,0x1b,0x1b,0x1a,0x1c,0x19,0x17,0x18,0x17,0x1b,0x97
,0x16,0x19,0x94,0x94,0x94,0x19,0x16,0x1b,0x17,0x19,0x1b,0x1c,0x19,0x19
,0x92,0x18,0x1b,0x1f,0x1c,0x1a,0x1f,0x1e,0x17,0x1c,0x18,0x17,0x17,0x13
,0x19,0x1b,0x18,0x19,0x14,0x14,0x18,0x97,0x19,0x14,0x18,0x15,0x19,0x1b
,0x1b,0x19,0x18,0x15,0x93,0x16,0x16,0x1a,0x1f,0x1e,0x1b,0x19,0x18,0x18
,0x18,0x1c,0x17,0x16,0x15,0x19,0x18,0x17,0x13,0x94,0x1a,0x18,0x19,0x13
,0x98,0x17,0x17,0x19,0x18,0x16,0x97,0x92,0x17,0x94,0x18,0x1a,0x1d,0x18
,0x1b,0x19,0x1b,0x1a,0x17,0x16,0x94,0x13,0x16,0x95,0x17,0x14,0x14,0x1b
,0x1a,0x19
,0x19,0x9a,0x92,0x98,0x95,0x94,0x81,0x95,0x98,0x1a,0x1b,0x96,0x17,0x9a
,0x9c,0x9a,0x96,0x95,0x97,0x19,0x17,0x18,0x97,0x1a,0x1d,0x1c,0x18,0x1d
,0x1f,0x1f,0x1b,0x1c,0x18,0x98,0x96,0x1b,0x1a,0x1a,0x1f,0x1d,0x1d,0x1b
,0x19,0x19,0x97,0x18,0x95,0x91,0x1b,0x19,0x91,0x95,0x83,0x82,0x17,0x1b
,0x1e,0x1f,0x1e,0x1f,0x1d,0x1a,0x1c,0x1a,0x99,0x17,0x98,0x1e,0x1c,0x1d
,0x1c,0x1d,0x1a,0x1f,0x1f,0x19,0x97,0x95,0x98,0x1e,0x1b,0x1c,0x1f,0x1a
,0x17,0x97,0x1a,0x1e,0x1a,0x1f,0x1a,0x1f,0x1b,0x9d,0x1a,0x17,0x18,0x98
,0x95,0x1b,0x1b,0x1c,0x1f,0x1f,0x1f,0x1e,0x1e,0x18,0x16,0x92,0x19,0x1d
,0x1f,0x1c,0x1c,0x19,0x1c,0x14,0x19,0x1a,0x1f,0x1b,0x1e,0x1c,0x17,0x9b
,0x18,0x19,0x18,0x19,0x97,0x9d,0x19,0x1e,0x1b,0x1b,0x1b,0x18,0x1c,0x18
,0x18,0x95,0x18,0x1f,0x1b,0x1a,0x9b,0x1d,0x1b,0x99,0x95,0x1c,0x1c,0x1b
,0x19,0x1a,0x1a,0x19,0x1c,0x98,0x97,0x94,0x92,0x18,0x19,0x17,0x1c,0x1c
,0x1b,0x1a,0x1a,0x1a,0x98,0x97,0x19,0x1b,0x1c,0x1a,0x19,0x1a,0x19,0x98
,0x93,0x9a,0x1e,0x1b,0x1f,0x1a,0x9b,0x97,0x18,0x18,0x95,0x98,0x85,0x15
,0x1c,0x1a,0x17,0x19,0x9a,0x1a,0x16,0x1a,0x98,0x18,0x14,0x1b,0x1a,0x18
,0x19,0x18,0x1a,0x18,0x95,0x1d,0x1b,0x1d,0x1c,0x18,0x97,0x18,0x18,0x82
,0x95,0x9a,0x17,0x94,0x91,0x19,0x1b,0x19,0x9b,0x9a,0x17,0x1a,0x9a,0x97
,0x98,0x18,0x19,0x17,0x97,0x16,0x97,0x96,0x82,0x9a,0x1b,0x9a,0x18,0x18
,0x16,0x98,0x82,0x94,0x98,0x97,0x18,0x99,0x98,0x95,0x9a,0x19,0x98,0x1b
,0x16,0x18,0x18,0x17,0x95,0x82,0x98,0x98,0x19,0x85,0x91,0x95,0x98,0x96
,0x83,0x99,0x98,0x1a,0x95,0x98,0x9b,0x98,0x9a,0x84,0x18,0x18,0x16,0x93
,0x97,0x98,0x18,0x1a,0x17,0x98,0x95,0x14,0x95,0x19,0x9c,0x92,0x95,0x92
,0x14,0x19,0x1c,0x19,0x1a,0x16,0x93,0x92,0x87,0x99,0x19,0x99,0x9a,0x18
,0x19,0x19,0x19,0x1b,0x16,0x92,0x16,0x16,0x76,0x18,0x86,0x92,0x18,0x1b
,0x1f,0x1a,0x98,0x97,0x1c,0x1b,0x1c,0x1e,0x1f,0x1d,0x18,0x1b,0x1b,0x1a
,0x1d,0x1b,0x94,0x95,0x19,0x1a,0x1a,0x18,0x14,0x98,0x19,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x17,0x98,0x92,0x19,0x18,0x1a,0x1c,0x1e
,0x16,0x1a,0x19,0x18,0x18,0x18,0x1b,0x17,0x88,0x1b,0x1e,0x1d,0x1f,0x1c
,0x1f,0x1f,0x1a,0x19,0x97,0x19,0x96,0x85,0x83,0x98,0x97,0x84,0x1b,0x93
,0x16,0x1a,0x19,0x18,0x1a,0x1b,0x18,0x9b,0x19,0x1b,0x17,0x1a,0x96,0x1a
,0x1c,0x1f,0x19,0x1f,0x1b,0x1f,0x1b,0x1a,0x98,0x17,0x16,0x1a,0x1f,0x1b
,0x1f,0x1b,0x1a,0x95,0x98,0x17,0x18,0x1a,0x9a,0x1b,0x8b,0x18,0x19,0x18
,0x19,0x97,0x9a,0x1d,0x1f,0x1c,0x1a,0x1a,0x1c,0x1f,0x1f,0x1c,0x95,0x97
,0x1a,0x1d,0x1c,0x1d,0x1c,0x1f,0x18,0x1d,0x96,0x19,0x16,0x19,0x18,0x1a
,0x19,0x9a,0x16,0x18,0x85,0x16,0x1c,0x18,0x19,0x1d,0x19,0x17,0x19,0x1c
,0x1b,0x1d,0x1c,0x14,0x1f,0x1f,0x1b,0x1d,0x1f,0x1e,0x1b,0x1b,0x18,0x97
,0x15,0x18,0x17,0x18,0x9a,0x98,0x17,0x95,0x92,0x98,0x1a,0x1c,0x1c,0x1a
,0x1c,0x16,0x1a,0x1a,0x1a,0x1b,0x17,0x93,0x1c,0x7d,0x1c,0x1f,0x1b,0x1e
,0x1c,0x1c,0x1a,0x85,0x92,0x97,0x9a,0x98,0x1a,0x97,0x84,0x92,0x18,0x99
,0x96,0x19,0x1c,0x1c,0x1d,0x1a,0x16,0x9a,0x19,0x1b,0x94,0x97,0x1c,0x1a
,0x18,0x1a,0x1c,0x1d,0x1c,0x1c,0x18,0x1b,0x97,0x95,0x91,0x95,0x92,0x9a
,0x1a,0x1e,0x1a,0x19,0x16,0x88,0x19,0x18,0x19,0x18,0x9b,0x1a,0x1a,0x9a
,0x15,0x94,0x17,0x19,0x19,0x18,0x1d,0x1c,0x1b,0x1c,0x18,0x17,0x95,0x18
,0x18,0x1c,0x1d,0x1d,0x1f,0x1c,0x1f,0x1f,0x1f,0x94,0x93,0x17,0x1b,0x1b
,0x16,0x9a,0x99,0x18,0x18,0x96,0x19,0x18,0x18,0x1c,0x1a,0x9c,0x19,0x18
,0x9a,0x98,0x95,0x18,0x1d,0x1f,0x1b,0x1e,0x1b,0x19,0x1d,0x1f,0x1b,0x1a
,0x95,0x97,0x19,0x17,0x18,0x17,0x1a,0x14,0x95,0x17,0x19,0x1c,0x1a,0x1b
,0x9a,0x18,0x1c,0x18,0x97,0x9a,0x98,0x18,0x1d,0x9f,0x1f,0x1d,0x1f,0x1a
,0x18,0x18,0x18,0x9a,0x13,0x92,0x1d,0x18,0x9a,0x99,0x16,0x97,0x15,0x18
,0x19,0x9b,0x18,0x9a,0x1a,0x1a,0x16,0x18,0x1a,0x18,0x93,0x16,0x1d,0x1c
,0x19,0x1c,0x1a,0x18,0x19,0x1a,0x1a,0x1a,0x19,0x98,0x9a,0x99,0x1a,0x98
,0x16,0x9a,0x95,0x85,0x95,0x19,0x9a,0x1a,0x15,0x19,0x1a,0x1b,0x17,0x19
,0x92,0x99,0x18,0x1f,0x1a,0x1b,0x1f,0x1e,0x9a,0x1c,0x18,0x9a,0x16,0x94
,0x19,0x19,0x17,0x18,0x97,0x95,0x9a,0x98,0x17,0x97,0x17,0x98,0x19,0x1a
,0x1a,0x19,0x17,0x97,0x94,0x98,0x9a,0x18,0x1f,0x1e,0x1a,0x9a,0x17,0x17
,0x16,0x1a,0x16,0x16,0x97,0x19,0x9a,0x17,0x95,0x94,0x18,0x17,0x18,0x13
,0x98,0x16,0x16,0x18,0x18,0x16,0x88,0x92,0x98,0x85,0x9a,0x19,0x1c,0x17
,0x19,0x18,0x1b,0x1a,0x15,0x14,0x84,0x94,0x97,0x95,0x98,0x95,0x88,0x1a
,0x18,0x19
};
const unsigned char texture3[] =