Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make contrast of all player colors the same #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-linux.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
gcc -O3 -Wall -Wextra -o nw -DTARGET_GLUT color.c config.c display.c main.c network.c simulation.c vector.c -lGL -lGLU -lglut -lm
gcc -O3 -Wall -Wextra -o nw -DTARGET_GLUT config.c display.c main.c network.c simulation.c vector.c hsluv.c -lGL -lGLU -lglut -lm
2 changes: 1 addition & 1 deletion build-mac.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
gcc -I/usr/local/include -L/usr/local/lib -L/opt/X11/lib -O3 -Wall -Wno-deprecated-declarations -o nw -DTARGET_GLUT color.c config.c display.c main.c network.c simulation.c vector.c -framework OpenGL -framework GLUT -lm
gcc -I/usr/local/include -L/usr/local/lib -L/opt/X11/lib -O3 -Wall -Wno-deprecated-declarations -o nw -DTARGET_GLUT config.c display.c main.c network.c simulation.c vector.c hsluv.c -framework OpenGL -framework GLUT -lm
2 changes: 1 addition & 1 deletion build-raspi.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
gcc -O3 -Wall -Wextra -Wno-unused-parameter -std=gnu11 -o nw -DTARGET_RASPI color.c config.c display.c main.c network.c simulation.c vector.c -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux -L/opt/vc/lib -lm -lbrcmEGL -lbrcmGLESv2 -lbcm_host -lvchiq_arm
gcc -O3 -Wall -Wextra -Wno-unused-parameter -std=gnu11 -o nw -DTARGET_RASPI config.c display.c main.c network.c simulation.c vector.c hsluv.c -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux -L/opt/vc/lib -lm -lbrcmEGL -lbrcmGLESv2 -lbcm_host -lvchiq_arm
30 changes: 24 additions & 6 deletions display.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#endif

#include "config.h"
#include "color.h"
#include "hsluv.h"
#include "simulation.h"

#if defined TARGET_GLUT
Expand Down Expand Up @@ -461,13 +461,31 @@ void initDisplay(int* argc, char** argv)
uiPlayer = malloc(conf.maxPlayers * sizeof(UiPlayer));
playersByPoints = malloc(conf.maxPlayers * sizeof(int));

// find the smallest coprime of max_players and use it as a multiplicator
// for more even color distribution

unsigned int multiplier = 2;
while (conf.maxPlayers % multiplier == 0)
{
multiplier++;
}

double hue_step_size = 360.0 / conf.maxPlayers * multiplier;
double red_hue = 11.0;


for(p = 0; p < conf.maxPlayers; ++p)
{
hsv color;
color.h = 360.0 / MIN(conf.maxPlayers, 6) * p + (p / 6) * 30.0;
color.s = 0.8;
color.v = 1.0;
uiPlayer[p].color = hsv2rgb(color);

double hue = p * hue_step_size + red_hue;
double saturation = 120;
double luminosity = 70;

rgb rgb;

hpluv2rgb(hue, saturation, luminosity, &rgb.r, &rgb.g, &rgb.b);

uiPlayer[p].color = rgb;
playersByPoints[p] = p;
}
sorted = 0;
Expand Down
8 changes: 7 additions & 1 deletion display.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#ifndef _DISPLAY_H_
#define _DISPLAY_H_
#include "color.h"

typedef struct
{
double r;
double g;
double b;
} rgb;

void updateZoom(double z);
void toggleFps(void);
Expand Down
Loading