this post was submitted on 16 Jun 2025
223 points (93.7% liked)
linuxmemes
25655 readers
850 users here now
Hint: :q!
Sister communities:
Community rules (click to expand)
1. Follow the site-wide rules
- Instance-wide TOS: https://legal.lemmy.world/tos/
- Lemmy code of conduct: https://join-lemmy.org/docs/code_of_conduct.html
2. Be civil
- Understand the difference between a joke and an insult.
- Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
- Don't get baited into back-and-forth insults. We are not animals.
- Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
- Bigotry will not be tolerated.
3. Post Linux-related content
- Including Unix and BSD.
- Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of
sudo
in Windows. - No porn, no politics, no trolling or ragebaiting.
4. No recent reposts
- Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
5. π¬π§ Language/ΡΠ·ΡΠΊ/Sprache
- This is primarily an English-speaking community. π¬π§π¦πΊπΊπΈ
- Comments written in other languages are allowed.
- The substance of a post should be comprehensible for people who only speak English.
- Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
6. (NEW!) Regarding public figures
We all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations. - Keep discussions polite and free of disparagement.
- We are never in possession of all of the facts. Defamatory comments will not be tolerated.
- Discussions that get too heated will be locked and offending comments removed. Β
Please report posts and comments that break these rules!
Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You could double the vertical resolution by using half-height blocks (
U+2584
) and using the background color for the upper half.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.
I gladly present you this jank.
You might need these to compile:
And the jank itself:
Some Rust code
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!
As an extra optimization, if top and bottom colors of a pixel match, you can just output space and only set background color. Implemented correctly, this can save a lot of memory. Didn't want to make the code more complex in fear of people being scared of running it.
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.This is actually fairly similar to what C# has.
This is a closure syntax:
In C#, the closest is lambda expressions, declared like this:
Parentheses are tuple deconstructors. In C# you have exactly the same thing. Imagine you have a method that returns a two element tuple. If you do this:
You'll get your tuple broken down automatically and variables
one
andtwo
declared for you.First of all, I'm using
.zip()
to pair the rows of the picture by two, that returns a tuple, so, I have to deconstruct that. That's what the outer parentheses are for. The pixel enumeration stuff I'm using returns a tuple(u32, u32, &Rgba<u8>)
first two values are x and y of the pixel, the third one is a reference to a structure with color data. I deconstruct those and just discard the position of the pixel, you do that with an underscore, same as C#.I'm not that far into learning myself, but I'm not a textbook learner at all. Poking around opensource projects and wrestling with the compiler prooved to educate me a lot more.
It's not so different in python:
for ((_, _, t), (_, _, b)) in zip(top, bottom):
Or in C#:
.ForEach(((_, _, t), (_, _, b)) => Console.Write(...));
Is
| (...) | { ... }
a lambda expression then?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?)
Or using sixels. For example foot supports them, and you can display one with chafa.