Skip to content
Merged
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to gitbonsai are recorded here. Any change to how a tree
grows or looks is at least a minor version, because people will notice their
tree changing.

## 0.1.1

Trees change look in this release: smoother wood and softer leaves.

- An optional legend beside the tree (`[render] legend = "left"` or `"right"`,
or `render --legend`): each language's leaf color and what the signs mean.
Off by default; the PNG leaves it out.
- Smoother wood: curved outlines, no knobs where pieces meet, side branches
that start at their own girth instead of as thorns, and tapered tips.
- Softer leaves: each pad is lit as one volume in three soft tones, with cool
shadows and warm light.
- Smaller SVGs.

## 0.1.0

The first release.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gitbonsai"
version = "0.1.0"
version = "0.1.1"
edition = "2024"
rust-version = "1.99.0"
license = "MIT OR Apache-2.0"
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ Grow a Japanese maple bonsai from your GitHub activity: an animated SVG for your

<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/veteran-dark.svg" />
<img src="assets/veteran-light.svg" width="400" alt="A Japanese maple bonsai grown from synthetic GitHub activity" />
<source media="(prefers-color-scheme: dark)" srcset="assets/veteran-legend-dark.svg" />
<img src="assets/veteran-legend-light.svg" width="640" alt="A Japanese maple bonsai grown from synthetic GitHub activity, with a legend of its leaf colors and signs" />
</picture>
</p>

The tree is yours: it grows from your own GitHub activity, week by week. The trunk rises with the years you've been active and thickens with every contribution you've ever made. Each language you write grows branches on its own side, with leaves in that language's color. Your last few months decide how full the leaves are, so busy stretches show and quiet ones thin the crown. Wood never shrinks, so the tree remembers everything.

| Newbie | Comeback | Veteran |
| :---: | :---: | :---: |
| <picture><source media="(prefers-color-scheme: dark)" srcset="assets/newbie-dark.svg" /><img src="assets/newbie-light.svg" width="260" alt="A newcomer bonsai: a young tree in its first pot" /></picture> | <picture><source media="(prefers-color-scheme: dark)" srcset="assets/comeback-dark.svg" /><img src="assets/comeback-light.svg" width="260" alt="A comeback bonsai: deadwood from the quiet years, new growth since" /></picture> | <picture><source media="(prefers-color-scheme: dark)" srcset="assets/veteran-dark.svg" /><img src="assets/veteran-light.svg" width="260" alt="A veteran bonsai: tall, thick and full" /></picture> |
| a few months in | quiet for two years, then back | 16 years, busy since 2023 |

<details>
<summary>What every part shows</summary>

Expand Down Expand Up @@ -55,7 +60,7 @@ On your profile, copy [examples/profile-workflow.yml](examples/profile-workflow.

On its own, `width="600"` suits a desktop column, and phones scale it down to fit. Next to other cards, use `400`.

Styles, leaf colors and the pot glaze go in a `bonsai.toml`; see [examples/bonsai.toml](examples/bonsai.toml).
Styles, leaf colors, the pot glaze and an optional legend (left or right of the tree) go in a `bonsai.toml`; see [examples/bonsai.toml](examples/bonsai.toml).

## Credits

Expand Down
1 change: 1 addition & 0 deletions assets/comeback-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/comeback-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/newbie-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/newbie-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/veteran-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/veteran-legend-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/veteran-legend-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/veteran-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion examples/bonsai.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ color = "#F4C7D3"

[render]
animate = true
size = 400 # display width in px; the viewBox stays 512
size = 400 # display width in px; the height follows the tree
legend = "off" # "left" or "right": what the colors and signs mean
29 changes: 29 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,42 @@ pub struct RenderConfig {
pub animate: bool,
/// Display width in pixels; the height follows the tree's frame.
pub size: u32,
/// A legend beside the tree: what the colors and signs mean.
pub legend: Legend,
}

impl Default for RenderConfig {
fn default() -> Self {
Self {
animate: true,
size: 400,
legend: Legend::Off,
}
}
}

/// Where the legend goes, if anywhere.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Legend {
/// No legend: just the tree.
#[default]
Off,
/// Left of the tree.
Left,
/// Right of the tree.
Right,
}

