processing鼠标移动
2014-09-07 22:44
501 查看
int rectX,rectY;
int rectSize=90;
color rectColor;
color baseColor;
boolean rectOver=false;
void setup(){
size(640,360);
rectColor=color(0);
baseColor=color(102);
rectX=width/2-rectSize/2;
rectY=height/2-rectSize/2;
}
void draw(){
update(mouseX,mouseY);
noStroke();
if(rectOver){
background(rectColor);
}else {
background(baseColor);
}
stroke(255);
fill(rectColor);
rect(rectX,rectY,rectSize,rectSize);
}
void update(int x,int y){
if(overRect(rectX,rectY,rectSize,rectSize)){
rectOver=true;
}else{
rectOver=false;
}
}
boolean overRect(int x,int y,int width,int height){
if(mouseX>=x && mouseX<=x+width &&
mouseY>=y && mouseY<y+height){
return true;
}else{
return false;
}
}
int rectSize=90;
color rectColor;
color baseColor;
boolean rectOver=false;
void setup(){
size(640,360);
rectColor=color(0);
baseColor=color(102);
rectX=width/2-rectSize/2;
rectY=height/2-rectSize/2;
}
void draw(){
update(mouseX,mouseY);
noStroke();
if(rectOver){
background(rectColor);
}else {
background(baseColor);
}
stroke(255);
fill(rectColor);
rect(rectX,rectY,rectSize,rectSize);
}
void update(int x,int y){
if(overRect(rectX,rectY,rectSize,rectSize)){
rectOver=true;
}else{
rectOver=false;
}
}
boolean overRect(int x,int y,int width,int height){
if(mouseX>=x && mouseX<=x+width &&
mouseY>=y && mouseY<y+height){
return true;
}else{
return false;
}
}
相关文章推荐
- processing鼠标移动物体停止旋转
- 跟随鼠标移动的div框
- 鼠标移动事件
- 鼠标移动实现样式改变
- JS实现窗口加载时模拟鼠标移动的方法
- 纯CSS实现鼠标移动切换图片示例
- 鼠标在按钮上移动、按下或者弹起时显示按钮功能提示文本
- CAD鼠标移动到对象时显示对象内容
- wpf 中限制鼠标移动范围 win
- 【ActionScript】使用鼠标移动元件与元件相交判断函数hitTest
- c#中通过设置钩子监视鼠标移动
- 抓虫记之七:模拟鼠标移动就报错
- 如何让一个div跟随鼠标移动
- 【html效果】使文字来回移动,当鼠标放上去停止
- Js+样式弹出层显示 鼠标移动JS
- 图片放大随鼠标移动
- 鼠标移动获取td的值
- ASP的GRIDVIEW中行颜色随鼠标移动变化(半原创)
- 游戏物体跟随鼠标移动
- VC/MFC 在ListCtl 控件中随鼠标移动提示单元格信息