AI Day Pie Clock - Time as a Shrinking Pie

59 views Β· Dec 14, 2025

See your day from a new perspective! A pie chart shows how much of your day is gone (dark) vs remaining (light). The current time displays in the center, with hours until midnight shown below. Past 6pm the remaining slice turns orange, past 9pm turns red for urgency. A unique, useful way to visualize time passing.

#xelsedia#xelsedai#clock#utility#datadriven
πŸ”€ Remix This πŸ“– View Docs β›Ά Full Screen ← Back to Gallery
πŸ“‹ Embed Code

Copy this code to embed this sketch on your website:

<iframe src="https://p5js.ai/embed/8e553f1a-cc76-4dda-bf65-3c48d1630966" width="400" height="400" frameborder="0" allow="autoplay" title="AI Day Pie Clock - Time as a Shrinking Pie"></iframe>

Adjust width and height as needed. Preview embed β†’

❓ About This Sketch 3 questions

What visual representation does the AI Day Pie Clock sketch create?

The sketch visually represents the passage of time as a pie chart, illustrating how much of the day has elapsed versus how much remains, with color changes indicating urgency as the day progresses.

Is there any interaction available for users in the AI Day Pie Clock sketch?

The sketch does not offer interactive features; it simply displays the current time and the visual representation of the day as a pie chart.

What creative coding concepts are demonstrated in the AI Day Pie Clock sketch?

This sketch demonstrates the use of p5.js for real-time data visualization, utilizing arcs to create a pie chart and color coding to convey urgency in relation to time.

πŸ’¬ AI Chat History 2 messages
πŸ‘€ You
Create a clock that visualizes the day as a pie chart. Light background. Large pie chart in center shows how much of the day is gone (dark slice) vs remaining (light slice). The dark slice grows as the day progresses. Show current time in center of pie. Display 'X hours until midnight' below. Add motivational urgency - when past 6pm the remaining slice turns orange, past 9pm turns red. Simple, useful perspective on time passing. Under 50 lines.
πŸ€– AI
Here’s a complete version of your project with the β€œday as a pie chart” clock, under 50 lines in `sketch.js`.

---

### `index.html`
Make sure p5.js is loaded before `sketch.js`:

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Day Pie Clock</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/p5@1.11.3/lib/p5.min.js"></script>
<script src="sketch.js"></script>
</body>
</html>
```

---

### `style.css`

```css
body {
margin: 0;
padding: 0;
overflow: hidden;
background: #f5f5f5;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

canvas {
display: block;
}
```

---

### `sketch.js` *(32 lines)*

```js
function setup() {
createCanvas(windowWidth, windowHeight);
textAlign(CENTER, CENTER);
}

function draw() {
background(245);
let h = hour(), m = minute(), s = second();
let total = h * 3600 + m * 60 + s;
let frac = total / 86400;
let start = -HALF_PI, ang = frac * TWO_PI;
let d = min(width, height) * 0.6;
let cx = width / 2, cy = height / 2;
let remainingCol = color(235);
if (h >= 21) remainingCol = color(255, 80, 80);
else if (h >= 18) remainingCol = color(255, 160, 60);
noStroke();
fill(remainingCol); arc(cx, cy, d, d, start, start + TWO_PI, PIE);
fill(40); arc(cx, cy, d, d, start, start + ang, PIE);
fill(20);
textSize(d * 0.12);
let hh = nf(h, 2), mm = nf(m, 2), ss = nf(s, 2);
text(hh + ":" + mm + ":" + ss, cx, cy);
textSize(d * 0.06);
let hrsLeft = 24 - (h + m / 60 + s / 3600);
hrsLeft = max(0, hrsLeft);
text("Only " + hrsLeft.toFixed(1) + " hours until midnight", cx, cy + d * 0.35);
}

function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
```

---

**How it works (brief):**

- Uses `hour()`, `minute()`, `second()` from p5.js ([docs](https://p5js.org/reference/#/p5/hour)) to get current time.
- Converts to seconds since midnight, then to a fraction of the 24‑hour day.
- Draws a big circle at the center:
- Remaining time slice: light (turns orange after 18:00, red after 21:00).
- Elapsed time slice: dark wedge that grows as the day passes.
- Shows `HH:MM:SS` in the center and
`"Only X hours until midnight"` below, with one decimal place for urgency.
🎬 Video Preview