Optimized asciinema output a bit. - icy_draw - icy_draw is the successor to mystic draw. fork / mirror
 (HTM) git clone https://git.drkhsh.at/icy_draw.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f3fd9dcc71a600919fd719c38f28fb78ab3552da
 (DIR) parent 9ec3554930debcf3715234f0699d46933e749023
 (HTM) Author: Mike Krüger <mkrueger@posteo.de>
       Date:   Wed,  4 Oct 2023 20:14:24 +0200
       
       Optimized asciinema output a bit.
       
       Diffstat:
         M src/ui/editor/animation/asciicast_… |      11 ++++++-----
       
       1 file changed, 6 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/src/ui/editor/animation/asciicast_encoder.rs b/src/ui/editor/animation/asciicast_encoder.rs
       @@ -1,4 +1,4 @@
       -use icy_engine::{SaveOptions, StringGenerator, TextPane};
       +use icy_engine::{SaveOptions, StringGenerator, TextPane, ColorOptimizer};
        use icy_engine_egui::animations::Animator;
        use std::{
            fs::File,
       @@ -33,8 +33,8 @@ impl AnimationEncoder for AsciiCast {
                        buf.get_width(),
                        buf.get_height(),
                        name,
       -                buf.palette.get_color(0).to_hex(),
                        buf.palette.get_color(7).to_hex(),
       +                buf.palette.get_color(0).to_hex(),
                        buf.palette.color_iter().take(16).fold(String::new(), |mut s, x| {
                            if !s.is_empty() {
                                s.push(':');
       @@ -54,10 +54,11 @@ impl AnimationEncoder for AsciiCast {
                    opt.preserve_line_length = true;
                    opt.modern_terminal_output = true;
        
       -            let mut gen = StringGenerator::new(opt);
       +            let mut gen = StringGenerator::new(opt.clone());
                    {
       -                let buf = &animator.lock().unwrap().frames[frame].0;
       -                gen.generate(buf, buf);
       +                let optimizer = ColorOptimizer::new(&animator.lock().unwrap().frames[frame].0, &opt);
       +                let buf = optimizer.optimize(&animator.lock().unwrap().frames[frame].0);
       +                gen.generate(&buf, &buf);
                    }
                    gen.line_offsets.push(gen.get_data().len());