螺旋霓虹灯

<html>
 <head>
  <title>K.G Script3D 3.00 —— 螺旋霓虹灯</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 pubS_Pix_x
Dim pubS_Pix_y
Dim pubS_Pix_z
Dim pubS_Pix_cr
Dim pubS_Pix_cg
Dim pubS_Pix_cb
Dim pubD_Mx
Dim pubD_My
Dim pubD_Mz
Dim pubD_Rx
Dim pubD_Ry
Dim pubD_Rz
Dim pubD_Mtx_Mx
Dim pubD_Mtx_Mr
Dim pubD_Pix_x
Dim pubD_Pix_y
Dim pubD_Pix_z
Dim pubF_Va
Dim pubF_Vd
Dim pubV_Vx
Dim pubV_Vy
Dim pubV_Vz
Dim pubV_Sc
Dim pubV_Mtx_Mx
Dim pubV_Mtx_Mr
Dim pubV_Pix_x
Dim pubV_Pix_y
Dim pubV_Pix_z
Dim pubElm
Dim pubElm_Len
Dim pubWeb_Tv
Dim pubWeb_Tw
Dim pubWeb_WW, pubWeb_WH
Dim pubR, pubG, pubB
Dim pubOR, pubOG, pubOB
'Web DHTML 事件函数
Sub window_onload()
 MakeModule
   
 With document.body
  pubWeb_WW = .clientWidth
  pubWeb_WH = .clientHeight
 End With
 pubD_Rz = 0
 pubD_Rx = 0
 pubD_Ry = 0
 pubF_Va = 15
 pubF_Vd = 20
 
 pubV_Vx = pubWeb_WW / 2
 pubV_Vy = pubWeb_WH / 3
 pubV_Vz = 0
 pubV_Sc = 10
 pubWeb_Tw = 33
 MTX_3DMixV pubV_Vx, pubV_Vy, pubV_Vz, pubV_Sc, pubV_Mtx_Mx, pubV_Mtx_Mr
 
 Web_TimeLoop
 
End Sub
Sub MakeModule
 pubElm_Len = 599
 pubElm = ELM_Create(pubElm_Len)
 ReDim pubS_Pix_x(pubElm_Len), pubS_Pix_y(pubElm_Len), pubS_Pix_z(pubElm_Len)
 ReDim pubD_Pix_x(pubElm_Len), pubD_Pix_y(pubElm_Len), pubD_Pix_z(pubElm_Len)
 ReDim pubV_Pix_x(pubElm_Len), pubV_Pix_y(pubElm_Len), pubV_Pix_z(pubElm_Len)
 ReDim pubS_Pix_cr(pubElm_Len), pubS_Pix_cg(pubElm_Len), pubS_Pix_cb(pubElm_Len)
 tH = 100
 tR = 0
 For tI = 1 To 1500 Step 15
  tR = tI * 15 / 1500 + 5
  tA = tA + (1000 / (tR * 2 * 3.14))
  tZ = 30 - tI * 30 / 1500
  tAr = Radian(tA)
  For tRd = Int(tR) To Int(tR) - 5 Step -1
   tX = Sin(tAr) * tRd
   tY = Cos(tAr) * tRd
   pubS_Pix_x(tAdd) = tX
   pubS_Pix_y(tAdd) = tY
   pubS_Pix_z(tAdd) = tZ
   tAdd = tAdd + 1
  Next
 Next
 'MsgBox tAdd
 pubD_Mx = 0
 pubD_My = 0
 pubD_Mz = 0
