Topic: 看看javaScript还能这样玩

ERP俱乐部

第 1 页 总共 1 页 [共有 3 条记录]


Posted by 半神 on 2009-01-07 08:25 下午

<html>
  <head>
    <title></title>
  </head>
  <body bgcolor="#000000" text="#FFFFFF">
    <p id="idText" style="color:rgb(255,255,255)"></p>
    <p id="idInsertObject"></p>  
  </body>
  <script languate="VBScript" type="text/VBScript">
    Dim pubOrbits_X(255, 255)
    Dim pubOrbits_Y(255, 255)
    Dim pubOrbits_Z(255, 255)
    Dim pubSpanObjects(255)
    Dim pubColors(255, 255)
    Dim pubStepOn
    Dim pubWorkOn
    Dim pubX
    Dim pubY
    Dim pubScale
    Dim pubTime
    Dim pubOnTimer
    Dim pubTimeout

    Sub window_onload()
      pubTimeout = 33
      CreateObjects
      CreateColors
      CreateOrbits pubOrbits_X, pubOrbits_Y, pubOrbits_Z
      NewSkyrocket
      ShowSkyrocket
    End Sub

    Sub NewSkyrocket()
      pubX= 300
      pubY= 300
      pubScale = 2 'Rnd * 2 + 2
      pubTime = window.setTimeout("ShowSkyrocket", 1)
    End Sub
       
    Sub ShowSkyrocket()
      If pubWorkOn <= 255 Then
          pubWorkOn = (pubWorkOn + 1) mod 256
          ViewObjects pubScale, pubWorkOn, pubX, pubY
          pubTime = window.setTimeout("ShowSkyrocket", 33)
        Else
          pubWorkOn = 0
          ViewObjects pubScale, pubWorkOn, pubX, pubY
          NewSkyrocket
      End If
    End Sub
   
    Sub ViewObjects(pScale, pIndex, pX, pY)
      For tIndex = 0 To 255
        If pIndex < 256 Then
          With pubSpanObjects(tIndex).style
            tLevel = pubOrbits_Z(tIndex, pIndex) + 200
            tSize = tLevel * 10 / 200
            tLight = tLevel * 170 / 200
            tSizeAdd = tSize / 2
            tScale = pScale * (tSize / 10)
            .color = pubColors(tIndex, tLight)
            .top = pubOrbits_Y(tIndex, pIndex) * tScale + pY - tSizeAdd
            .left = pubOrbits_X(tIndex, pIndex) * tScale + pX - tSizeAdd
            .fontsize = tSize & "px"
            .zindex = tSize
          End With
        End If
      Next
    End Sub

    Sub CreateObjects()
      For tIndex = 0 To 255
        Set pubSpanObjects(tIndex) = document.createElement("SPAN")
        With pubSpanObjects(tIndex)
          .innerText = "*"
        End With
        With pubSpanObjects(tIndex).style
          .position = "absolute"
          .color = Rgb(0, 0, 0)
        End With
        idInsertObject.insertAdjacentElement "beForeEnd", pubSpanObjects(tIndex)
      Next
    End Sub

    Sub CreateColors()
      Dim tColor(2)
      For tColorIndex = 0 To 255
        tColor(0) = Rnd : tColor(1) = Rnd : tColor(2) = Rnd       
        tColor(Int(Rnd*3)) = 1
        For tLightIndex = 0 To 255
          pubColors(tColorIndex, tLightIndex) = rgb(tColor(0) * tLightIndex, tColor(1) * tLightIndex, tColor(2) * tLightIndex)
        Next
      Next
    End Sub

    Sub CreateOrbits(pOrbits_X(), pOrbits_Y(), pOrbits_Z())
      tR = 100
      For tOrbitsIndex = 0 To 255
        tRndAgV = Int(Rnd * 360)
        tRndAgP = Int(Rnd * 360)
        For tLi = 0 To 255
          tAgP = (tRndAgP + (tLi * 360) \ 255) Mod 360
          SphereLocate tR, tRndAgV, tAgP, tX, tY, tZ
          pOrbits_X(tOrbitsIndex, tLi) = tY
          pOrbits_Y(tOrbitsIndex, tLi) = tZ
          pOrbits_Z(tOrbitsIndex, tLi) = tX
        Next
      Next
    End Sub
 
    Sub SphereLocate(pR, pAgV, pAgP, pX, pY, pZ)
      tRdV = Radian(pAgV)
      tRdP = Radian(pAgP)
      pX = SphereX(pR, tRdV, tRdP)
      pY = SphereY(pR, tRdV, tRdP)
      pZ = SphereZ(pR, tRdV)
    End Sub

    Function SphereX(pR, pRdV, pRdP)
      SphereX = pR * Sin(pRdV) * Cos(pRdP)
    End Function

    Function SphereY(pR, pRdV, pRdP)
      SphereY = pR * Sin(pRdV) * Sin(pRdP)
    End Function

    Function SphereZ(pR, pRdV)
      SphereZ = pR * Cos(pRdV)
    End Function
   
    Function Radian(pAngle)
      Radian =pAngle * 71 / 4068
    End Function
  </script>
</html>

 


Posted by 半神 on 2009-01-07 08:26 下午
将这个直接复制到一个"记事本"里面,然后将.txt的后缀名改成.html就可以看到效果了

Posted by Amanda0929 on 2009-01-22 10:21 上午
呵呵挺有意思的.