Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4739973
  • 博文数量: 206
  • 博客积分: 5240
  • 博客等级: 大校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-12 21:40
文章分类

全部博文(206)

文章存档

2013年(13)

2012年(8)

2011年(33)

2010年(152)

我的朋友

分类:

2010-08-20 20:09:11

“范例->标准库->mouse->鼠标画线”
快手v0.54.2支持

//鼠标画渐开线
import mouse.draw;
import key;

import win.gdi;
SetPixel := ::Gdi32.api(
"SetPixel","int(int hdc,int x,int y,int crColor)")

//自定义此函数,每移动到一个点,画线函数会自动调用此函数
//mouse.draw库所有函数遵守约定:返回值为true表示继续,返回false表示停止画线
mouse.draw.move = function(x,y){ 
    hdc = ::GetDC(0)
    SetPixel(hdc ,x,y,255 )
    ::ReleaseDC(0,hdc);
    
    
if(key.getState("ESC"))
        
return  false//按ESC键退出;
    
    mouse.move(x,y,
true)
    
sleep(1) 
    
return true;
}

//画直线
mouse.draw.line(23,100,23,300); 

//画矩形
mouse.draw.rect(23,32,200,100);

// 画正弦曲线
mouse.draw.sin() 

// 画渐开线
mouse.draw.involute(); 

// 画方形仿渐开线,步进为5,中间忽略的正方形边长为50
mouse.draw.rect_inv(5,50); 


//这是真正的渐开线,第三个参数指定基圆的半径
mouse.draw.involute2(1024/2,768/2,0.1,10);
阅读(1378) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~