impl std::str::FromStr for Legend {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"off" => Ok(Self::Off),
"left" => Ok(Self::Left),
"right" => Ok(Self::Right),
_ => Err(format!("legend must be off, left or right, not {s:?}")),
}
}
}
Expand Down
33 changes: 24 additions & 9 deletions src/eggs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use std::fmt::Write as _;

use crate::Bonsai;
use crate::color::Rgb;
use crate::config::Legend;
use crate::growth::GOLDEN;
use crate::math;
use crate::noise::{fbm, hash01, noise1};
Expand Down Expand Up @@ -139,8 +140,9 @@ fn take_spot(
/// The easter eggs of `b`'s achievements.
/// Where the moon hangs: the clearer of the frame's top corners. When both
/// are crowded, the frame grows upward until the moon's disc stands clear.
/// `k` is the moon's size relative to a full-grown frame.
fn moon_spot(scene: &Scene, frame: &mut Frame, k: f64) -> (f64, f64) {
/// `k` is the moon's size relative to a full-grown frame. With a legend, the
/// corner away from it wins whenever it is clear.
fn moon_spot(scene: &Scene, frame: &mut Frame, k: f64, legend: Legend) -> (f64, f64) {
let inset = 34.0 * k;
let clear = 30.0 * k;
let mut pts: Vec<(f64, f64)> = scene
Expand All @@ -165,10 +167,15 @@ fn moon_spot(scene: &Scene, frame: &mut Frame, k: f64) -> (f64, f64) {
let top = frame.1 + inset;
let left = (frame.0 + inset, top);
let right = (frame.0 + frame.2 - inset, top);
let (spot, room) = if clearance(left) > clearance(right) {
(left, clearance(left))
} else {
(right, clearance(right))
let away = match legend {
Legend::Right => Some(left),
Legend::Left => Some(right),
Legend::Off => None,
};
let (spot, room) = match away {
Some(c) if clearance(c) >= clear => (c, clearance(c)),
_ if clearance(left) > clearance(right) => (left, clearance(left)),
_ => (right, clearance(right)),
};
if room >= clear {
return spot;
Expand All @@ -179,8 +186,16 @@ fn moon_spot(scene: &Scene, frame: &mut Frame, k: f64) -> (f64, f64) {
(spot.0, spot.1 - lift)
}

/// The easter eggs of `b`'s achievements. The moon may grow `frame` upward.
pub fn eggs(b: &Bonsai, scene: &Scene, paints: &Paints, pot: &Pot, frame: &mut Frame) -> Eggs {
/// The easter eggs of `b`'s achievements. The moon may grow `frame` upward,
/// and keeps clear of the legend's side.
pub fn eggs(
b: &Bonsai,
scene: &Scene,
paints: &Paints,
pot: &Pot,
frame: &mut Frame,
legend: Legend,
) -> Eggs {
let mut e = Eggs::default();
let tier = |slug: &str| b.achievements.get(slug).copied();
if !DRAWN.iter().any(|slug| tier(slug).is_some()) {
Expand Down Expand Up @@ -350,7 +365,7 @@ pub fn eggs(b: &Bonsai, scene: &Scene, paints: &Paints, pot: &Pot, frame: &mut F
if t >= 3 {
// Sized to the frame, so it never looms over a young tree.
let k = (frame.2 / 480.0).clamp(0.5, 1.0);
let at = moon_spot(scene, frame, k);
let at = moon_spot(scene, frame, k, legend);
// Golden with a halo on light backgrounds, pale on dark: visible on both.
let (body, halo, crater) = if dark {
("#f3e3a3", "#f6e9b2", "#d9c47e")
Expand Down
Loading
Loading