;butterfly.asm
;蝴蝶曲线的极坐标方程如下:
;x=sin(t)(e^cos(t)-2cos(4t)-sin^5(t/12))
;y=cos(t)(e^cos(t)-2cos(4t)-sin^5(t/12))
;不足之处,敬请指导。
;QQ:112426112
;Email:leguanyuan at 126 dot com
;Homepage:http://correy.webs.com
.386
.model flat,stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
includelib user32.lib
includelib kernel32.lib
include gdi32.inc
includelib gdi32.lib
.code
hInstance dd ?
hWinMain dd ?
stMsg MSG <>
szClassName db "correy",0
szCaptionMain db "made by correy",0
pwndclassex dd 48,3,offset liuchunli,0,0,0,0,0,6,0,offset szClassName,0
cxClient DD ?
cyClient DD ?
x DD ?
y DD ?
x_offset DD ?
y_offset DD ?
colour DD ?
temp DD ?
oldcw word ?
newcw word ?
scaleX real4 0.0
scaleY real4 0.0
theta real4 0.0
incr real4 0.01
four real4 4.0
rep12 real4 0.08333333
scale real4 75.0
change_base real4 2.30258
liuchunli proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL hdc:HDC, ps:PAINTSTRUCT
.IF uMsg==WM_SIZE;改变窗口尺寸有效果,改变change_base参数更有效果。
finit
mov eax,lParam
and eax,0ffffh
mov cxClient,eax
shr eax,2;1
mov x_offset,eax ;;;;;;;;;;;;
invoke GetSystemMetrics,SM_CXSCREEN
mov temp,eax
shr temp,7
fild cxClient
fidiv temp
fstp scaleX
mov ebx,lParam
shr ebx,16
mov cyClient,ebx
shr ebx,1
mov y_offset,ebx;;;;;;;;;;;;;
invoke GetSystemMetrics,SM_CYSCREEN
mov temp,eax
shr temp,7;6
fild cyClient
fidiv temp
fstp scaleY
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd, ADDR ps
mov hdc,eax
finit
mov si,15700
.WHILE si > 0
fld theta
fmul rep12
fsin
fld st
fmul st,st(1)
fmul st,st(1)
fmul st,st(1)
fmul
fld theta
fmul four
fcos
fld st
fadd
fsub
fld theta
fcos
fldl2t
fmulp st(1),st(0)
fld st(0)
fstcw oldcw
fwait
mov ax,oldcw
and ax,0f3ffh
or ax,0400h
mov newcw,ax
fldcw newcw
frndint
fldcw oldcw
fld st(0)
fxch st(2)
fsubrp st(1),st(0)
fld1
fchs
fxch st(1)
fscale
fstp st(1)
f2xm1
fld1
faddp st(1),st(0)
fmul st(0),st(0)
fscale
fstp st(1)
fdiv change_base
fadd
fld theta
fcos
fmul st,st(1)
fmul scaleX
fiadd x_offset
fistp x
fld theta
fsin
fmul
fmul scaleY
fiadd y_offset
fistp y
invoke SetPixel,hdc,x,y,colour
fld theta
fadd incr
fstp theta
inc si
add colour,999
.ENDW
invoke EndPaint,hWnd,ADDR ps
.ELSEIF uMsg==WM_DESTROY
invoke PostQuitMessage,0
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
liuchunli endp
start:invoke GetModuleHandle,0
mov hInstance,eax
mov pwndclassex+20,eax
invoke LoadIcon,hInstance,1;其实这四行也可以去掉。
mov pwndclassex+24,eax
invoke LoadCursor,0,32512
mov pwndclassex+28,eax
invoke RegisterClassEx,addr pwndclassex
invoke CreateWindowEx,200h,offset szClassName,offset szCaptionMain,00cf0000h,80000000h,80000000h,1028,768,0,0,hInstance,0;0cf0000h ca0000h
mov hWinMain,eax
invoke ShowWindow,hWinMain,1;不想显示这一两行也可以不要。
invoke UpdateWindow,hWinMain
again:invoke GetMessage,addr stMsg,0,0,0
cmp eax,0
je exit
invoke TranslateMessage,addr stMsg;这一行也可以去掉,特别是不处理字符信息。
invoke DispatchMessage,addr stMsg
jmp again
exit:invoke ExitProcess,0
end start
;made at 2010.03.30
没有评论:
发表评论