Skip to content

Instantly share code, notes, and snippets.

View wchargin's full-sized avatar

wchargin wchargin

View GitHub Profile
@wchargin
wchargin / cmp.js
Created February 5, 2024 23:07
sortAsciinumeric, extractNumbers: numeric-aware string sorting
/**
* A comparator that follows elements' natural ordering. Useful for comparing
* numbers: `[8, 9, 10].sort()` is broken, but `[8, 9, 10].sort(natural)` works
* as expected. Also useful as a "neutral" comparator to give to combinators.
*/
function natural(a, b) {
if (a > b) return 1;
if (a < b) return -1;
return 0;
}
@wchargin
wchargin / chances.dat
Last active October 30, 2023 00:21
plot backpack battles item chances
round common rare epic legend godly
1 90 10 0 0 0
2 84 15 1 0 0
3 75 20 5 0 0
4 64 25 10 1 0
5 45 35 15 5 0
6 29 40 20 10 1
7 20 35 25 15 5
8 20 30 25 15 10
9 20 28 25 15 12
@wchargin
wchargin / Caddyfile
Last active October 29, 2023 06:07
Caddy x GCS reverse proxy via storage.googleapis.com
# requires caddyserver/cache-handler module
{
order cache before rewrite
cache
log default {
output stdout
# http.handlers.cache logs the entire contents of request
# bodies at info level(??!)
exclude http.handlers.cache
@wchargin
wchargin / art.rs.patch
Created October 11, 2023 20:16
dump flow fields before and after disturbances
diff --git a/src/art.rs b/src/art.rs
index bcba7e0..1d99457 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -548,10 +548,84 @@ impl FlowField {
} => Self::raw_circular(*circularity, *direction, *rotation, traits.version, rng),
};
let disturbances = Disturbance::build(traits, rng);
+ ff.dump(&[], "flowfield0_initial.png").unwrap();
+ ff.dump(&disturbances, "flowfield1_disturbances.png")
@wchargin
wchargin / art.rs.patch
Created October 4, 2023 19:28
color bullseyes by ring count in qqlrs
diff --git a/src/art.rs b/src/art.rs
index 953bf99..ffec2d1 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -1431,14 +1431,21 @@ fn draw_ring_dot(pt: &Point, pctx: &mut PaintCtx, rng: &mut Rng) {
variance_adjust * rescale(num_rings as f64, (1.0, 7.0), (0.022, 0.008))
};
+ // https://personal.sron.nl/~pault/
+ const SEQ: [Rgb; 7] = [
@wchargin
wchargin / art.rs.patch
Created October 3, 2023 19:14
hacky patch to qqlrs to force wide margin and specific background color
diff --git a/src/art.rs b/src/art.rs
index 953bf99..f605dfd 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -521,8 +521,9 @@ impl ColorScheme {
let splatter_center = (rng.uniform(w(-0.1), w(1.1)), rng.uniform(h(-0.1), h(1.1)));
let splatter_odds = *rng.wc(splatter_odds_choices);
+ let bg_override: ColorKey = color_db.color_key_by_name("Fidenza Brown").unwrap();
ColorScheme {
@wchargin
wchargin / art.rs.patch
Created September 14, 2023 15:49
qqlrs animation schedule patch to slow down around larger rings
diff --git a/src/art.rs b/src/art.rs
index 97a18d1..cf2b600 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -1646,12 +1646,30 @@ pub fn draw<F: FnMut(Frame)>(
let batch_sizes = match config.animate {
Animation::None => None,
Animation::Groups => Some(group_sizes.0),
- Animation::Points { step } => {
- let step = step as usize;
@wchargin
wchargin / layout-order.patch
Created September 14, 2023 01:18
qqlrs patch: debug pass to show progress of layout through flow line groups
diff --git a/src/art.rs b/src/art.rs
index 78e28bf..970b0e0 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -813,6 +813,7 @@ impl MarginChecker {
#[derive(Debug, Clone)]
pub struct Point {
+ pub group_idx: u32,
pub position: (f64, f64),
@wchargin
wchargin / art.rs.patch
Created September 14, 2023 00:32
patches to qqlrs to force Margin::Wide and reduce scale changes
diff --git a/src/art.rs b/src/art.rs
index 78e28bf..aaf353f 100644
--- a/src/art.rs
+++ b/src/art.rs
@@ -213,7 +213,7 @@ impl ColorChangeOdds {
}
}
-#[derive(Debug)]
+#[derive(Debug, Clone)]
use std::collections::{HashMap, HashSet};
struct Pawn;
struct Bishop;
struct Rook;
struct Monarch;
struct Knight;
/// A subset of the squares on a chess board.
///