End Sub
Sub Web_TimeLoop()
 pubD_Rz = (pubD_Rz + 1) Mod 360
 pubD_Rx = 45
 pubD_Ry = 0
 MTX_3DMixD pubD_Mx, pubD_My, pubD_Mz, pubD_Rx, pubD_Ry, pubD_Rz, pubD_Mtx_Mx, pubD_Mtx_Mr
 PXE_MTXTram3D pubS_Pix_x, pubS_Pix_y, pubS_Pix_z, pubD_Mtx_Mx, pubD_Mtx_Mr, pubD_Pix_x, pubD_Pix_y, pubD_Pix_z
 FIT_PSV pubD_Pix_x, pubD_Pix_y, pubD_Pix_z, pubF_Va, pubF_Vd, pubD_Pix_x, pubD_Pix_y, pubD_Pix_z
 PXE_MTXTram3D pubD_Pix_x, pubD_Pix_y, pubD_Pix_z, pubV_Mtx_Mx, pubV_Mtx_Mr, pubV_Pix_x, pubV_Pix_y, pubV_Pix_z
 
 For tI = 0 To 5
 For tEi = pubElm_Len To 0 Step -1
  If CBool(tEi) Then
    pubS_Pix_cr(tEi) = pubS_Pix_cr(tEi-1)
    pubS_Pix_cg(tEi) = pubS_Pix_cg(tEi-1)
    pubS_Pix_cb(tEi) = pubS_Pix_cb(tEi-1)
   Else
    If pubR < pubOR Then pubR = pubR + 1
    If pubR > pubOR Then pubR = pubR - 1
    If pubG < pubOG Then pubG = pubG + 1
    If pubG > pubOG Then pubG = pubG - 1
    If pubB < pubOB Then pubB = pubB + 1
    If pubB > pubOB Then pubB = pubB - 1
    If pubR = pubOR And pubB = pubOB And pubG = pubOG Then
     pubOR = Int(Rnd * 32) + 31
     pubOG = Int(Rnd * 32) + 31
     pubOB = Int(Rnd * 32) + 31
    End If
    pubS_Pix_cr(tEi) = pubR*4
    pubS_Pix_cg(tEi) = pubG*4
    pubS_Pix_cb(tEi) = pubB*4
  End If
 Next
 Next
 For tEi = pubElm_Len To 0 Step -1
  With pubElm(tEi).style
   .left = pubV_Pix_x(tEi)
   .top = pubV_Pix_y(tEi)
   tL = tEi Mod 6 + 1
   .color = rgb(pubS_Pix_cr(tEi)/tL,pubS_Pix_cg(tEi)/tL,pubS_Pix_cb(tEi)/tL)
  End With
 Next
 
 pubWeb_Tv = window.setTimeout("Web_TimeLoop", pubWeb_Tw)
End Sub
Function ELM_Create(pEn)
 ReDim tElms(pEn)
 For tEi = 0 To pEn
  With document
   Set tElms(tEi) = .createElement("SPAN")
   .body.insertAdjacentElement "beForeEnd", tElms(tEi)
  End With
  With tElms(tEi)
   .innerText = "*"
   .style.position = "absolute"
   .style.color = rgb(0,0,0)
  End With
 Next
 ELM_Create = tElms
End Function
Sub PXE_MTXTram2D(pPx(), pPy(), pM(), pMr, oPx(), oPy())
 tPe = UBound(pPx)
 For tPi = 0 To tPe
  oPx(tPi) = pPx(tPi) * pM(0) + pPy(tPi) * pM(1) + pM(2)
  oPy(tPi) = pPx(tPi) * pM(3) + pPy(tPi) * pM(4) + pM(5)
 Next
End Sub
Sub PXE_MTXTram3D(pPx(), pPy(), pPz(), pM(), pMr(), oPx(), oPy(), oPz())
 tPe = UBound(pPx)
 For tPi = 0 To tPe
  oPx(tPi) = pPx(tPi) * pM(0) + pPy(tPi) * pM(1) + pPz(tPi) * pM(2) + pM(3)
  oPy(tPi) = pPx(tPi) * pM(4) + pPy(tPi) * pM(5) + pPz(tPi) * pM(6) + pM(7)
  oPz(tPi) = pPx(tPi) * pM(8) + pPy(tPi) * pM(9) + pPz(tPi) * pM(10) + pM(11)
 Next
End Sub
Sub FIT_PSV(iPx, iPy, iPz, iVa, iVd, oPx, oPy, oPz)
 tPe = UBound(iPx)
 For tPi = 0 To tPe
  tVr = Sin(Radian(iVa))
  tZ = iPz(tPi) + iVd
  oPx(tPi) = iPx(tPi) * tVr * tZ / (tVr * iVd)
  oPy(tPi) = iPy(tPi) * tVr * tZ / (tVr * iVd)
  oPz(tPi) = iPz(tPi)
 Next
End Sub
Sub MTX_2DPixMulti(iSc, oM(), oMr)
 oMr = 3
 ReDim oM(8)
 oM = Array(iSc, 0, 0, 0, iSc, 0, 0, 0, 1)
End Sub
Sub MTX_2DPixMove(iMx, iMy, oM(), oMr)
 oMr = 3
 ReDim oM(8)
 oM = Array(1, 0, iMx, 0, 1, iMy, 0, 0, 1)
