Microsoft Small Basic

Program Listing:
Embed this in your website
' mahreen miangul Smiley Animation DecEmber 2018
' Blink added by Nonki Takahashi

GraphicsWindow.top=0
GraphicsWindow.left=0
GraphicsWindow.Title = "mahreen miangul"
GraphicsWindow.Width = "1288"
GraphicsWindow.Height = "666"
GraphicsWindow.BackgroundColor="skyblue"

'----------------- Draw Hill-------------------------------------------------------------------------------------------------------
' Hill
GraphicsWindow.brushColor = "tan"
GraphicsWindow.fillEllipse(-88,505,620,288)
GraphicsWindow.fillEllipse(211,388,622,366)
GraphicsWindow.fillEllipse(211,388,1888,666)

'Makesprite()
SPRITE_init()         ' <--------- all shape data is input here!!
add_shapes()          ' <--------- all shapes are added here!!
eyes[1] = "1=6;2=7;"
StartBlink()

Sub add_shapes
  For M=1 to Array.GetItemCount(s)      ' 5 types shapes // Kong , trees , House , Apple , sprite
    For N=1 to Array.GetItemCount(s[M]) ' repeat number //Kong=1 , trees =12 , House=1 , Apple=16 , sprite=1
      ss=s[M][N]      ' scale
      _shx=shx[M][N]  ' base point _X
      _shY=shY[M][N]  ' base point _Y
      _shape=shape[M] ' temporary shape data
      NMB=M+":"+N     ' shape index
      for i=1 To Array.GetItemCount(_shape)
        GraphicsWindow.PenWidth = _shape[i]["pw"]
        GraphicsWindow.BrushColor = _shape[i]["bc"]
        GraphicsWindow.penColor = _shape[i]["pc"]
        If _shape[i]["func"]="ell" Then
          shp[NMB][i] = Shapes.AddEllipse(_shape[i]["width"]*ss, _shape[i]["height"]*ss)
        ElseIf _shape[i]["func"]="rect" Then
          shp[NMB][i] = Shapes.AddRectangle(_shape[i]["width"]*ss, _shape[i]["height"]*ss)
        ElseIf _shape[i]["func"]="tri" Then
          shp[NMB][i] = Shapes.Addtriangle(_shape[i]["x1"]*ss, _shape[i]["y1"]*ss,_shape[i]["x2"]*ss, _shape[i]["y2"]*ss, _shape[i]["x3"]*ss, _shape[i]["y3"]*ss)
        ElseIf shape[N][i]["func"]="line" Then
          shp[NMB][i] = Shapes.Addline(_shape[i]["x1"]*ss, _shape[i]["y1"]*ss,_shape[i]["x2"]*ss, _shape[i]["y2"]*ss)
        EndIf
        Shapes.Animate(shp[NMB][i], _shape[i]["x"]*ss+_shX, _shape[i]["y"]*ss+_shY, 500)
        Shapes.Rotate(shp[NMB][i], _Shape[i]["angle"])
      EndFor
    Endfor
  Endfor
EndSub

' Smiley//mahreen miangul
Sub SPRITE_init
  s[1]   ="1=1.7;2=1.8;"
  shX[1] ="1=-800;2=-600;"
  shY[1] ="1=-1188;2=-1088;"
  shape[1][1] = "func=ell;x=800;y=800;width=120;height=120;bc=orangered;pw=0;"
  shape[1][2] = "func=ell;x=813;y=805;width=95;height=95;bc=greenyellow;pw=0;"
  shape[1][3] = "func=ell;x=827;y=807;width=65;height=35;bc=white;pw=0;"
  shape[1][4] = "func=rect;x=822;y=833;width=25;height=4;angle=10;bc=red;pw=0;"
  shape[1][5] = "func=rect;x=877;y=844;width=25;height=4;angle=10;bc=red;pw=0;"
  shape[1][6] = "func=ell;x=822;y=822;width=25;height=25;bc=red;pw=0;"
  shape[1][7] = "func=ell;x=877;y=833;width=25;height=25;bc=red;pw=0;"
  shape[1][8] = "func=ell;x=833;y=855;width=40;height=35;angle=30;bc=red;pw=0;"
  shape[1][9] = "func=rect;x=838;y=850;width=40;height=20;angle=20;bc=greenyellow;pw=0;"
EndSub

Sub StartBlink
  Timer.Interval = 500
  Timer.Tick = OnTick
EndSub

Sub OnTick
  ' work t - times
  t = t + 1
  If Math.Remainder(t, 6) = 0 Then
    open = "False"
    Blink()
  ElseIf Math.Remainder(t, 6) = 1 Then
    open = "True"
    Blink()
  EndIf
EndSub

Sub Blink
  ' work iSp - splite
  ' work iRp - repeat
  ' work iEy - eye
  For iSp = 1 To Array.GetItemCount(s)
    _shape = shape[iSp]
    _eyes = eyes[iSp]
    For iRp = 1 To Array.GetItemCount(s[iSp])
      _shp = shp[iSp + ":" + iRp]
      For iEy = 1 To Array.GetItemCount(_eyes)
        _eye = _eyes[iEy]
        If open Then
          Shapes.ShowShape(_shp[_eye])
        Else
          Shapes.HideShape(_shp[_eye])
        EndIf
      EndFor
    EndFor
  EndFor
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.