Microsoft Small Basic

Program Listing: FSD172
' March Community Challenge - Small Basic Quilt Program // Quilt pattern -3 by NaochanON
color="0=Teal;1=Yellow;2=Green;3=Blue;4=Orange;5=Red;6=Purple;7=Pink"
GraphicsWindow.BackgroundColor=color[0]
dL="1=50;"
dL=dL+"2="+(dL[1]*0.6)+";rt2="+(dL[1]*math.SquareRoot(2))
YN=8
XN=7
GraphicsWindow.Width=dL[1]*XN*3
GraphicsWindow.height=dL["rt2"]*(YN+1)
GraphicsWindow.PenWidth=0

For j=1 To YN
For i=1 To XN
NMB=j+":"+i
GraphicsWindow.BrushColor="Skyblue"
shp[NMB]= Shapes.AddRectangle(2*dL[1],2*dL[1])
pos="X="+((i-1)*2*dL["rt2"]+Math.Remainder(j-1,2)*dL["rt2"])+";Y="+((j-1)*dL["rt2"])
Shapes.Move(shp[NMB],pos["X"],pos["Y"])
Shapes.Rotate(shp[NMB],45)
Shapes.SetOpacity(shp[NMB],40)
make_fish()
EndFor
EndFor

Sub make_fish
GraphicsWindow.BrushColor= color[Math.GetRandomNumber(7)]
shp[NMB][1]=Shapes.AddRectangle(dL[1],dL[1])
Shapes.Move(shp[NMB][1],pos["X"]+dL["rt2"]/2+dL[1]/2,pos["Y"]+dL[1]/2)
shp[NMB][2]=Shapes.Addtriangle(0,dL[1],dL[1]/2,0,dL[1]/2,dL[1])
Shapes.Move(shp[NMB][2],pos["X"]+dL[1],pos["Y"]+dL[1]-dL["rt2"])
shp[NMB][3]=Shapes.Addtriangle(0,0,0,dL[1],dL[1]/2,dL[1])
Shapes.Move(shp[NMB][3],pos["X"]+dL[1],pos["Y"]+dL["rt2"])
shp[NMB][4]=Shapes.Addtriangle(0,dL[2],dL[2],dL[2],dL[2],0)
Shapes.Move(shp[NMB][4],pos["X"]+dL[1]/2+dL["rt2"]/4-dL[2],pos["Y"]+dL["rt2"]/2)
For k=1 To 4
Shapes.Rotate(shp[NMB][k],45-(k-1)*90)
Shapes.SetOpacity(shp[NMB][k],20+8*j)
EndFor
Shapes.Rotate(shp[NMB][4],-45)
EndSub