vfp如何用渐进色作图
记得windowsAPI里有专门的函数可以在矩形和三角形里作渐进色图,但是我一直没搞懂那几个API函数的参数的结构(vfp里怎么调用),如果有人知道的,可以说明一下,谢谢!最好给个示例~~~作为回馈,我把纯用foxpro代码的渐进色作图代码奉上,作为抛砖引玉!
程序代码:
PARAMETERS ndirection IF PARAMETERS()=0 ndirection=4 &&这个值1-5,会有不同效果 ENDIF CLEAR ncurrentcolor=_screen.ForeColor _screen.Box(100,100,500,500) *!* * 渐变颜色计算 *!* 设定起始颜色 ocolor_begin=NEWOBJECT("color","myclass") ncolor_begin=GETCOLOR() ocolor_begin.set(ncolor_begin) ocolor_end=NEWOBJECT("color","myclass") ncolor_end=GETCOLOR() ocolor_end.set(ncolor_end) nStepRed = (ocolor_end.r - ocolor_begin.r) / 400 nStepGreen = (ocolor_end.g - ocolor_begin.g) / 400 nStepBlue = (ocolor_end.b - ocolor_begin.b) / 400 * 绘制色彩渐变 FOR nX = 100 TO 500 nRed = ocolor_begin.r + (nX - 100) * nStepRed nGreen = ocolor_begin.g + (nX - 100) * nStepGreen nBlue = ocolor_begin.b + (nX - 100) * nStepBlue _screen.forecolor=RGB(nRed, nGreen, nBlue) DO CASE CASE ndirection=1 &&水平渐进 _screen.LINE (nx,100,nx,500) CASE ndirection=2 &&垂直渐进 _screen.LINE (100,nx,500,nx) CASE ndirection=3 &&往中间渐变 _screen.LINE (100,600-nx , nx, 500) _screen.LINE (600-nx,100,500,nx) CASE ndirection=4 &&左下到右上对角渐变 _screen.Line(IIF(nx<=300,100,(nx-300)*2+99),IIF(nx<=300,(300-nx)*2+99,100),; IIF(nx<=300,(nx-100)*2+101,500),IIF(nx<=300,500,500-(nx-300)*2+1)) _screen.Line(IIF(nx<=300,100,(nx-300)*2+100),IIF(nx<=300,(300-nx)*2+100,100),; IIF(nx<=300,(nx-100)*2+100,500),IIF(nx<=300,500,500-(nx-300)*2)) CASE ndirection=5 &&水波渐变 _screen.LINE (nx,100,nx,500) _screen.LINE (100,nx,500,nx) ENDCASE ENDFOR _screen.ForeColor=ncurrentcolor