diff options
Diffstat (limited to 'examples/rects.h')
-rw-r--r-- | examples/rects.h | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/examples/rects.h b/examples/rects.h index 3537a5b..b99d9f0 100644 --- a/examples/rects.h +++ b/examples/rects.h @@ -23,16 +23,16 @@ typedef float vec2[2]; typedef struct { - float pos[2]; - float size[2]; - float fillColor[4]; + float pos[2]; + float size[2]; + float fillColor[4]; } Rect; static const vec2 rectVertices[] = { - {0.0f, 0.0f}, // TL - {1.0f, 0.0f}, // TR - {0.0f, 1.0f}, // BL - {1.0f, 1.0f} // BR + {0.0f, 0.0f}, // TL + {1.0f, 0.0f}, // TR + {0.0f, 1.0f}, // BL + {1.0f, 1.0f} // BR }; static const unsigned rectIndices[4] = {0, 1, 2, 3}; @@ -41,19 +41,19 @@ static const unsigned rectIndices[4] = {0, 1, 2, 3}; static inline Rect makeRect(const size_t index, const float frameWidth) { - static const float alpha = 0.3f; - const float minSize = frameWidth / 64.0f; - const float maxSize = frameWidth / 6.0f; - const float s = (sinf((float)index) / 2.0f + 0.5f); - const float c = (cosf((float)index) / 2.0f + 0.5f); + static const float alpha = 0.3f; + const float minSize = frameWidth / 64.0f; + const float maxSize = frameWidth / 6.0f; + const float s = (sinf((float)index) / 2.0f + 0.5f); + const float c = (cosf((float)index) / 2.0f + 0.5f); - const Rect rect = { - {0.0f, 0.0f}, // Position is set later during expose - {minSize + s * maxSize, minSize + c * maxSize}, - {0.0f, s / 2.0f + 0.25f, c / 2.0f + 0.25f, alpha}, - }; + const Rect rect = { + {0.0f, 0.0f}, // Position is set later during expose + {minSize + s * maxSize, minSize + c * maxSize}, + {0.0f, s / 2.0f + 0.25f, c / 2.0f + 0.25f, alpha}, + }; - return rect; + return rect; } /// Move `rect` with the given index around in an arbitrary way that looks cool @@ -65,15 +65,15 @@ moveRect(Rect* const rect, const float frameHeight, const double time) { - const float normal = (float)index / (float)numRects; - const float offset[2] = {normal * 128.0f, normal * 128.0f}; + const float normal = (float)index / (float)numRects; + const float offset[2] = {normal * 128.0f, normal * 128.0f}; - rect->pos[0] = (frameWidth - rect->size[0] + offset[0]) * - (sinf((float)time * rect->size[0] / 64.0f + normal) + 1.0f) / - 2.0f; - rect->pos[1] = (frameHeight - rect->size[1] + offset[1]) * - (cosf((float)time * rect->size[1] / 64.0f + normal) + 1.0f) / - 2.0f; + rect->pos[0] = (frameWidth - rect->size[0] + offset[0]) * + (sinf((float)time * rect->size[0] / 64.0f + normal) + 1.0f) / + 2.0f; + rect->pos[1] = (frameHeight - rect->size[1] + offset[1]) * + (cosf((float)time * rect->size[1] / 64.0f + normal) + 1.0f) / + 2.0f; } #endif // EXAMPLES_RECTS_H |