shapes_draw_circle_sector.bmx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. SuperStrict
  2. Framework Ray.GUI
  3. ' Initialization
  4. '--------------------------------------------------------------------------------------
  5. Const screenWidth:Int = 800
  6. Const screenHeight:Int = 450
  7. InitWindow(screenWidth, screenHeight, "raylib [shapes] example - draw circle sector")
  8. Local center:RVector2 = New RVector2((GetScreenWidth() - 300)/2, GetScreenHeight()/2)
  9. Local outerRadius:Float = 180
  10. Local startAngle:Float = 0
  11. Local endAngle:Float = 180
  12. Local segments:Float = 10
  13. Local minSegments:Int = 4
  14. SetTargetFPS(60) ' Set our game to run at 60 frames-per-second
  15. '--------------------------------------------------------------------------------------
  16. ' Main game loop
  17. While Not WindowShouldClose() ' Detect window close button or ESC key
  18. ' Update
  19. '----------------------------------------------------------------------------------
  20. ' NOTE: All variables update happens inside GUI control functions
  21. '----------------------------------------------------------------------------------
  22. ' Draw
  23. '----------------------------------------------------------------------------------
  24. BeginDrawing()
  25. ClearBackground(RAYWHITE)
  26. DrawLine(500, 0, 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.6))
  27. DrawRectangle(500, 0, GetScreenWidth() - 500, GetScreenHeight(), Fade(LIGHTGRAY, 0.3))
  28. DrawCircleSector(center, outerRadius, startAngle, endAngle, Int(segments), Fade(MAROON, 0.3))
  29. DrawCircleSectorLines(center, outerRadius, startAngle, endAngle, Int(segments), Fade(MAROON, 0.6))
  30. ' Draw GUI controls
  31. '------------------------------------------------------------------------------
  32. GuiSliderBar(New RRectangle(600, 40, 120, 20), "StartAngle", "", startAngle, 0, 720)
  33. GuiSliderBar(New RRectangle(600, 70, 120, 20), "EndAngle", "", endAngle, 0, 720)
  34. GuiSliderBar(New RRectangle( 600, 140, 120, 20), "Radius", "", outerRadius, 0, 200)
  35. GuiSliderBar(New RRectangle(600, 170, 120, 20), "Segments", "", segments, 0, 100)
  36. '------------------------------------------------------------------------------
  37. minSegments = Int(Int((endAngle - startAngle) / 90))
  38. Local col:RColor
  39. Local txt:String
  40. If segments >= minSegments Then
  41. txt = "MODE: MANUAL"
  42. col = MAROON
  43. Else
  44. txt = "MODE: AUTO"
  45. col = DARKGRAY
  46. End If
  47. DrawText(txt, 600, 200, 10, col)
  48. DrawFPS(10, 10)
  49. EndDrawing()
  50. '----------------------------------------------------------------------------------
  51. Wend
  52. ' De-Initialization
  53. '--------------------------------------------------------------------------------------
  54. CloseWindow() ' Close window and OpenGL context
  55. '--------------------------------------------------------------------------------------