Skip to content

Instantly share code, notes, and snippets.

@wchargin
Created September 14, 2023 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wchargin/6a4bb941fae99d6eb04bbf8da0eb46d9 to your computer and use it in GitHub Desktop.
Save wchargin/6a4bb941fae99d6eb04bbf8da0eb46d9 to your computer and use it in GitHub Desktop.
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;
- let (n_groups, remainder) = (num_points / step, num_points % step);
- let mut result = vec![step; n_groups];
- if remainder > 0 {
- result.push(remainder);
+ Animation::Points { step: _ } => {
+ let mut result = Vec::new();
+ let mut area = 0.0;
+ let mut group = 0;
+ for point in points.0.iter() {
+ area += point.scale * point.scale;
+ group += 1;
+ if area >= 5_000.0 || group >= 50 {
+ println!("frame: group={}, area={}", group, area);
+ result.push(group);
+ if area >= 10_000.0 {
+ result.push(0);
+ result.push(0);
+ result.push(0);
+ }
+ if area >= 5_000.0 {
+ result.push(0);
+ }
+ area = 0.0;
+ group = 0;
+ }
+ }
+ if group > 0 {
+ result.push(group);
}
Some(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment