summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-07-17 23:31:07 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2024-07-17 23:31:07 -0400
commit1fd83f1656b0e16366c0cbaa98e5fc802238f022 (patch)
tree528af35d242146bc9928cd9387daa349a081cd98
parent3d6f05e213247faf41cdebec01016cd99e7ededd (diff)
LESS LINES OF CODEEEEHEADmaster
-rw-r--r--README.org6
-rw-r--r--main.go9
2 files changed, 6 insertions, 9 deletions
diff --git a/README.org b/README.org
index d712eb0..0cf1b28 100644
--- a/README.org
+++ b/README.org
@@ -29,11 +29,11 @@
Well, the idea to do this came to me as I was browsing the vim subreddit
(as one does) and saw [[https://www.reddit.com/r/vim/comments/1e5o998/if_were_sharing_vim_pixel_art][this post]] by ~u/fapperruning~ where he drew
the vim logo with pixel art. The size was small enough it could nicely fit
- in a terminal window, though big enough it waas no feasible to draw by hand.
+ in a terminal window, though big enough it was not feasible to draw by hand.
- So using this as a starting point, I searched for a way to firstly parse the image
+ So using this as a starting point, I searched for a way to parse the image
and found [[https://www.piskelapp.com/p/create/sprite][Piskel]]. The amazing thing about Piskel is that it allows you to export
- a sprite as a big integer array written in C. The first thing I did was to
+ a sprite as a big integer array written in a C file. The first thing I did was to
downscale ~u/fapperruning~'s image so that 1 pixel = 1 square in the sprite.
I the slightly modified Piskel's C file output so that it corresponds to a Go slice
of 32-bit unsigned integers.
diff --git a/main.go b/main.go
index 9e8b22b..68939db 100644
--- a/main.go
+++ b/main.go
@@ -54,11 +54,9 @@ func mkPixelStack(top, bot pixel) string {
case noTop && noBot:
return " "
case noTop:
- return fmt.Sprintf(botFmt+postFmt,
- bot.r, bot.g, bot.b)
+ return fmt.Sprintf(botFmt+postFmt, bot.r, bot.g, bot.b)
case noBot:
- return fmt.Sprintf(topFmt+postFmt,
- top.r, top.g, top.b)
+ return fmt.Sprintf(topFmt+postFmt, top.r, top.g, top.b)
default:
return fmt.Sprintf(topFmt+botFmt+postFmt,
top.r, top.g, top.b,
@@ -77,8 +75,7 @@ func (p pixelArt) draw(stream io.Writer) {
if p.height%2 != 0 {
for i := range top {
- top[i] = pixel{0, 0, 0}
- bot[i] = int2Pixel(p.pixels[0])
+ top[i], bot[i] = pixel{0, 0, 0}, int2Pixel(p.pixels[0])
}
drawRowStack(top, bot)
topIdx += step