aaaabbb
Microsoft Small Basic
                        Program Listing:  SLH926
  
  1. GraphicsWindow.BackgroundColor = ”Wheat”
    eyeball_num = 5
    For i = 1 to eyeball_num
    rad[i] = Math.GetRandomNumber(150)+50
    pupilrad[i] = rad[i]/5
    irisrad[i] = pupilrad[i]*1.5
    eyecolor[i] = GraphicsWindow.GetRandomColor()
    GraphicsWindow.BrushColor = ”White”
    eyeball[i] = Shapes.AddEllipse(rad[i],rad[i])
    GraphicsWindow.BrushColor = eyecolor[i]
    iris[i] = Shapes.AddEllipse(irisrad[i],irisrad[i])
    GraphicsWindow.BrushColor = ”Black”
    pupil[i] = Shapes.AddEllipse(pupilrad[i],pupilrad[i])
    posX[i] = Math.GetRandomNumber(GraphicsWindow.Width-rad[i])
    posY[i] = Math.GetRandomNumber(GraphicsWindow.Height-rad[i])
    Shapes.Move(pupil[i],posX[i]-pupilrad[i]/2,posY[i]-pupilrad[i]/2)
    Shapes.Move(eyeball[i],posX[i]-rad[i]/2,posY[i]-rad[i]/2)
    Shapes.Move(iris[i],posX[i]-irisrad[i]/2,posY[i]-irisrad[i]/2)
    EndFor
    GraphicsWindow.MouseDown = MouseDown
    GraphicsWindow.MouseUp = MouseUp
    While (“True”)
    For g = 1 To eyeball_num
    getAngle()
    distfromcenter[g] = Math.SquareRoot(Math.Abs(dx[g]*dx[g]+dy[g]*dy[g]))
    yOnEyeball[g] = Math.Sin(angle[g])*Math.Min(rad[g]/2-irisrad[g]/2,distfromcenter[g]/3)
    xOnEyeball[g] = Math.Cos(angle[g])*Math.Min(rad[g]/2-irisrad[g]/2,distfromcenter[g]/3)
    Shapes.Move(pupil[g],posX[g]+xOnEyeball[g]-pupilrad[g]/2,posY[g]+yOnEyeball[g]-pupilrad[g]/2)
    Shapes.Move(iris[g],posX[g]+xOnEyeball[g]-irisrad[g]/2,posY[g]+yOnEyeball[g]-irisrad[g]/2)
    EndFor
    Program.Delay(10)
    EndWhile Sub getAngle
    dx[g] = GraphicsWindow.MouseX - posX[g]
    dy[g] = GraphicsWindow.MouseY - posY[g]
    If (dx[g] = 0) Then
    angle[g] = Math.Pi/2
    If (dy[g] < 0) Then
    angle[g] = -angle[g]
    EndIf
    Else
    angle[g] = Math.ArcTan(dy[g]/dx[g])
    EndIf
    If (dx[g] < 0) Then
    angle[g] = angle[g]+Math.Pi
    EndIf
    EndSub
    Sub MouseDown
    For r = 1 To eyeball_num
    Shapes.Zoom(iris[r],1.2,1.2)
    Shapes.Zoom(pupil[r],1.2,1.2)
    EndFor
    EndSub
    Sub MouseUp
    For w = 1 To eyeball_num
    Shapes.Zoom(iris[w],1,1)
    Shapes.Zoom(pupil[w],1,1)
    EndFor
    EndSub
  2. ‘ Copyright (c) Microsoft Corporation. All rights reserved.
 

Deja un comentario