Microsoft Small Basic

Program Listing: QRW993
' Draw Arc
' Version 0.2
' Copyright © 2016 Nonki Takahashi. The MIT License.
'
GraphicsWindow.PenWidth = 20
GraphicsWindow.PenColor = "Red"
GraphicsWindow.BrushColor = "Black"
param = "x=315;y=150;r=200;a1=0;a2=180;da=10;ct=Round"
DrawArc()
d = 30
GraphicsWindow.FillEllipse(240 - d / 2, 100 - d / 2, d, d)
GraphicsWindow.FillEllipse(390 - d / 2, 100 - d / 2, d, d)
Sub DrawArc
' param["x"] - center x coordinate [px]
' param["y"] - center y coordinate [px]
' param["r"] - radius [px]
' param["a1"] - start angle [°]
' param["a2"] - end angle [°]
' param["da"] - delta (step) angle [°]
' param["ct"] - cap type ("Round" for round, otherwise for flat)
Stack.PushValue("local", local)
Stack.PushValue("local", a)
local["pw"] = GraphicsWindow.PenWidth
local["bc"] = GraphicsWindow.BrushColor
GraphicsWindow.BrushColor = GraphicsWindow.PenColor
For a = param["a1"] To param["a2"] Step param["da"]
local["rad"] = Math.GetRadians(a)
local["x2"] = param["x"] + param["r"] * Math.Cos(local["rad"])
local["y2"] = param["y"] + param["r"] * Math.Sin(local["rad"])
If param["a1"] < a Then
GraphicsWindow.DrawLine(local["x1"], local["y1"], local["x2"], local["y2"])
EndIf
If ((param ["a1"] < a) And (a < param["a2"])) Or Text.ConvertToLowerCase(param["ct"]) = "round" Then
GraphicsWindow.PenWidth = 0
GraphicsWindow.FillEllipse(local["x2"] - local["pw"] / 2, local["y2"] - local["pw"] / 2, local["pw"], local["pw"])
GraphicsWindow.PenWidth = local["pw"]
EndIf
local["x1"] = local["x2"]
local["y1"] = local["y2"]
EndFor
GraphicsWindow.BrushColor = local["bc"]
a = Stack.PopValue("local")
local = Stack.PopValue("local")
EndSub