| 3079 | } |
| 3080 | |
| 3081 | function colorize(img, color, bias) { |
| 3082 | /* Returns a colorized image. |
| 3083 | * - color: a Color (or array) of RGBA-values to multiply with each image pixel. |
| 3084 | * - bias : a Color (or array) of RGBA-values to add to each image pixel. |
| 3085 | */ |
| 3086 | var m1 = new Color(color || [1,1,1,1]).rgba(); |
| 3087 | var m2 = new Color(bias || [0,0,0,0]).map({base: 255}); |
| 3088 | return filter(img, function(p) { |
| 3089 | return [ |
| 3090 | p[0] * m1[0] + m2[0], |
| 3091 | p[1] * m1[1] + m2[1], |
| 3092 | p[2] * m1[2] + m2[2], |
| 3093 | p[3] * m1[3] + m2[3] |
| 3094 | ]; |
| 3095 | }); |
| 3096 | } |
| 3097 | |
| 3098 | // function adjust(img, {hue:0, saturation:1.0, brightness:1.0, contrast:1.0}) |
| 3099 | function adjust(img, options) { |