Animation in ClojureScript

Hi all,

I would like to do some simple animating (mostly text animation) in ClojureScript. I am essentially a Javascript and web programming newbie, so the proposed solution doesn’t have to conform to any particular paradigm. However, since I will be playing around a lot, I would very much like to be able to livecode. So far I have tried quil with the lein template for figwheel-main (with Reagent) and that almost worked: the page livecodes fine, but the canvas that quil draws disappears when I update it and I have to reload the page. Since I am not sure that this approach even makes sense, I thought I would try to find out what solution I should be using, before sinking a bunch of time into debugging.

Thank you,
Matt

how does your effort differ from this example ?

I think you need to have the canvas component be long-lived more-or-less, and all of your live coding pieces are happening in functions that the canvas is using for draw/update state etc.

As an aside, you can use regular SVG from react and animate their properties with ratoms. You can also probably accomplish a lot with CSS animations (yet another web tech to learn :frowning: , but it can be worthwhile). SVG Sample is an example.

1 Like

The quil documentation advises the use of the q/defsketch macro instead of q/sketch, but it also doesn’t include Reagent so perhaps I shouldn’t have dismissed q/sketch so readily. Looking at this, it makes sense that the canvas should be controlled within a component instead of floating alongside it. Thank you, I will give something like this a try (and maybe update the documentation while I’m at it). This approach would also help me to better understand Reagent, I think.

Thanks also for the SVG suggestion, I have looked at it a little but not very seriously. Something relatively lightweight that doesn’t require too much stuff to interact with other stuff is always appealing. :slight_smile:

Regards,
Matt

I have also been using threeagent recently; although that’s perhaps a much taller order :slight_smile:

1 Like

I mean…I don’t really know much of anything, might as well learn this? Looks a little bit like animation in Racket, could make sense. Thanks :slight_smile:

After making games for 2 years I found graphical live coding painful in Clojure/Script, so I ended up making Freja - an editor specifically designed for playing around with graphics. Write some draw-text and rl-scalef calls, hit Ctrl+L and see it fly. :slight_smile:

Check it out: Making breakout in 1 hour! - YouTube

4 Likes

Wow, this is very cool! I hadn’t heard of Janet either, thanks for the reference :slight_smile:

1 Like

It’s a new language but been using it for a year and it generally works well. Currently employed 50% making games in Freja.

I wouldn’t recommend Janet for corporate stuff, since Clojure has a lot going for it in that space. But if you want to live code graphics I’ve found Janet to be great!

Feel free to PM me if you have any questions. :slight_smile:

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.