mikera / clisk

The Clojure Image Synthesis Kit
281 stars 13 forks source link

Gradient #6

Closed nodename closed 11 years ago

nodename commented 11 years ago

Hello Mike I am studying the library and through rough pattern-matching on existing code without much understanding I have come up with

(defn x-gradient
  ([a b]
    (clisk.functions/lerp (vfrac x) a b)))

which I have stuck into my copy of clisk.patterns.clj.

Could you please comment on whether this is at all correct (image looks a bit off) and what would be the right thing to do?

Thanks!

mikera commented 11 years ago

Hi, you need to use the vectorised version of lerp, called vlerp:

(defn x-gradient
   ([a b]
     (clisk.functions/vlerp  a b x)))

(show (x-gradient 0 1))

lerp itself is just a utility function that works on scalars

nodename commented 11 years ago

Thanks! ... I don't find vlerp in the source on github...

mikera commented 11 years ago

should be just below lerp in functions.clj

I need to document some of this stuff better :-)

mikera commented 11 years ago

Sorry I was looking at the wrong clisk version in git! Latest version should use lerp