From d395e2bc75d35e117b02762a9322333eb5e452e4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 8 Oct 2025 12:18:04 -0400 Subject: [PATCH] Introduce animated crop. --- .../xcschemes/Clock Signal Kiosk.xcscheme | 2 +- Outputs/CRT/CRT.cpp | 25 ++++++++++++++++--- Outputs/CRT/CRT.hpp | 8 ++++-- Outputs/CRT/Internals/RectAccumulator.hpp | 6 ++--- Outputs/ScanTarget.hpp | 9 +++++++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal Kiosk.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal Kiosk.xcscheme index 49a1f6e3e..8ddc3c375 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal Kiosk.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal Kiosk.xcscheme @@ -57,7 +57,7 @@ isEnabled = "NO"> set_modals(scan_target_modals_); + + ++animation_step_; } + // TODO: probably something more gradated. levels_are_interesting_ = level_changes_in_frame_ >= 5; } active_rect_ = Display::Rect(65536.0f, 65536.0f, 0.0f, 0.0f); diff --git a/Outputs/CRT/CRT.hpp b/Outputs/CRT/CRT.hpp index 3d6bcf881..b3e9e4e69 100644 --- a/Outputs/CRT/CRT.hpp +++ b/Outputs/CRT/CRT.hpp @@ -370,11 +370,15 @@ private: static constexpr uint8_t DefaultAmplitude = 41; // Accumulator for interesting detail from this frame. - Outputs::Display::Rect active_rect_, posted_rect_; + Outputs::Display::Rect active_rect_; + bool frame_is_complete_ = false; + + // Current state of cropping rectangle as communicated onwards. + Outputs::Display::Rect posted_rect_, previous_posted_rect_; Numeric::CubicCurve animation_curve_; + int animation_step_ = 0; static constexpr int AnimationSteps = 25; - bool frame_is_complete_ = false; bool levels_are_interesting_ = false; int level_changes_in_frame_ = 0; diff --git a/Outputs/CRT/Internals/RectAccumulator.hpp b/Outputs/CRT/Internals/RectAccumulator.hpp index 6871d0e52..782f35de6 100644 --- a/Outputs/CRT/Internals/RectAccumulator.hpp +++ b/Outputs/CRT/Internals/RectAccumulator.hpp @@ -32,7 +32,6 @@ private: struct RectHistory { void push_back(const Display::Rect &rect) { stream_[stream_pointer_] = rect; - ++stream_pointer_; if(stream_pointer_ == n) stream_pointer_ = 0; } @@ -67,8 +66,9 @@ private: size_t stream_pointer_ = 0; }; - RectHistory<8> unions_; - RectHistory<8> candidates_; + RectHistory<32> unions_; // A long record, to try to avoid instability caused by interlaced video, flashing + // cursors, etc. + RectHistory<28> candidates_; }; } diff --git a/Outputs/ScanTarget.hpp b/Outputs/ScanTarget.hpp index 24aef3684..e3c14c860 100644 --- a/Outputs/ScanTarget.hpp +++ b/Outputs/ScanTarget.hpp @@ -79,6 +79,15 @@ struct Rect { ); } + Rect operator +(const Rect &rhs) const { + return Rect( + origin.x + rhs.origin.x, + origin.y + rhs.origin.y, + size.width + rhs.size.width, + size.height + rhs.size.height + ); + } + Rect operator /(const float multiplier) const { return Rect( origin.x / multiplier,