Microsoft Small Basic

Program Listing:
Embed this in your website
' Draw Pictogram
' Version 0.2
' Copyright © 2019 Nonki Takahashi. The MIT License.
' Last update 2019-04-17
' Program ID PPT955-0

GraphicsWindow.Title = "Pictogram - Handicapped Accesible Sign"
GraphicsWindow.Width = 600
GraphicsWindow.Height = 600
border = "#666666"
blue = "#155196"
GraphicsWindow.PenWidth = 2
GraphicsWindow.PenColor = border
GraphicsWindow.BrushColor = "White"
param="x=1;y=1;width=598;height=598;border-radius=50;"
GW_FillRoundRectangle()
GW_DrawRoundRectangle()
param="x=15;y=15;width=570;height=570;border-radius=35;"
GraphicsWindow.BrushColor = blue
GW_FillRoundRectangle()
GraphicsWindow.PenWidth = 40
GraphicsWindow.PenColor = "White"
GraphicsWindow.DrawEllipse(113, 246, 280, 280)
GraphicsWindow.BrushColor = blue
GraphicsWindow.FillRectangle(253, 216, 160, 160)
GraphicsWindow.PenWidth = 68
GraphicsWindow.PenColor = blue
GraphicsWindow.DrawLine(212, 98, 228, 338)
GraphicsWindow.PenWidth = 40
GraphicsWindow.PenColor = "White"
GraphicsWindow.DrawLine(212, 98, 228, 338)
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillEllipse(188, 50, 87, 87)
GraphicsWindow.PenWidth = 84
GraphicsWindow.PenColor = blue
GraphicsWindow.DrawLine(378, 306, 452, 490)
GraphicsWindow.PenWidth = 40
GraphicsWindow.PenColor = "White"
GraphicsWindow.DrawLine(379, 307, 452, 490)
GraphicsWindow.DrawLine(220, 250, 352, 250)
GraphicsWindow.DrawLine(208, 320, 396, 320)
GraphicsWindow.DrawLine(426, 480, 512, 447)

Sub GW_DrawRoundRectangle
  ' GraphicsWindow | draw round rectangle
  ' param x - co-ordinate of the rectangle
  ' param y - co-ordinate of the rectangle
  ' param width - of the rectangle
  ' param height - of the rectangle
  ' param border-radius
  Stack.PushValue("local", param)
  Stack.PushValue("local", local)
  local = param
  param = ""
  param["r"] = local["border-radius"]
  If (local["width"] / 2 < param["r"]) Or (local["height"] / 2 < param["r"]) Then
    param["r"] = Math.Min(local["width"] / 2, local["height"] / 2)
  EndIf
  param["da"] = 5
  param["x"] = local["x"] + param["r"]
  param["y"] = local["y"] + param["r"]
  param["a1"] = 180
  param["a2"] = 270
  GW_DrawArc()
  GraphicsWindow.DrawLine(local["x"] + param["r"], local["y"], local["x"] + local["width"] - param["r"], local["y"])
  param["x"] = local["x"] + local["width"] - param["r"]
  param["y"] = local["y"] + param["r"]
  param["a1"] = 270
  param["a2"] = 360
  GW_DrawArc()
  GraphicsWindow.DrawLine(local["x"] + local["width"], local["y"] + param["r"], local["x"] + local["width"], local["y"] + local["height"] - param["r"])
  param["x"] = local["x"] + local["width"] - param["r"]
  param["y"] = local["y"] + local["height"] - param["r"]
  param["a1"] = 0
  param["a2"] = 90
  GW_DrawArc()
  GraphicsWindow.DrawLine(local["x"] + param["r"], local["y"] + local["height"], local["x"] + local["width"] - param["r"], local["y"] + local["height"])
  param["x"] = local["x"] + param["r"]
  param["y"] = local["y"] + local["height"] - param["r"]
  param["a1"] = 90
  param["a2"] = 180
  GW_DrawArc()
  GraphicsWindow.DrawLine(local["x"], local["y"] + param["r"], local["x"], local["y"] + local["height"] - param["r"])
  local = Stack.PopValue("local")
  param = Stack.PopValue("local")