End Sub
Sub MTX_2DRot(iA, oM(), oMr)
 tR = Radian(iA)
 oMr = 3
 ReDim oM(8)
 oM = Array(cos(tR), -sin(tR), 0, sin(tR), cos(tR), 0, 0, 0, 1)
End Sub
Sub MTX_3DMixD(iMx, iMy, iMz, iRx, iRy, iRz, oMx, oMr)
 MTX_3DPixMove tMtx_MV, oMr, iMx, iMy, iMz
 MTX_3DPixRotZ tMtx_RTz, oMr, iRz
 MTX_3DPixRotX tMtx_RTx, oMr, iRx
 MTX_3DPixRotY tMtx_RTy, oMr, iRy
 MTX_Multi tMtx_MV, oMr, tMtx_RTz, oMr, tMx, oMr
 oMx = tMx
 MTX_Multi oMx, oMr, tMtx_RTx, oMr, tMx, oMr
 oMx = tMx
 MTX_Multi oMx, oMr, tMtx_RTy, oMr, tMx, oMr
 oMx = tMx
End Sub
Sub MTX_3DMixV(iVx, iVy, iVz, iSc, oMx, oMr)
 MTX_3DPixMulti tMtx_SC, oMr, iSc
 MTX_3DPixMove tMtx_VM, oMr, iVx, iVy, iVz
 MTX_Multi tMtx_SC, oMr, tMtx_VM, oMr, tMx, oMr
 oMx = tMx
End Sub
Sub MTX_3DPixMulti(oM(), oMr, iSc)
 oMr = 4
 ReDim oM(15) 
 oM = Array(iSc, 0, 0, 0, 0, iSc, 0, 0, 0, 0, iSc, 0, 0, 0, 0, 1)
End Sub
Sub MTX_3DPixMove(oM(), oMr, iMx, iMy, iMz)
 oMr = 4
 ReDim oM(15) 
 oM = Array(1, 0, 0, iMx, 0, 1, 0, iMy, 0, 0, 1, iMz, 0, 0, 0, 1)
End Sub
Sub MTX_3DPixRotZ(oM(), oMr, iA)
 oMr = 4
 ReDim oM(15)
 tR = Radian(iA) : tSin = sin(tR) : tCos = cos(tR)
 oM = Array(tCos, -tSin, 0, 0, tSin, tCos, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) 
End Sub
Sub MTX_3DPixRotY(oM(), oMr, iA)
 oMr = 4
 ReDim oM(15) 
 tR = Radian(iA) : tSin = sin(tR) : tCos = cos(tR)
 oM = Array(tCos, 0, tSin, 0, 0, 1, 0, 0, -tSin, 0, tCos, 0, 0, 0, 0, 1)
End Sub
Sub MTX_3DPixRotX(oM(), oMr, iA)
 oMr = 4
 tR = Radian(iA) 
 tR = Radian(iA) : tSin = sin(tR) : tCos = cos(tR) 
 oM = Array(1, 0, 0, 0, 0, tCos, tSin, 0, 0, -tSin, tCos, 0, 0, 0, 0, 1)
End Sub
Sub MTX_Multi(iMa(), iMar, iMb(), iMbr, oMc(), oMcr)
 tN = (iMar = ((UBound(iMb) / iMbr) + 1)) And (iMar - 1)
 
 If CBool(tN) Then
 
  tM = Ubound(iMa) / iMar
  tP = iMbr - 1
  
  oMcr = tP + 1
    
  ReDim oMc(oMcr * (tM + 1) - 1)
  
  For tMi = 0 To tM
   For tPi = 0 To tP
    For tNi = 0 To tN
     tMv = MTX_VGet(oMc, oMcr, tMi, tPi) + MTX_VGet(iMa, iMar, tMi, tNi) * MTX_VGet(iMb, iMbr, tNi, tPi)
     MTX_VSet oMc, oMcr, tMi, tPi, tMv
     
    Next
   Next
  Next
  
 End If
  
End Sub
Sub MTX_VSet(pM(), pMr, pX, pY, pMv)
 tMi = pY * pMr + pX
 pM(tMi) = pMv
End Sub
Function MTX_VGet(pM(), pMr, pX, pY)
 tMi = pY * pMr + pX
 MTX_VGet = pM(tMi)
End Function
Function Radian(pA)
 Radian = pA * 71 / 4068
End Function
</script>
</html>

转载:http://blog.csdn.net/zswang/archive/2009/12/27/5085342.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值