用asp程序编写一个bmp图片格式的五星红旗

2012 年 9 月 7 日6650

今天看到一个用asp程序编写一个bmp图片格式的五星红旗,像手绘的一样,很好,把它转过来和大家分享


view sourceprint?001 <%


002 Option Explicit


003 Class FiveStarredFlag


004 PRivate Width


005 Private Height


006 Private Filler


007 Private SizeImage


008 Private FileSize


009 Private BitMap()


010


011 Private Sub Class_Initialize


012 Height = 200


013 Width = 300


014 Filler = (32 - Width Mod 32) Mod 32


015 SizeImage = (Width + Filler) * Height \ 8


016 FileSize = SizeImage + 14 + 40 + 8


017


018 ReDim BitMap(Width + Filler - 1, Height - 1)


019


020 Star Height * 0.25, Height * 0.75, Height * 0.15, 0


021 Star Width / 3, Height * 0.9, Height * 0.05, 120.9637565320735


022 Star Width * 0.4, Height * 0.8, Height * 0.05, 98.13010235415598


023 Star Width * 0.4, Height * 0.65, Height * 0.05, 74.0546040990771


024 Star Width / 3, Height * 0.55, Height * 0.05, 51.3401917459099


025 End Sub


026


027 Private Sub Class_Terminate


028 Response.ContentType = "image/bmp"


029 Response.BinaryWrite FileHeader & InfoHeader & Palette & ImageData


030 End Sub


031


032 Private Sub Star(x, y, r, a)


033 Dim pi, v, d, i, j, k, m2


034


035 pi = 3.1415926535897932


036 v = r * Sin(pi * 0.1) / Sin(pi * 0.7)


037


038 For j = -r To r


039 For i = -r To r


040 d = Sqr(i ^ 2 + j ^ 2)


041


042 If d < v Then


043 BitMap(x + i, y + j) = 1


044 ElseIf d < r Then


045 If i = 0 Then


046 If j > 0 Then k = 90 Else k = -90


047 Else


048 k = Atn(j / i) * 180 / pi


049 If i < 0 Then k = k + 180


050 End If


051


052 k = k - a - 18


053 While k < 0


054 k = k + 360


055 Wend


056 While k >= 360


057 k = k - 360


058 Wend

[1][2]下一页

【责编:cc】

0 0