Has my motd gone too far? It loads a random ANSI catgirl from a folder. I use arch btw, server runs minimized Ubuntu Server.

  • rtxn@lemmy.worldM
    link
    fedilink
    arrow-up
    44
    ·
    14 hours ago

    You could double the vertical resolution by using half-height blocks (U+2584) and using the background color for the upper half.

    • Finadil@lemmy.worldOP
      link
      fedilink
      arrow-up
      15
      ·
      12 hours ago

      Thanks for the suggestion, gonna look into this. I didn’t want to use real images even though kitty supports them because I like the retro look and wanted it terminal agnostic for when I use termux on my phone.

      • TwilightKiddy@programming.dev
        link
        fedilink
        English
        arrow-up
        13
        ·
        edit-2
        9 hours ago

        I gladly present you this jank.

        You might need these to compile:

        cargo add image
        cargo add clap --features derive
        

        And the jank itself:

        Some Rust code
        use std::path::PathBuf;
        
        use clap::Parser;
        use image::{ imageops::{self, FilterType}, ImageReader };
        
        #[derive(Parser)]
        struct Cli {
            path: PathBuf,
            #[arg(short = 'H', long, default_value_t = 30)]
            height: u32,
            #[arg(short, long, default_value_t = 0.4)]
            ratio: f32,
            #[arg(short, long, default_value_t, value_enum)]
            filter: Filter,
        }
        
        #[derive(clap::ValueEnum, Clone, Default)]
        enum Filter {
            Nearest,
            Triangle,
            Gaussian,
            CatmullRom,
            #[default]
            Lanczos3,
        }
        
        fn main() -> Result<(), Box<dyn std::error::Error>> {
            let args = Cli::parse();
            let filter = match args.filter {
                Filter::Nearest    => { FilterType::Nearest },
                Filter::Triangle   => { FilterType::Triangle },
                Filter::CatmullRom => { FilterType::CatmullRom },
                Filter::Gaussian   => { FilterType::Gaussian },
                Filter::Lanczos3   => { FilterType::Lanczos3 },
            };
            let img = ImageReader::open(args.path)?.decode()?;
            let original_ratio = img.width() as f32 / img.height() as f32;
            let width = ( args.height as f32 / args.ratio ) * original_ratio;
            let out = imageops::resize(&img, width as u32, args.height * 2, filter);
            let mut iter = out.enumerate_rows();
            while let Some((_, top)) = iter.next() {
                let (_, bottom) = iter.next().unwrap();
                top.zip(bottom)
                    .for_each(|((_, _, t), (_, _, b))| {
                        print!("\x1B[38;2;{};{};{};48;2;{};{};{}m\u{2584}", b[0], b[1], b[2], t[0], t[1], t[2])
                    });
                println!("\x1B[0m");
            }
            Ok(())
        }
        
        • Finadil@lemmy.worldOP
          link
          fedilink
          arrow-up
          6
          ·
          8 hours ago

          It’s beautiful! I actually adjusted my python code to your method and just for optimization checked if the current two pixel colors match the previous two and if so leave out the color info. Much more fidelity in the images now!

        • rtxn@lemmy.worldM
          link
          fedilink
          arrow-up
          5
          ·
          edit-2
          8 hours ago

          I’ve been learning Rust by going through The Book… there’s some wack-ass syntax in that language. I’ve mostly used C# and Python so most of it just looks weird… I can more or less understand what while let Some((_, top)) = iter.next() { ... } is doing, but .for_each(|((_, _, t), (_, _, b))| { ... } just looks like an abomination. And I mean the syntax in general, not this code in particular.

          • __dev@lemmy.world
            link
            fedilink
            arrow-up
            4
            ·
            7 hours ago

            but .for_each(|((_, , t), (, _, b))| { … } just looks like an abomination

            It’s not so different in python: for ((_, _, t), (_, _, b)) in zip(top, bottom):

            Or in C#: .ForEach(((_, _, t), (_, _, b)) => Console.Write(...));

              • Ignotum@lemmy.world
                link
                fedilink
                arrow-up
                1
                ·
                4 hours ago

                Yep, lambda or closure (it’s an anonymous function but it can also capture state from the enclosing function, i think pure lambdas can’t do that?)

    • Lucy :3@feddit.org
      link
      fedilink
      arrow-up
      4
      ·
      14 hours ago

      Or using sixels. For example foot supports them, and you can display one with chafa.

  • NateNate60@lemmy.world
    link
    fedilink
    arrow-up
    34
    ·
    16 hours ago

    It would be cringe if you were using a shared server and set this as a default for everyone or if it was interfering with something. But if you’re just minding your own business I could not care less what customisations you put on your terminal as long as it isn’t using excessive resources

    • Finadil@lemmy.worldOP
      link
      fedilink
      arrow-up
      7
      ·
      13 hours ago

      I considered using kitty’s built-in ssh kitten to display real images, but I ended up liking the retro look more.

  • db2@lemmy.world
    link
    fedilink
    arrow-up
    14
    ·
    16 hours ago

    I can’t hate on ANSI art even if I’m not in to what the art is of. 🤷

  • tuckerm@feddit.online
    link
    fedilink
    English
    arrow-up
    10
    ·
    16 hours ago

    Nah, I don’t think so. I mean, sure, arch is a little cringe, but it’s not that bad. Cool terminal, btw.