Your program must take as input a line of characters, like this:
@+.0
And output the characters sorted by how dark they are, like this:
.+0@
Requirements:
You must use a monospaced font for darkness detection.
You must find out how many pixels each character takes up. You must actually draw the character and count pixels, i.e. you can't just hardcode pixel amounts.
- As a more concrete rule: if you switched fonts, your program should still work. Furthermore, your program should be able to switch fonts by simply changing a variable or value or string in the code.
If you use antialiasing, you must count pixels as percentages of a fully black pixel. For example, an
rgb(32, 32, 32)
pixel will count as 1/8 of a full pixel. Disregard this rule if your characters are not antialiased.After counting pixels, you must sort the characters by the amount of pixels, and output them in order.
This is code-golf, so the shortest code in bytes will win.