【编程游戏】贺岁霓虹灯。(第一名奖励10000可用分) 效果图 评分 参观 [目前Firefox中好使,其他浏览器需复制到本地,存为html文件看效果] <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 language="VBScript" type="text/VBScript"> 'CSDN KiteGirl 原创 Dim pubS_Pix_x, pubS_Pix_y, pubS_Pix_z Dim pubS_Pix_cr, pubS_Pix_cg, pubS_Pix_cb Dim pubD_Mx, pubD_My, pubD_Mz Dim pubD_Rx, pubD_Ry, pubD_Rz Dim pubD_Mtx_Mx, pubD_Mtx_Mr Dim pubD_Pix_x, pubD_Pix_y, pubD_Pix_z, pubD_Pix_s Dim pubF_Va, pubF_Vd Dim pubV_Vx, pubV_Vy, pubV_Vz, pubV_Sc Dim pubV_Mtx_Mx, pubV_Mtx_Mr Dim pubV_Pix_x, pubV_Pix_y, pubV_Pix_z Dim pubElm, pubElm_Len Dim pubWeb_Tv, pubWeb_Tw Dim pubWeb_WW, pubWeb_WH Dim pubWeb_FontSize Dim pubLg Dim pubR, pubG, pubB Dim pubOR, pubOG, pubOB Dim pubX, pubY, pubZ Dim pubOX, pubOY, pubOZ 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 = 40 pubV_Vx = pubWeb_WW / 2 pubV_Vy = pubWeb_WH / 2 pubV_Vz = 0 pubV_Sc = 15 pubWeb_Tw = 33 pubWeb_FontSize = 5 pubD_Mx = 0 pubD_My = 0 pubD_Mz = 0 MTX_3DMixV pubV_Vx, pubV_Vy, pubV_Vz, pubV_Sc, pubV_Mtx_Mx, pubV_Mtx_Mr pubD_Rz = 45 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, pubD_Pix_s 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 Web_TimeLoop End Sub Sub MakeModule tSize = 20 pubElm_Len = tSize^2 * 3 pubElm = ELM_Create(pubElm_Len) ReDim pubS_Pix_x(pubElm_Len), pubS_Pix_y(pubElm_Len), pubS_Pix_z(pubElm_Len) ReDim pubS_Pix_cr(pubElm_Len), pubS_Pix_cg(pubElm_Len), pubS_Pix_cb(pubElm_Len) ReDim pubD_Pix_x(pubElm_Len), pubD_Pix_y(pubElm_Len), pubD_Pix_z(pubElm_Len) ReDim pubD_Pix_s(pubElm_Len), pubLg(pubElm_Len) ReDim pubV_Pix_x(pubElm_Len), pubV_Pix_y(pubElm_Len), pubV_Pix_z(pubElm_Len) tH = 100 tR = 0 For tI = 0 To (tSize^2 - 1) tX = tI mod tSize tY = tI / tSize pubS_Pix_x(tI) = tX : pubS_Pix_y(tI) = tY : pubS_Pix_z(tI) = 0 : pubLg(tI) = 1 tPi = tI + tSize^2 pubS_Pix_x(tPi) = tX : pubS_Pix_y(tPi) = 0 : pubS_Pix_z(tPi) = tY : pubLg(tPi) = 1 tPi = tI + tSize^2 * 2 pubS_Pix_x(tPi) = 0 : pubS_Pix_z(tPi) = tX : pubS_Pix_y(tPi) = tY : pubLg(tPi) = 1 Next End Sub Sub Web_TimeLoop() tSize = 20 ValuesMove pubX, pubY, pubZ, pubOX, pubOY, pubOZ If pubX = pubOX And pubY = pubOY And pubZ = pubOZ Then pubOX = Int(Rnd * tSize) pubOY = Int(Rnd * tSize) pubOZ = Int(Rnd * tSize) End If ValuesMove pubR, pubG, pubB, pubOR, pubOG, pubOB If pubR = pubOR And pubB = pubOB And pubG = pubOG Then pubOR = Int(Rnd * 64) + 63 pubOG = Int(Rnd * 64) + 63 pubOB = Int(Rnd * 64) + 63 End If For tEi = 0 To pubElm_Len pubS_Pix_cr(tEi) = pubR * 2 pubS_Pix_cg(tEi) = pubG * 2 pubS_Pix_cb(tEi) = pubB * 2 tLg = SQR(Abs(pubS_Pix_x(tEi) - pubX) ^ 2 + Abs(pubS_Pix_y(tEi) - pubY) ^ 2 + Abs(pubS_Pix_z(tEi) - pubZ) ^ 2) If tLg <= tSize Then pubLg(tEi) = (tSize - tLg) / tSize Else pubLg(tEi) = 0 End If Next ELM_Show pubElm, pubV_Pix_x, pubV_Pix_y, pubV_Pix_z, pubD_Pix_s, pubS_Pix_cr, pubS_Pix_cg, pubS_Pix_cb, pubLg, pubWeb_FontSize pubWeb_Tv = window.setTimeout("Web_TimeLoop", pubWeb_Tw) End Sub Sub ValuesMove(pA, pB, pC, pOA, pOB, pOC) ValueMove pA, pOA ValueMove pB, pOB ValueMove pC, pOC End Sub Sub ValueMove(pV, pVo) If pV < pVo Then pV = pV + 1 If pV > pVo Then pV = pV - 1 End Sub Sub ELM_Show(pEl(), pVx(), pVy(), pVz(), pVs(), pSr(), pSg(), pSb(), pLg(), pFs) tEn = UBound(pEl) For tEi = 0 To tEn With pubElm(tEi).style .left = pVx(tEi) .top = pVy(tEi) .zindex = pVz(tEi) + 100 .backgroundcolor = rgb(pSr(tEi) * pLg(tEi), pSg(tEi) * pLg(tEi), pSb(tEi) * pLg(tEi)) .width = pVs(tEi) * pFs & "px" .height = .width End With Next End Sub Function ELM_Create(pEn) ReDim tElms(pEn) For tEi = 0 To pEn With document Set tElms(tEi) = .createElement("DIV") .body.insertAdjacentElement "beForeEnd", tElms(tEi) End With With tElms(tEi) .style.position = "absolute" .style.backgroundcolor = rgb(255,255,255) .style.fontsize = 0 .style.width = 10 .style.height = 10 End With Next ELM_Create = tElms End Function 'PXE 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 'FIT Sub FIT_PSV(iPx, iPy, iPz, iVa, iVd, oPx, oPy, oPz, oPs) tPe = UBound(iPx) For tPi = 0 To tPe tZ = iPz(tPi) + iVd oPs(tPi) = tZ / iVd oPx(tPi) = iPx(tPi) * oPs(tPi) oPy(tPi) = iPy(tPi) * oPs(tPi) oPz(tPi) = iPz(tPi) Next End Sub 'MTX 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) : 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> 参观 [目前Firefox中好使,其他浏览器需复制到本地,存为html文件看效果]