mualice
mualice
mualice
8 posts
A developer for twoleaflotus. Working on random stuff currently.
Don't wanna be here? Send us removal request.
mualice · 10 months ago
Text
Cute!
Tumblr media
OG double ears
590 notes · View notes
mualice · 1 year ago
Text
Projects are one of the best ways you can learn programming in depth.
People stuck in tutorial hell can get out of it if they do projects. However, they must never follow a step by step guide on how to do the project. They must traverse the fog of confusion and the mountain of information to get a deeper understanding of what they're working on. By then, they have climbed out of the hole they dug themselves into.
1 note · View note
mualice · 1 year ago
Text
GIF modification with Golang
I'm trying to modify a GIF and draw funny little stuff on it. How nice~ It's a relatively simple project.
All I need to do is to stitch some images together and push them into a GIF struct. It's very simple~ I even did some basic multi-threading on it.
Tumblr media
It's pretty right?
Then, when I profiled them, I noticed encoding them is hellishly slow. It takes 50 seconds to conceive four GIFs with 30 frames in them (when single-threaded, 6 seconds when multi-threaded). I'm going to be using this in a Discord bot where it'll be spammed to shreds!
This performance can't be right..
So, I dug deep into the code using go tool pprof and found these.
Tumblr media Tumblr media
These functions are taking up all of my time. This profile finished encoding at 55 seconds btw.
Edit: I am writing this from my bed.
Anyways, after analyzing it a bit, it looks like its trying to get the distance between two colors, the palette color and the image pixel's color using this formula (to make the image fit into a specific palette, it uses the distance to tell)
Tumblr media
For more information:
The article explains that this method is horribly inefficient. For an image of size 1920x768, you would have to compute it 1920*768*10 (10 is the palette size) = 14,745,600 times!
It explains why it spends so much time there. They even admit it too.
Tumblr media
So, guess I need to make my own draw function!
1 note · View note
mualice · 1 year ago
Text
Figuring out how to get the average color of an image...
I could just loop through the image and average out the RGB values like this:
Tumblr media
But it'll iterate through every single pixel. It will struggle with 500x200 images (100,000 pixels). Another solution is to select 50 random pixels from the image and get the average of that, but I don't know how accurate that will be.
So, stuck with a problem I am incapable of solving by myself... I searched for a path that other people that have traversed before.
Turns out, if you get the average color of an image, it turns into the color of vomit.
From that information, my goal changed from getting the average to getting the most dominant color.
I could do this using a histogram to count every color, but it only works when there are a few colors (less than 50) to avoid inaccurate results.
What I could do is somehow flatten the entire image into base colors. A palette of some sorts.
...
PalettedImage.
I do have the palette!
Tumblr media
All I need to do is count the pixels that are similar to it and see what the dominant color is.
But how can I define "similar colors"?
Update soon-ish.
(This problem might be related to nearest-neighbor search)
6 notes · View notes
mualice · 1 year ago
Text
My stomach feels so painful rn. Its crazy how much it hurts. Was it because I ate something expired..? Something I left in the open for too long??
0 notes
mualice · 1 year ago
Text
Building a calculator is hard.
I'm not talking about the very simple if-else statements that people getting into programming do...
I'm making a Recursive Descent Parser for this!
Tumblr media
I'm currently doing the scanner to convert them into tokens. I love infinite loops. >_>
0 notes
mualice · 1 year ago
Text
Godot's only flaw is its code editor (and in some ways, GDScript).
Why is there no way to check what type a variable is? I get that we can do `var name: type = value`, however we sometimes need to infer the type from its usage throughout the code. I find that the code editor doesn't show me that in a readable way...
I encounter so many eccentricities of the code editor that I find myself wanting to go back to neovim. ;-;
9 notes · View notes
mualice · 1 year ago
Text
Tumblr media
A basic form website for a friend of mine~ I should really work on the redstone calculator..
Tumblr media
I'm halfway done with this project.
All I need to do is model the data, do the view design and put the modeled data on pocketbase and connect pocketbase and host both db and site in the internet.
... There's still a lot to do.
1 note · View note