[ANN] Bardo v0.1.0 - A clojure(script) library to assist with transitions between dimensions

197 views
Skip to first unread message

Dylan Butman

unread,
Dec 13, 2014, 8:16:11 PM12/13/14
to clo...@googlegroups.com, clojur...@googlegroups.com
TL:DR 

Bardo https://github.com/pleasetrythisathome/bardo is a clojure(script) library that provides semantics for defining interpolators between data structures as well as utilities for composing them with each other, easing curves, and other transformations. It can be extended through clojure protocols to define other interopolateable types. 

This is great for animations, but can be useful in a variety of contexts where state is not binary.
I come from a design and graphics background and got into programming initially writing particle systems and music visualizers. When I started doing web development and interactive work, transitions and animation we’re always an interest. I was deeply unsatisfied with the current state of black box Jquery animation, where one must be content with pressing play, and then watching the side effects flow. 

When I first started using React around the time it came out, and I was thrilled by the declarative nature. I realized that by instead of animation dom properties, if you transition component state, then suddenly you have the opportunity to insert arbitrary control flow into running animations. I wrote https://github.com/pleasetrythisathome/react.animate based on d3 interpolators. This library is a big step forward, based on an entirely functional approach and greatly aided clojure’s expressiveness. 

I’ve been using some version of this code in production projects for a while. That said, this is definitely still alpha software. Thoughts, issues, pull request, etc. are very welcome. I hope someone finds it useful!

David Nolen

unread,
Dec 13, 2014, 8:30:03 PM12/13/14
to clojur...@googlegroups.com, clojure
Excellent! :)
> --
> Note that posts from new members are moderated - please be patient with your
> first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojurescrip...@googlegroups.com.
> To post to this group, send email to clojur...@googlegroups.com.
> Visit this group at http://groups.google.com/group/clojurescript.

pand...@gmail.com

unread,
Dec 14, 2014, 9:08:45 AM12/14/14
to clojur...@googlegroups.com
This is really cool. I'd been bringing in D3 just to use scales and other math; I think bardo obviates that, which is great from a payload standpoint.

Slightly off-topic, sorry, but what's the story with all the tests being commented out, just out of curiosity?

Dylan Butman

unread,
Dec 14, 2014, 11:03:37 AM12/14/14
to clojur...@googlegroups.com
I was mostly doing repl testing. I had a few tests but when you're trying to test composition of a number of transformation functions it becomes pretty impossible to write well formed tests. Next on my list is adding some more robust tests using https://github.com/cemerick/double-check

pand...@gmail.com

unread,
Dec 14, 2014, 12:45:49 PM12/14/14
to clojur...@googlegroups.com
Yeah I can imagine it isn't easy to test that stuff well. (So it wasn't directly cljx/cljs related, which was my interest.)

Thanks for the report.

Daniel Kersten

unread,
Dec 14, 2014, 2:50:28 PM12/14/14
to clojur...@googlegroups.com
This is great! Thanks for sharing. Looks really flexible. I'm looking forward to replacing my own sightly buggy easing functions with this. :)

On Sun, 14 Dec 2014 17:47 null <pand...@gmail.com> wrote:
Yeah I can imagine it isn't easy to test that stuff well. (So it wasn't directly cljx/cljs related, which was my interest.)

Thanks for the report.

--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescript+unsubscribe@googlegroups.com.

Dylan Butman

unread,
Dec 15, 2014, 9:53:25 AM12/15/14
to clojur...@googlegroups.com
Let me know how it goes for you and if there are use cases it doesn't cover or directions you'd like to see explored. I'm hoping to have some time to write a few more composition examples this week


You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/JROUw58NPX0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.

Aaron Craelius

unread,
Dec 17, 2014, 10:30:11 PM12/17/14
to clojur...@googlegroups.com
Looks good... I've updated freactive's README to reference bardo's easing functions.

I want to make sure people can use bardo's interpolators as well with some overload of freactive's start-easing!. I'm wondering how (or if) to handle the case where an animation in progress is interrupted and then sent in a different direction (which freactive currently has some basic naive support for). I don't know if you might have any thoughts on how best to deal with this case in general and/or how it might or might not be possible to do with bardo's interpolators? For an example of what I'm talking about you can see in freactive's little demo that it's possible to interrupt the animation in progress and it guesses (linearly) about the correct speed.

Dylan Butman

unread,
Dec 18, 2014, 11:03:27 AM12/18/14
to clojur...@googlegroups.com
Hey Aaron,

Bardo interpolators are meant to be able to handle the transition case that you’re talking about, although the semantics for doing so are still relatively low level and thus not the easiest thing to understand. 

The om example in the repo does exactly what you’re talking about. https://github.com/pleasetrythisathome/bardo/blob/master/examples/om.cljs#L34

Essentially,mMixes between interpolators that represent overlapping time domains can be mixed by shifting the domains of the interpolators. Here’s a more step by step explanation.

(def a 0)
(def b 10)
(def intrpl (interpolate a b))
(map intrpl [0 0.5 1])
;; => (0 5.0 10)
;; => (fn [t]) : t [0 -> 1] : a -> b

;; interrupt at dt and interpolate to c
(def dt 0.6)
(def c 50)
(def dintrpl (interpolate (intrpl dt) c))
(map dintrpl [0 0.5 1])
;; => (6.0 28.0 50.0)
;; (fn [t]) : t [0 -> 1] : (intrpl dt) -> c

;; to mix, we need to shift the domain of the input to intrpl
(def sintrpl (ease/shift intrpl 0 (- 1 dt) dt 1))
(map sintrpl [0 (- 1 dt) 1])
;; => (6.0 10.0 16.0)
;; we get a higher output at 1 because we've extended the domain
;; (fn [t]) ; t [0 -> (- 1 dt)] : (intrpl dt) -> b
(-> identity
    (ease/shift 0 (- 1 dt) dt 1)
    (map [0 (- 1 dt) 1]))
;; => (0.6 1.0 1.6)

(def mixed (mix sintrpl dintrpl))
(map mixed [0 0.25 0.5 0.75 1])
;; => (6.0 10.625 19.5 32.625 50.0)

Does that make sense?

I added this to the readme, but a more thorough blog post exploring more of the possibilities here is probably in order. 

I’m still exploring the interaction points myself. I plan on writing some more composition helper functions that help simplify these operations.

On Dec 17, 2014, at 10:30 PM, Aaron Craelius <aaronc...@gmail.com> wrote:

Looks good... I've updated freactive's README to reference bardo's easing functions.

I want to make sure people can use bardo's interpolators as well with some overload of freactive's start-easing!. I'm wondering how (or if) to handle the case where an animation in progress is interrupted and then sent in a different direction (which freactive currently has some basic naive support for). I don't know if you might have any thoughts on how best to deal with this case in general and/or how it might or might not be possible to do with bardo's interpolators? For an example of what I'm talking about you can see in freactive's little demo that it's possible to interrupt the animation in progress and it guesses (linearly) about the correct speed.

Reply all
Reply to author
Forward
0 new messages