From 306f96164784a8cbf405e72fa4364d6523366e95 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 5 May 2025 15:09:54 +0200 Subject: old dir --- old/bv1/codec/src/split.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 old/bv1/codec/src/split.rs (limited to 'old/bv1/codec/src/split.rs') diff --git a/old/bv1/codec/src/split.rs b/old/bv1/codec/src/split.rs new file mode 100644 index 0000000..c17179e --- /dev/null +++ b/old/bv1/codec/src/split.rs @@ -0,0 +1,42 @@ +use crate::{View, P2}; + +pub fn split(view: View) -> [View; 2] { + let s = view.size(); + if s.x > s.y { + let mid_x = (view.a.x + view.b.x) / 2; + [ + View { + a: view.a, + b: P2 { + x: mid_x, + y: view.b.y, + }, + }, + View { + a: P2 { + x: mid_x, + y: view.a.y, + }, + b: view.b, + }, + ] + } else { + let mid_y = (view.a.y + view.b.y) / 2; + [ + View { + a: view.a, + b: P2 { + x: view.b.x, + y: mid_y, + }, + }, + View { + a: P2 { + x: view.a.x, + y: mid_y, + }, + b: view.b, + }, + ] + } +} -- cgit v1.2.3-70-g09d2