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
342 changes: 5 additions & 337 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ umbra = "0.5.0"

[dev-dependencies]
dircpy = "0.3.21"
font8x8 = "0.3.1"
rstest = "0.27.0"
tempfile = "3.27.0"
text-to-png = "0.3.0"

[profile.release]
codegen-units = 1
Expand Down
43 changes: 27 additions & 16 deletions src/tests/graph.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::Path;

use chrono::{Days, TimeZone, Utc};
use font8x8::{UnicodeFonts, BASIC_FONTS};
use image::{GenericImage, GenericImageView};
use rustc_hash::{FxHashMap, FxHashSet};

Expand Down Expand Up @@ -1923,7 +1924,6 @@ fn generate_and_output_graph_image<P: AsRef<Path>>(path: P, option: &GenerateGra
let mut img_buf: image::ImageBuffer<image::Rgba<u8>, Vec<u8>> =
image::ImageBuffer::new(image_width, image_height);

let text_renderer = text_to_png::TextRenderer::default();
let text_x = (width * (graph.max_pos_x + 1)) as u32;

for (i, edges) in graph.edges.iter().enumerate() {
Expand All @@ -1941,23 +1941,15 @@ fn generate_and_output_graph_image<P: AsRef<Path>>(path: P, option: &GenerateGra
commit.commit_hash.as_short_hash(),
commit.committer_date.naive_utc().format("%Y-%m-%d")
);
let text_png = text_renderer
.render_text_to_png_data(text, height / 4, 0x888888)
.unwrap();
let text_image = image::load_from_memory(&text_png.data).unwrap();
img_buf
.copy_from(&text_image, text_x, y + (height as u32 / 4))
.unwrap();
draw_text(&mut img_buf, &text, text_x, y + (height as u32 / 4));

// write subject
let text = &commit.subject;
let text_png = text_renderer
.render_text_to_png_data(text, height / 4, 0x888888)
.unwrap();
let text_image = image::load_from_memory(&text_png.data).unwrap();
img_buf
.copy_from(&text_image, text_x, y + ((height as u32 / 4) * 2))
.unwrap();
draw_text(
&mut img_buf,
&commit.subject,
text_x,
y + ((height as u32 / 4) * 2),
);
}

// Save
Expand All @@ -1973,6 +1965,25 @@ fn generate_and_output_graph_image<P: AsRef<Path>>(path: P, option: &GenerateGra
.unwrap();
}

fn draw_text(img_buf: &mut image::RgbaImage, text: &str, x: u32, y: u32) {
for (i, ch) in text.chars().enumerate() {
let glyph = BASIC_FONTS
.get(ch)
.unwrap_or_else(|| panic!("unsupported graph test character: {ch:?}"));
for (row, bits) in glyph.iter().enumerate() {
for col in 0..8 {
if bits & (1 << col) != 0 {
img_buf.put_pixel(
x + i as u32 * 8 + col,
y + row as u32,
image::Rgba([0x88, 0x88, 0x88, 0xff]),
);
}
}
}
}
}

#[derive(Debug, Default)]
pub struct GraphImage {
pub images: FxHashMap<Vec<Edge>, GraphRowImage>,
Expand Down
Binary file modified tests/graph/branch_001_angular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_001_angular_antialias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_001_chrono.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_001_curved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_001_curved_antialias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_001_max_count.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_001_rounded_antialias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_001_topo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_002_angular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_002_chrono.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_002_max_count.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_002_topo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_003_angular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_003_angular_antialias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_003_chrono.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_003_curved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_003_curved_antialias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_003_rounded_antialias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_003_topo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_004_angular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_004_chrono.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_004_topo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_005_angular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_005_chrono.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_005_topo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/graph/branch_006_angular.png
Binary file modified tests/graph/branch_006_chrono.png
Binary file modified tests/graph/branch_006_topo.png
Binary file modified tests/graph/branch_007_angular.png
Binary file modified tests/graph/branch_007_chrono.png
Binary file modified tests/graph/branch_007_topo.png
Binary file modified tests/graph/branch_008_angular.png
Binary file modified tests/graph/branch_008_chrono.png
Binary file modified tests/graph/branch_008_topo.png
Binary file modified tests/graph/complex_001_angular.png
Binary file modified tests/graph/complex_001_angular_antialias.png
Binary file modified tests/graph/complex_001_chrono.png
Binary file modified tests/graph/complex_001_curved.png
Binary file modified tests/graph/complex_001_curved_antialias.png
Binary file modified tests/graph/complex_001_rounded_antialias.png
Binary file modified tests/graph/complex_001_topo.png
Binary file modified tests/graph/head_001_angular.png
Binary file modified tests/graph/head_001_chrono.png
Binary file modified tests/graph/head_001_topo.png
Binary file modified tests/graph/merge_001_angular.png
Binary file modified tests/graph/merge_001_chrono.png
Binary file modified tests/graph/merge_001_topo.png
Binary file modified tests/graph/merge_002_angular.png
Binary file modified tests/graph/merge_002_chrono.png
Binary file modified tests/graph/merge_002_topo.png
Binary file modified tests/graph/merge_003_angular.png
Binary file modified tests/graph/merge_003_chrono.png
Binary file modified tests/graph/merge_003_topo.png
Binary file modified tests/graph/merge_004_angular.png
Binary file modified tests/graph/merge_004_angular_antialias.png
Binary file modified tests/graph/merge_004_chrono.png
Binary file modified tests/graph/merge_004_curved.png
Binary file modified tests/graph/merge_004_curved_antialias.png
Binary file modified tests/graph/merge_004_rounded_antialias.png
Binary file modified tests/graph/merge_004_topo.png
Binary file modified tests/graph/merge_005_angular.png
Binary file modified tests/graph/merge_005_chrono.png
Binary file modified tests/graph/merge_005_topo.png
Binary file modified tests/graph/merge_006_angular.png
Binary file modified tests/graph/merge_006_chrono.png
Binary file modified tests/graph/merge_006_topo.png
Binary file modified tests/graph/orphan_001_angular.png
Binary file modified tests/graph/orphan_001_chrono.png
Binary file modified tests/graph/orphan_001_topo.png
Binary file modified tests/graph/orphan_002_angular.png
Binary file modified tests/graph/orphan_002_chrono.png
Binary file modified tests/graph/orphan_002_topo.png
Binary file modified tests/graph/primary_branch_001_chrono.png
Binary file modified tests/graph/primary_branch_001_topo.png
Binary file modified tests/graph/stash_001_angular.png
Binary file modified tests/graph/stash_001_chrono.png
Binary file modified tests/graph/stash_001_topo.png
Binary file modified tests/graph/stash_002_angular.png
Binary file modified tests/graph/stash_002_chrono.png
Binary file modified tests/graph/stash_002_topo.png
Binary file modified tests/graph/stash_003_angular.png
Binary file modified tests/graph/stash_003_chrono.png
Binary file modified tests/graph/stash_003_topo.png
Binary file modified tests/graph/stash_004_angular.png
Binary file modified tests/graph/stash_004_chrono.png
Binary file modified tests/graph/stash_004_topo.png
Binary file modified tests/graph/straight_001.png
Loading