2022-11-09

toying with stable diffusion

Inspired by this blog covering a stable diffusion -> pixel art process:

https://pixelparmesan.com/ai-and-the-future-of-pixel-art/

I'm generating some concept art with #StableDiffusion for a leaf-catching runner game this morning via lexica.art:

https://lexica.art/prompt/f972bb05-409f-4c3f-9c0b-c94a8e1d3577

this is cray! At the very least, it's inspiration, layouts, and tree/leaf shapes to borrow from.

> TODO add some images

babashka -e for converting images with imagemagick

I normally go straight into a bb.edn or tasks.clj to write some clojure (b/c it's all about that repl ), but today I wanted to convert a bunch of `.webp`s from a quick stable diffusion session into .pngs.

Traditionally this is where the linux sys admin will bust out some piping, probably something with ls, awk, and a few other bits of whatever bash expects a computer user to know.

Instead, I reached for babashka:

bb -e '(->> (babashka.fs/list-dir ".") (filter #(clojure.string/includes? (str %) ".webp")) (map (fn [f] (-> ^{:out :string} (babashka.process/$ convert ~(str f) ~(clojure.string/replace f ".webp" ".png")) babashka.process/check :out))))' # convert images in this dir with imagemagick

> Note the trailing comment above, it's one of my favorite tricks for making searching history easier (because you can then search for your comment, not just the command itself).

The clojure in there, broken out a bit better:

(->> ;; thread-last
  (babashka.fs/list-dir ".") ;; ls
  (filter #(clojure.string/includes? (str %) ".webp")) ;; only this extension (there's a bb.fs way to do this as well)
  (map (fn [f] ;; for each file
    (->
      ;; run a process - metadata to specify we want string output
      ^{:out :string}
      (babashka.process/$ ;; this is a macro that lets your write like you're in a shell
        ;; here we use imagemagick's convert helper
        convert ~(str f) ~(clojure.string/replace f ".webp" ".png"))
      babashka.process/check ;; check awaits the process and throws if there's an error
      :out)))) ;; we only care for the process's output here

This is probably common enough to write some sort of helper function or a wrapper. I also admit I couldn't have smashed this out on the command line without being intimate with clojure's threading macros, babashka.fs and babashka.process.

But... imagine a world... in which you are familiar with those things, because they can be used in any of clojure's targetted runtimes! Bada bow! Now your life is easier, and you didn't spend 30 minutes dealing with bash trivia! Hooray!

beehave - same name idea as i had re: dino beehive!

maybe worth toying with

https://github.com/bitbrain/braingdx

java aka clojure game dev

godot comes with parallax bgs/layers built in! wut!

and a great, quick tutorial for them: https://www.youtube.com/watch?v=f8z4x6R7OSM

idea: add mastodon and twitch api support to org-blog

basically we're writing ->hiccup for various api endpoints

https://mastodon.gamedev.place/api/v1/timelines/public when i found this i thought, am I about to accidentally ddos them?

this hiccupping out of control idea is excellent

I feel like i am probably stealing this from somewhere

leaf runner game mechanic idea: sneak through the room

org-blog idea: ui is a pretty-printed (nicely colored) clojure datastructure

{:if-it-was-so-easy "I'd write the whole blog in here"
:post [
"Org Source blocks aren't too bad."
"And I think i'd be able to interact with this in a browser."
"Could be keyboard controlled anyway."
"At which point, we might as well be in Emacs."]}

These would make for really nice difftastic views tho.

patron updates idea: create a custom org->hiccup impl for the blog

keep the patreon usage minimal, include all the same content on the blog post and just link to it.

then, at publish time, just wing it and keep it to some fixed 100 word limit.

in fact, if they could all be hundos, that'd be just grand

org-blog: todos by tag-count, todos per project, todos by priority? (matching any project)

idea: silent streaming

i'll do the interactions during the stream, and make it more of a read-along

then the edited versions can speed up the in-betweens

we need a links-by-tag feature for every note

basically wrapping the tags page's component and passing in the items

org-blog: write override pages for specific types

e.g. projects get a custom 'project' page really just wraps the note page.

it's just hiccup! (->> [] (into [:div {}]))