-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[examples] Added shapes_math_sine_cosine
(#5209)
#5237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
shapes_math_sine_cosine
(#5209)
@oqu Thanks! It looks nice! Please, could you change the background to RAYWHITE, for consistency with most other examples? |
|
||
int main(void) | ||
{ | ||
// Window initialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that Init, Update, Draw sections should be defined by:
//--------------------------------------------------------------------------------------
following the template structure: https://github.com/raysan5/raylib/blob/master/examples/examples_template.c
const int screenHeight = 450; | ||
|
||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - math sine cosine"); | ||
const char* playText = "Play"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, review raylib code conventions: https://github.com/raysan5/raylib/blob/master/CONVENTIONS.md
|
||
// Animation / UI state | ||
bool playing = true; // play / pause toggle | ||
int frameCountLocal = 0; // local frame counter (used when playing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, review raylib code conventions: https://github.com/raysan5/raylib/blob/master/CONVENTIONS.md
Comments should start with capital letter
// Main loop | ||
while (!WindowShouldClose()) | ||
{ | ||
// Handle GUI and input first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, note that Update and Draw should be in separate sections.
DrawLine((int)(circleX - circleRadius), (int)circleY, (int)(circleX + circleRadius), (int)circleY, Fade(GRAY, 0.6f)); | ||
|
||
// Compute moving point on circle (cos for x, sin for y). Note: cos/sin in C expect radians | ||
float angRad = angleDeg * (PI / 180.0f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, review raylib code conventions: https://github.com/raysan5/raylib/blob/master/CONVENTIONS.md
*
and /
should not have spaces
shapes_math_sine_cosine
(#5209)shapes_math_sine_cosine
(#5209)
TL;DR #5209 is asking for more examples. This PR is for the example shapes_math_sine_cosine
Summary
Added a new example
shapes_math_sine_cosine.c
that demonstrates the relationshipbetween the unit circle and the sine / cosine functions. The example is a C port
of the p5.js "angles and motion: sine/cosine" demo and uses raylib for rendering
and raygui for a small control panel.
Key features:
Changelog
examples/shapes/shapes_math_sine_cosine.c
— NEW: main example sourceexamples/shapes/shapes_math_sine_cosine.png
— optional screenshot.Possible areas of improvement
Tests
Manually tested on macos by building raylib, then building the example.
Let me know if you need any changes