Colour palette improved for the calendar
This commit is contained in:
parent
479153df17
commit
d3f5b046f3
3 changed files with 45 additions and 10 deletions
|
@ -1044,17 +1044,31 @@ SQL;
|
||||||
$event["nowPlaying"] = false;
|
$event["nowPlaying"] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//event colouring
|
|
||||||
if ($show["color"] != "") {
|
|
||||||
$event["textColor"] = "#".$show["color"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($show["background_color"])) {
|
if (!empty($show["background_color"])) {
|
||||||
$event["color"] = "#" . $show["background_color"];
|
$event["color"] = "#" . $show["background_color"];
|
||||||
} else {
|
} else {
|
||||||
$event["color"] = "#" . self::getDefaultBackgroundColor($startsDT);//DEFAULT_SHOW_COLOR;
|
$event["color"] = "#" . self::getDefaultBackgroundColor($startsDT);//DEFAULT_SHOW_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//event colouring
|
||||||
|
if ($show["color"] != "") {
|
||||||
|
$event["textColor"] = "#".$show["color"];
|
||||||
|
} else {
|
||||||
|
$bg = $event["color"];
|
||||||
|
//Calculate the text colour (black or white) based on the brightness of the background.
|
||||||
|
$r = intval(substr($bg, 1, 2), 16);
|
||||||
|
$g = intval(substr($bg, 3, 2), 16);
|
||||||
|
$b = intval(substr($bg, 5, 2), 16);
|
||||||
|
$brightness = 0.299*floatval($r) + 0.587*floatval($g) + 0.114*floatval($b);
|
||||||
|
if ($brightness > 130) {
|
||||||
|
$event["textColor"] = "#000000";
|
||||||
|
} else {
|
||||||
|
$event["textColor"] = "#fcfcfc";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
$event[$key] = $value;
|
$event[$key] = $value;
|
||||||
}
|
}
|
||||||
|
@ -1067,12 +1081,33 @@ SQL;
|
||||||
/** Get a palettized colour for the show. */
|
/** Get a palettized colour for the show. */
|
||||||
private static function getDefaultBackgroundColor($date) {
|
private static function getDefaultBackgroundColor($date) {
|
||||||
|
|
||||||
|
$basePalette = ['A22BE8', '2FFF8D', 'FF743C', '2ED4FF', 'E8D82B'];
|
||||||
|
// 'B23F11', 'FF7E4A', 'FF6C31'
|
||||||
|
|
||||||
|
/*
|
||||||
$palette = [['42d5a1', '56bd99', '65ab93', '7b938b'],
|
$palette = [['42d5a1', '56bd99', '65ab93', '7b938b'],
|
||||||
['42a4d5', '569bbd', '6594ab', '7b8b93'],
|
['42a4d5', '569bbd', '6594ab', '7b8b93'],
|
||||||
['4264d5', '566fbd', '6576ab', '7b8193']];
|
['4264d5', '566fbd', '6576ab', '7b8193']];
|
||||||
|
*/
|
||||||
|
$palette = [];
|
||||||
|
for ($baseColorIdx = 0; $baseColorIdx < count($basePalette); $baseColorIdx++) {
|
||||||
|
$dayPalette = [];
|
||||||
|
for ($shade = 0.0; $shade < 0.8; $shade += 0.1) {
|
||||||
|
$origColour = $basePalette[$baseColorIdx];
|
||||||
|
$r = intval(substr($origColour, 0, 2), 16);
|
||||||
|
$g = intval(substr($origColour, 2, 2), 16);
|
||||||
|
$b = intval(substr($origColour, 4, 2), 16);
|
||||||
|
$r = floatval($r) * (1.0 - $shade);
|
||||||
|
$g = floatval($g) * (1.0 - $shade);
|
||||||
|
$b = floatval($b) * (1.0 - $shade);
|
||||||
|
$color = sprintf("%02x%02x%02x", $r, $g, $b);
|
||||||
|
array_push($dayPalette, $color);
|
||||||
|
}
|
||||||
|
array_push($palette, $dayPalette);
|
||||||
|
}
|
||||||
|
|
||||||
//$hashValue = (md5($date->format('d'))[0] % $cols) + ((intval($date->format('h'))/24) % $rows);
|
//$hashValue = (md5($date->format('d'))[0] % $cols) + ((intval($date->format('h'))/24) % $rows);
|
||||||
$row = intval($date->format('d')) % sizeof($palette);
|
$row = intval($date->format('w')) % sizeof($palette);
|
||||||
$foo = $date->format('H');
|
$foo = $date->format('H');
|
||||||
$col = intval(intval($date->format('H'))/24.0 * sizeof($palette[0]));
|
$col = intval(intval($date->format('H'))/24.0 * sizeof($palette[0]));
|
||||||
//$color = $palette[$hashValue % sizeof($palette)];
|
//$color = $palette[$hashValue % sizeof($palette)];
|
||||||
|
|
|
@ -605,9 +605,9 @@ table.fc-border-separate {
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: #fff;
|
background: #C3C3C3;
|
||||||
opacity: 0.3;
|
opacity: 0.15;
|
||||||
filter: alpha(opacity=30);
|
filter: alpha(opacity=15);
|
||||||
}
|
}
|
||||||
|
|
||||||
.fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */
|
.fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */
|
||||||
|
|
|
@ -1371,7 +1371,7 @@ thead tr.fc-first
|
||||||
height: 32px;
|
height: 32px;
|
||||||
line-height: 32px;
|
line-height: 32px;
|
||||||
}
|
}
|
||||||
|
ful
|
||||||
/** Extremely nasty workaround for a fullcalendar bug, where clicking "Add Show"
|
/** Extremely nasty workaround for a fullcalendar bug, where clicking "Add Show"
|
||||||
would cause this large space under the table header. The CSS to get to that
|
would cause this large space under the table header. The CSS to get to that
|
||||||
is ridiculously complicated and set in the HTML (!) dynamically with JS,
|
is ridiculously complicated and set in the HTML (!) dynamically with JS,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue