mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-06 14:23:12 +00:00
Update shapes_lines_drawing.c
This commit is contained in:
parent
4caba49658
commit
9efe127f5d
@ -51,6 +51,8 @@ int main(void)
|
|||||||
BeginTextureMode(canvas);
|
BeginTextureMode(canvas);
|
||||||
ClearBackground(backgroundColor);
|
ClearBackground(backgroundColor);
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
@ -59,10 +61,7 @@ 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))
|
||||||
@ -79,7 +78,7 @@ int main(void)
|
|||||||
if (leftButtonDown || rightButtonDown)
|
if (leftButtonDown || rightButtonDown)
|
||||||
{
|
{
|
||||||
// The color for the line
|
// The color for the line
|
||||||
Color drawColor;
|
Color drawColor = WHITE;
|
||||||
|
|
||||||
if (leftButtonDown)
|
if (leftButtonDown)
|
||||||
{
|
{
|
||||||
@ -88,10 +87,7 @@ int main(void)
|
|||||||
|
|
||||||
// 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
|
||||||
while (lineHue >= 360.0f)
|
while (lineHue >= 360.0f) lineHue -= 360.0f;
|
||||||
{
|
|
||||||
lineHue -= 360.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the final color
|
// Create the final color
|
||||||
drawColor = ColorFromHSV(lineHue, 1.0f, 1.0f);
|
drawColor = ColorFromHSV(lineHue, 1.0f, 1.0f);
|
||||||
@ -104,10 +100,12 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user