Created
October 3, 2023 19:14
-
-
Save wchargin/e19b1e09b93f3b0367ebd90e581b638e to your computer and use it in GitHub Desktop.
hacky patch to qqlrs to force wide margin and specific background color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
- background: bg.color, | |
+ background: bg_override, | |
primary_seq, | |
secondary_seq, | |
splatter_odds, | |
@@ -787,7 +788,11 @@ pub struct MarginChecker { | |
} | |
impl MarginChecker { | |
pub fn from_traits(traits: &Traits) -> Self { | |
- match traits.margin { | |
+ Self::new(traits.margin) | |
+ } | |
+ | |
+ pub fn new(margin: Margin) -> Self { | |
+ match margin { | |
Margin::None => Self { | |
margin: w(-0.05), | |
bottom_margin: w(-0.05), | |
@@ -1551,6 +1556,14 @@ fn draw_clean_circle( | |
// We don't need to compute that, but we need to burn a uniform deviate to keep RNG synced. | |
rng.rnd(); | |
+ // HACK: Cull points that would be outside a wide margin. | |
+ // (This isn't equivalent to using a wide margin because flow lines don't start packed against | |
+ // it, but it gives something of an approximation.) | |
+ let margin_wide = MarginChecker::new(Margin::Wide); | |
+ if !margin_wide.in_bounds((x, y), 0.0) { | |
+ return; | |
+ } | |
+ | |
if x + (rx + stroke_weight / 2.0) < pctx.viewport.left | |
|| x - (rx + stroke_weight / 2.0) > pctx.viewport.right | |
|| y + (ry + stroke_weight / 2.0) < pctx.viewport.top | |
diff --git a/src/color.rs b/src/color.rs | |
index 002845b..02c06ac 100644 | |
--- a/src/color.rs | |
+++ b/src/color.rs | |
@@ -192,8 +192,12 @@ impl ColorDb { | |
self.colors.get(key as usize) | |
} | |
+ pub fn color_key_by_name(&self, name: &str) -> Option<ColorKey> { | |
+ self.colors_by_name.get(name).copied() | |
+ } | |
+ | |
pub fn color_by_name(&self, name: &str) -> Option<&ColorSpec> { | |
- self.color(*self.colors_by_name.get(name)?) | |
+ self.color(self.color_key_by_name(name)?) | |
} | |
pub fn palette(&self, palette_key: crate::traits::ColorPalette) -> Option<&PaletteSpec> { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment