All I wanted to do was to compute two or three color steps between two colors 
to fade from one to the other. Usually I would this with available compositing 
methods but in the current case it's easier to do maths and just redraw with 
the new color. The usual method to calculate the color steps is the linear one 
(http://stackoverflow.com/questions/27532/generating-gradients-programmatically).
 Wouldn't it be nice to define new methods for the usual arithmetic operation 
generics '(+ - * / < > = abs) to do color arithmetic?

Example:

(define color-1 (make-color r1 g1 b1))
(define color-2 (make-color r2 g2 b2))

(define color-delta (/ (- color-2 color-1) number-of-steps))
(let loop ((color color-1))
  (cons color [if (= color color-2) '() (loop (+ color color-delta))] ))

NB It's not the best example out there: delta should be computed like any other 
delta as the absolute numerical distance
 where the return value of the subtraction might be a negative color-distance% 
object but colors usually are only
 positive. Perhaps it's better to do without bigger than and less than when it 
comes to colors.

Before I go ahead and just do it I wanted to ask:

1) Does such a thing exist somewhere for Scheme or Racket (I couldn't find 
anything)
     The only example I found was: 
https://www.wolframalpha.com/examples/ColorArithmetic.html

2) Does anyone know how this proposed color arithmetic would interact with 
color management / color spaces?
2a) Is it true that non-linear color arithmetic produces better results for 
gradients?

3) Any suggestions regarding the implementation of the generics?

4) Both Cairo and Quartz do have more sophisticated compositing methods - but 
they do not expose this low level functionality?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to