shapes_basic_shapes.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. -------------------------------------------------------------------------------------------
  2. --
  3. -- raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...)
  4. --
  5. -- This example has been created using raylib 1.6 (www.raylib.com)
  6. -- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. --
  8. -- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
  9. --
  10. -------------------------------------------------------------------------------------------
  11. -- Initialization
  12. -------------------------------------------------------------------------------------------
  13. local screenWidth = 800
  14. local screenHeight = 450
  15. InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing")
  16. SetTargetFPS(60) -- Set target frames-per-second
  17. -------------------------------------------------------------------------------------------
  18. -- Main game loop
  19. while not WindowShouldClose() do -- Detect window close button or ESC key
  20. -- Update
  21. ---------------------------------------------------------------------------------------
  22. -- TODO: Update your variables here
  23. ---------------------------------------------------------------------------------------
  24. -- Draw
  25. ---------------------------------------------------------------------------------------
  26. BeginDrawing()
  27. ClearBackground(RAYWHITE)
  28. DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY)
  29. DrawLine(18, 42, screenWidth - 18, 42, BLACK)
  30. DrawCircle(screenWidth/4, 120, 35, DARKBLUE)
  31. DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE)
  32. DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE)
  33. DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED)
  34. DrawRectangleGradient(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD)
  35. DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE)
  36. DrawTriangle(Vector2(screenWidth/4*3, 80),
  37. Vector2(screenWidth/4*3 - 60, 150),
  38. Vector2(screenWidth/4*3 + 60, 150), VIOLET)
  39. DrawTriangleLines(Vector2(screenWidth/4*3, 160),
  40. Vector2(screenWidth/4*3 - 20, 230),
  41. Vector2(screenWidth/4*3 + 20, 230), DARKBLUE)
  42. DrawPoly(Vector2(screenWidth/4*3, 320), 6, 80, 0, BROWN)
  43. EndDrawing()
  44. ---------------------------------------------------------------------------------------
  45. end
  46. -- De-Initialization
  47. -------------------------------------------------------------------------------------------
  48. CloseWindow() -- Close window and OpenGL context
  49. -------------------------------------------------------------------------------------------