EndSub

Sub GW_FillRoundRectangle
  ' GraphicsWindow | fill round rectangle
  ' param x - co-ordinate of the rectangle
  ' param y - co-ordinate of the rectangle
  ' param width - of the rectangle
  ' param height - of the rectangle
  ' param border-radius
  Stack.PushValue("local", param)
  If (param["width"] / 2 < param["border-radius"]) Or (param["height"] / 2 < param["border-radius"]) Then
    param["border-radius"] = Math.Min(param["width"] / 2, param["height"] / 2)
  EndIf
  GraphicsWindow.FillEllipse(param["x"], param["y"], param["border-radius"] * 2, param["border-radius"] * 2)
  GraphicsWindow.FillRectangle(param["x"] + param["border-radius"], param["y"], param["width"] - param["border-radius"] * 2, param["height"])
  GraphicsWindow.FillEllipse(param["x"] + param["width"] - param["border-radius"] * 2, param["y"], param["border-radius"] * 2, param["border-radius"] * 2)
  GraphicsWindow.FillRectangle(param["x"], param["y"] + param["border-radius"], param["width"], param["height"] - param["border-radius"] * 2)
  GraphicsWindow.FillEllipse(param["x"], param["y"] + param["height"] - param["border-radius"] * 2, param["border-radius"] * 2, param["border-radius"] * 2)
  GraphicsWindow.FillEllipse(param["x"] + param["width"] - param["border-radius"] * 2, param["y"] + param["height"] - param["border-radius"] * 2, param["border-radius"] * 2, param["border-radius"] * 2)
  param = Stack.PopValue("local")
EndSub

Sub GW_DrawArc
  ' GraphicsWindow | draw arc
  ' param x - co-ordinate of the center
  ' param y - co-ordinate of the center
  ' param a1 - start angle
  ' param a2 - end angle
  Stack.PushValue("local", param)
  Stack.PushValue("local", local)
  Stack.PushValue("local", a)
  local = param
  param = ""
  local["pw"] = GraphicsWindow.PenWidth
  local["pc"] = GraphicsWindow.PenColor
  local["bc"] = GraphicsWindow.BrushColor
  GraphicsWindow.BrushColor = local["pc"]
  local["r1"] = local["r"] - local["pw"] / 2
  local["r2"] = local["r"] + local["pw"] / 2
  For a = local["a1"] To local["a2"] Step local["da"]
    local["rad"] = Math.GetRadians(a)
    param["x1"] = local["x"] + local["r1"] * Math.Cos(local["rad"])
    param["y1"] = local["y"] + local["r1"] * Math.Sin(local["rad"])
    param["x2"] = local["x"] + local["r2"] * Math.Cos(local["rad"])
    param["y2"] = local["y"] + local["r2"] * Math.Sin(local["rad"])
    If local["a1"] < a Then
      GW_FillQuadrangle()
    EndIf
    param["x4"] = param["x1"]
    param["y4"] = param["y1"]
    param["x3"] = param["x2"]
    param["y3"] = param["y2"]
  EndFor
  GraphicsWindow.BrushColor = local["bc"]
  a = Stack.PopValue("local")
  local = Stack.PopValue("local")
  param = Stack.PopValue("local")
EndSub

Sub GW_FillQuadrangle
  ' GraphicsWindow | fill quadrangle
  ' param x1 - the x co-ordinate of the first point
  ' param y1 - the y co-ordinate of the first point
  ' param x2 - the x co-ordinate of the second point
  ' param y2 - the y co-ordinate of the second point
  ' param x3 - the x co-ordinate of the third point
  ' param y3 - the y co-ordinate of the third point
  ' param x4 - the x co-ordinate of the fourth point
  ' param y4 - the y co-ordinate of the fourth point
  GraphicsWindow.FillTriangle(param["x1"], param["y1"], param["x2"], param["y2"], param["x3"], param["y3"])
  GraphicsWindow.FillTriangle(param["x3"], param["y3"], param["x4"], param["y4"], param["x1"], param["y1"])
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.