diff options
Diffstat (limited to 'src/blender')
-rw-r--r-- | src/blender/blender.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/blender/blender.c b/src/blender/blender.c index 738811d..99abedd 100644 --- a/src/blender/blender.c +++ b/src/blender/blender.c | |||
@@ -3,12 +3,12 @@ | |||
3 | #include <math.h> | 3 | #include <math.h> |
4 | #include "morpher/morpher.h" | 4 | #include "morpher/morpher.h" |
5 | 5 | ||
6 | static ColorComponent blend_components(ColorComponent origin, ColorComponent target, TimeVector frame) { | 6 | static inline ColorComponent blend_components(ColorComponent origin, ColorComponent target, TimeVector frame) { |
7 | // https://www.youtube.com/watch?v=LKnqECcg6Gw | ||
7 | return (ColorComponent) sqrt((TIME_UNIT - frame) * pow(origin, 2) + frame * pow(target, 2)); | 8 | return (ColorComponent) sqrt((TIME_UNIT - frame) * pow(origin, 2) + frame * pow(target, 2)); |
8 | } | 9 | } |
9 | 10 | ||
10 | Color blender_blend_colors(Color origin, Color target, TimeVector frame) { | 11 | static inline Color blend_colors(Color origin, Color target, TimeVector frame) { |
11 | assert(frame >= TIME_ORIGIN && frame <= TIME_UNIT); | ||
12 | return (Color) {{blend_components(origin.rgba.r, target.rgba.r, frame), | 12 | return (Color) {{blend_components(origin.rgba.r, target.rgba.r, frame), |
13 | blend_components(origin.rgba.g, target.rgba.g, frame), | 13 | blend_components(origin.rgba.g, target.rgba.g, frame), |
14 | blend_components(origin.rgba.b, target.rgba.b, frame), | 14 | blend_components(origin.rgba.b, target.rgba.b, frame), |
@@ -34,11 +34,7 @@ void blender_blend_canvas(Canvas *canvas, Canvas *source, Canvas *target, Morphi | |||
34 | point.y = flat_dim / dim.y; | 34 | point.y = flat_dim / dim.y; |
35 | 35 | ||
36 | mapping = morpher_get_point_mapping(morphing, point, frame); | 36 | mapping = morpher_get_point_mapping(morphing, point, frame); |
37 | 37 | pixel = blend_colors(canvas_get_pixel(source, mapping.origin), canvas_get_pixel(target, mapping.target), frame); | |
38 | pixel = blender_blend_colors(canvas_get_pixel(source, mapping.origin), | ||
39 | canvas_get_pixel(target, mapping.target), | ||
40 | frame); | ||
41 | |||
42 | canvas_set_pixel(canvas, point, pixel); | 38 | canvas_set_pixel(canvas, point, pixel); |
43 | } | 39 | } |
44 | } | 40 | } |