Microsoft Small Basic

Program Listing: WXF823
' Monarch Butterfly 1.0
' Copyright (c) 2013 Nonki Takahashi. All rights reserved.
'
' History:
' 0.0 2013/02/10 16:18:01 Shapes generated by Shapes 1.5.
' 0.1 2013/02/10 Created.
'
GraphicsWindow.Title = "Monarch Butterfly"
' initialize shapes
Right_Init() ' right antenna and wing
' add shapes
scale = 1
Shapes_Add()
asX = 312
Left_Init() ' convert from right to left
Shapes_Add()
Shapes_Init() ' body
Shapes_Add()
Sub Shapes_Init
' Shapes | Initialize shapes data
' return shX, shY - current position of shapes
' return shape - array of shapes
shX = 301 ' x offset
shY = 140 ' y offset
shape = ""
shape[1] = "func=ell;x=2;y=20;width=19;height=19;bc=#1A1A1A;pc=#000000;pw=2;"
shape[2] = "func=ell;x=0;y=23;width=9;height=9;bc=#454545;pc=#000000;pw=2;"
shape[3] = "func=ell;x=14;y=23;width=9;height=9;bc=#454545;pc=#000000;pw=2;"
shape[4] = "func=ell;x=4;y=74;width=15;height=57;bc=#1A1A1A;pc=#000000;pw=2;"
shape[5] = "func=ell;x=1;y=33;width=21;height=48;bc=#1A1A1A;pc=#000000;pw=2;"
shape[6] = "func=ell;x=8;y=38;width=7;height=20;bc=#FFFFFF;pw=0;"
EndSub
Sub Left_Init
' Left | Initialize left shapes data
' param asX - axis of symmetry X coordinate
nShapes = Array.GetItemCount(shape)
For i = 1 To nShapes
If shape[i]["func"] = "line" Then
dx = shX + shape[i]["x"] - asX
x = asX - dx
dx = shX + shape[i]["x"] + shape[i]["x1"] - asX
x1 = asX - dx
shape[i]["x1"] = x1 - x
dx = shX + shape[i]["x"] + shape[i]["x2"] - asX
x2 = asX - dx
shape[i]["x2"] = x2 - x
shape[i]["x"] = x - shX
ElseIf shape[i]["func"] = "tri" Then
width = shape[i]["x3"] - shape[i]["x2"]
dx = shX + shape[i]["x"] - asX
x = asX - dx - width
shape[i]["x"] = x - shX
shape[i]["angle"] = -shape[i]["angle"]
ElseIf shape[i]["func"] = "ell" Then
dx = shX + shape[i]["x"] - asX
x = asX - dx - shape[i]["width"]
shape[i]["x"] = x - shX
shape[i]["angle"] = -shape[i]["angle"]
EndIf
EndFor
EndSub
Sub Right_Init
' Right | Initialize right shapes data
' return shX, shY - current position of shapes
' return shape - array of shapes
shX = 301 ' x offset
shY = 140 ' y offset
shape = ""
shape[1] = "func=line;x=16;y=0;x1=0;y1=23;x2=24;y2=0;pc=#454545;pw=2;"
shape[2] = "func=ell;x=7;y=16;width=174;height=73;bc=#1A1A1A;pw=0;"
shape[3] = "func=tri;x=54;y=54;x1=35;y1=0;x2=0;y2=49;x3=71;y3=49;angle=334;bc=#1A1A1A;pw=0;"
shape[4] = "func=ell;x=0;y=56;width=78;height=95;angle=332;bc=#1A1A1A;pw=0;"
shape[5] = "func=ell;x=31;y=47;width=81;height=22;angle=34;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[6] = "func=ell;x=65;y=46;width=59;height=19;angle=36;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[7] = "func=ell;x=86;y=41;width=48;height=18;angle=36;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[8] = "func=ell;x=35;y=29;width=76;height=18;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[9] = "func=ell;x=19;y=58;width=16;height=73;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[10] = "func=ell;x=38;y=98;width=20;height=39;angle=352;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[11] = "func=ell;x=31;y=90;width=15;height=48;angle=4;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[12] = "func=ell;x=48;y=89;width=18;height=36;angle=342;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[13] = "func=ell;x=29;y=55;width=29;height=53;angle=346;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[14] = "func=ell;x=54;y=67;width=18;height=46;angle=337;bc=#C16E25;pc=#1A1A1A;pw=4;"
shape[15] = "func=ell;x=111;y=21;width=9;height=9;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[16] = "func=ell;x=118;y=31;width=9;height=9;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[17] = "func=ell;x=121;y=41;width=9;height=9;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[18] = "func=ell;x=135;y=53;width=10;height=10;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[19] = "func=ell;x=135;y=41;width=9;height=9;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[20] = "func=ell;x=138;y=33;width=9;height=9;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[21] = "func=ell;x=133;y=24;width=9;height=9;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[22] = "func=ell;x=93;y=20;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[23] = "func=ell;x=164;y=37;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[24] = "func=ell;x=166;y=45;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[25] = "func=ell;x=162;y=51;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[26] = "func=ell;x=154;y=59;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[27] = "func=ell;x=159;y=56;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[28] = "func=ell;x=145;y=63;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[29] = "func=ell;x=134;y=66;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[30] = "func=ell;x=128;y=66;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[31] = "func=ell;x=120;y=71;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[32] = "func=ell;x=113;y=77;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[33] = "func=ell;x=106;y=80;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[34] = "func=ell;x=94;y=87;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[35] = "func=ell;x=74;y=88;width=6;height=7;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[36] = "func=ell;x=72;y=102;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[37] = "func=ell;x=70;y=113;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[38] = "func=ell;x=70;y=121;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[39] = "func=ell;x=64;y=124;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[40] = "func=ell;x=64;y=130;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[41] = "func=ell;x=57;y=132;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[42] = "func=ell;x=56;y=138;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[43] = "func=ell;x=48;y=135;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[44] = "func=ell;x=47;y=141;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[45] = "func=ell;x=36;y=135;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[46] = "func=ell;x=35;y=141;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[47] = "func=ell;x=29;y=131;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[48] = "func=ell;x=28;y=136;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[49] = "func=ell;x=20;y=125;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[50] = "func=ell;x=19;y=132;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[51] = "func=ell;x=16;y=122;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[52] = "func=ell;x=16;y=130;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[53] = "func=ell;x=174;y=52;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[54] = "func=ell;x=170;y=59;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[55] = "func=ell;x=163;y=66;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[56] = "func=ell;x=156;y=71;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[57] = "func=ell;x=146;y=73;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[58] = "func=ell;x=134;y=75;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[59] = "func=ell;x=129;y=76;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[60] = "func=ell;x=121;y=80;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[61] = "func=ell;x=114;y=85;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[62] = "func=ell;x=107;y=88;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[63] = "func=ell;x=95;y=94;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
shape[64] = "func=ell;x=73;y=109;width=5;height=5;bc=#FFFFFF;pc=#1A1A1A;pw=1;"
EndSub
Sub Shapes_Add
' Shapes | Add shapes as shapes data
' param shape - array of shapes
' param scale - to zoom
' return nShapes - number of shapes
' return shAngle - current angle of shapes
Stack.PushValue("local", i)
nShapes = Array.GetItemCount(shape)
s = scale
For i = 1 To nShapes
GraphicsWindow.PenWidth = shape[i]["pw"] * s
If shape[i]["pw"] > 0 Then
GraphicsWindow.PenColor = shape[i]["pc"]
EndIf
If shape[i]["func"] = "rect" Then
GraphicsWindow.BrushColor = shape[i]["bc"]
shape[i]["obj"] = Shapes.AddRectangle(shape[i]["width"]* s, shape[i]["height"] * s)
ElseIf shape[i]["func"] = "ell" Then
GraphicsWindow.BrushColor = shape[i]["bc"]
shape[i]["obj"] = Shapes.AddEllipse(shape[i]["width"]* s, shape[i]["height"] * s)
ElseIf shape[i]["func"] = "tri" Then
GraphicsWindow.BrushColor = shape[i]["bc"]
shape[i]["obj"] = Shapes.AddTriangle(shape[i]["x1"] * s, shape[i]["y1"] * s, shape[i]["x2"] * s, shape[i]["y2"] * s, shape[i]["x3"] * s, shape[i]["y3"] * s)
ElseIf shape[i]["func"] = "line" Then
shape[i]["obj"] = Shapes.AddLine(shape[i]["x1"] * s, shape[i]["y1"] * s, shape[i]["x2"] * s, shape[i]["y2"] * s)
EndIf
Shapes.Move(shape[i]["obj"], shX + shape[i]["x"] * s, shY + shape[i]["y"] * s)
If Text.IsSubText("rect|ell|tri", shape[i]["func"]) And shape[i]["angle"] <> 0 Then
Shapes.Rotate(shape[i]["obj"], shape[i]["angle"])
EndIf
shape[i]["rx"] = shape[i]["x"]
shape[i]["ry"] = shape[i]["y"]
EndFor
shAngle = 0
i = Stack.PopValue("local")
EndSub