diff options
Diffstat (limited to 'graphics.c')
| -rw-r--r-- | graphics.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -19,8 +19,6 @@ #include "RGBImage.h" #include <stdlib.h> -# define M_PI 3.14159265358979323846 /* pi */ - int main() { u32 width = 512; @@ -28,17 +26,20 @@ main() { const u32 FPS = 60; u32 frames = FPS * 5; + PixelCallback* child; TransformCenter childLeft = { .centerX = width / 4, .centerY = height * 3 / 4, }; TransformCenter childRight = { .centerX = width * 3 / 4, .centerY = height * 3 / 4, }; + + PixelCallback* segment; LineSegment segmentRight = { .aX = width / 2, .aY = height / 4, .bX = width * 3 / 4, .bY = height * 3 / 4, - .width = 10, .color = 0xFFFF00FF, + .width = 20, .color = 0xFFFF00FF, }; LineSegment segmentLeft = { .aX = width / 2, .aY = height / 4, .bX = width / 4, .bY = height * 3 / 4, - .width = 10, .color = 0xFFFF00FF, + .width = 20, .color = 0xFF0088FF, }; PixelCallback* callbacks[] = { @@ -46,6 +47,9 @@ main() { Square_setup((Square){ .size = width, .color = 0xFFF0F0F0, }), + /* Connecting line */ + NULL, + segment = LineSegment_setup(segmentRight), /* Root node */ TransformCenter_setup((TransformCenter){ .centerX = width / 2, .centerY = height / 4, @@ -55,48 +59,44 @@ main() { }), /* Child node */ NULL, - TransformCenter_setup(childRight), + child = TransformCenter_setup(childRight), Circle_setup((Circle){ .radius = 60, .color = 0xFF00FF00, }), - /* Connecting line */ - NULL, - LineSegment_setup((LineSegment){ - .aX = width / 2, .aY = height / 4, - .bX = width * 3 / 4, .bY = height * 3 / 4, - .width = 10, .color = 0xFFFF00FF, - }), }; u32 sizeCallbacks = sizeof(callbacks) / sizeof(*callbacks); FrameCallback* frameCallbacks[] = { + /* Move right to left */ FrameRange_setup((FrameRange){ .startFrame = frames / 3 - FPS, .endFrame = frames / 3, }), Interpolate_setup((Interpolate){ .startValue = &childRight, .endValue = &childLeft, - .value = callbacks[4]->callback_self, + .value = child->callback_self, .interpolate = (f_interpolate)Interpolate_TransformCenter, }), Interpolate_setup((Interpolate){ .startValue = &segmentRight, .endValue = &segmentLeft, - .value = callbacks[7]->callback_self, + .value = segment->callback_self, .interpolate = (f_interpolate)Interpolate_LineSegment, }), + /* Move left to right */ NULL, FrameRange_setup((FrameRange){ .startFrame = frames * 2 / 3 - FPS, .endFrame = frames * 2 / 3, }), Interpolate_setup((Interpolate){ .startValue = &childLeft, .endValue = &childRight, - .value = callbacks[4]->callback_self, + .value = child->callback_self, .interpolate = (f_interpolate)Interpolate_TransformCenter, }), Interpolate_setup((Interpolate){ .startValue = &segmentLeft, .endValue = &segmentRight, - .value = callbacks[7]->callback_self, + .value = segment->callback_self, .interpolate = (f_interpolate)Interpolate_LineSegment, }), + /* Render */ NULL, Draw_setup((Draw){ .callbacks = (const PixelCallback**)callbacks, .sizeCallbacks = sizeCallbacks, |
