Skip to content

Instantly share code, notes, and snippets.

<style type="text/css">
@keyframes color-animation {
...
<?php
foreach($sun as $k => $v){
$momentSeconds = $v - $zeroSecondTs;
$dayPercent = (int)($momentSeconds / 864);
?>
/* The color during <?= $k; ?> */
<?= $dayPercent ?>% {
<style type="text/css">
@keyframes color-animation {
/*
the colors at
"midnight"
*/
0%, 100% {
background: rgba(0, 7, 22, 1);
color: #f7ca83;
}
// ============================================================================
// Optional:
// Select a random picture from different time-of-day sets
// selected choice is loaded into $headerImageName for use in your page
// ============================================================================
// default to the daytime set
$activePicSet = $dayPics;
switch($nowSecond){
// Optional: load a random pic from different sets corresponding to times of day
$dayPics =
[
'day1.png',
'day2.png',
'day3.png',
'day4.png',
'day5.png',
'day6.png'
];
<?php
// ============================================================================
// Config section
// Set up whatever values you want for the circadian animation
// ============================================================================
// Time zone used to do day/night calculations
$targetTimezone = 'America/Los_Angeles';
// Coordinates used to retrieve circadian cycle information (Lat, Long)
<head>
...
<?php
/*
Configure the configuration section
of circadian_css_animation.php
to match your own needs
*/
require('circadian_css_animation.php');
?>
<head>
...
<?php
/*
Configure the configuration section
of circadian_css_animation.php
to match your own needs
*/
require('circadian_css_animation.php');
?>