conventions

This commit is contained in:
RobinsAviary 2025-10-18 15:51:22 -04:00
parent 2ebec24664
commit 6ce48d01f5

View File

@ -58,12 +58,14 @@ int main(void)
{ {
// Update // Update
// Disable the hint text once the user clicks // Disable the hint text once the user clicks
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && startText) { if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && startText)
{
startText = false; startText = false;
} }
// Clear the canvas when the user middle-clicks // Clear the canvas when the user middle-clicks
if (IsMouseButtonPressed(MOUSE_BUTTON_MIDDLE)) { if (IsMouseButtonPressed(MOUSE_BUTTON_MIDDLE))
{
BeginTextureMode(canvas); BeginTextureMode(canvas);
ClearBackground(backgroundColor); ClearBackground(backgroundColor);
EndTextureMode(); EndTextureMode();
@ -79,7 +81,7 @@ int main(void)
if (leftButtonDown) { if (leftButtonDown) {
// Increase the hue value by the distance our cursor has moved since the last frame (divided by 3) // Increase the hue value by the distance our cursor has moved since the last frame (divided by 3)
lineHue += Vector2Distance(mousePositionPrevious, GetMousePosition()) / 3.0f; lineHue += Vector2Distance(mousePositionPrevious, GetMousePosition())/3.0f;
// While the hue is >=360, subtract it to bring it down into the range 0-360 // While the hue is >=360, subtract it to bring it down into the range 0-360
// This is more visually accurate than resetting to zero // This is more visually accurate than resetting to zero
@ -98,8 +100,8 @@ int main(void)
// Draw the line onto the canvas // Draw the line onto the canvas
BeginTextureMode(canvas); BeginTextureMode(canvas);
// Circles act as "caps", smoothing corners // Circles act as "caps", smoothing corners
DrawCircleV(mousePositionPrevious, lineThickness / 2.0f, drawColor); DrawCircleV(mousePositionPrevious, lineThickness/2.0f, drawColor);
DrawCircleV(GetMousePosition(), lineThickness / 2.0f, drawColor); DrawCircleV(GetMousePosition(), lineThickness/2.0f, drawColor);
DrawLineEx(mousePositionPrevious, GetMousePosition(), lineThickness, drawColor); DrawLineEx(mousePositionPrevious, GetMousePosition(), lineThickness, drawColor);
EndTextureMode(); EndTextureMode();
} }
@ -115,10 +117,10 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
// Draw the render texture to the screen, flipped vertically to make it appear top-side up // Draw the render texture to the screen, flipped vertically to make it appear top-side up
DrawTextureRec(canvas.texture, (Rectangle){0.0f, 0.0f, (float)canvas.texture.width,(float)-canvas.texture.height}, (Vector2){0, 0}, WHITE); DrawTextureRec(canvas.texture, (Rectangle){ 0.0f, 0.0f, (float)canvas.texture.width,(float)-canvas.texture.height }, Vector2Zero(), WHITE);
// Draw the preview circle // Draw the preview circle
if (!leftButtonDown) DrawCircleLinesV(GetMousePosition(), lineThickness / 2.0f, (Color){127, 127, 127, 127}); if (!leftButtonDown) DrawCircleLinesV(GetMousePosition(), lineThickness/2.0f, (Color){ 127, 127, 127, 127 });
// Draw the hint text // Draw the hint text
if (startText) DrawText("try clicking and dragging!", 275, 215, 20, LIGHTGRAY); if (startText) DrawText("try clicking and dragging!", 275, 215, 20, LIGHTGRAY);