【发布时间】:2015-05-13 23:22:15
【问题描述】:
我正在使用 processing.js 进行编码。我希望大小变量随着光标(鼠标)接近椭圆而变大,并随着光标远离椭圆而变小。大小应该(如果可能的话)限制在最小 50 到最大 200 之间。有什么方法可以做到这一点吗?
我在网上查看过,但似乎没有很多关于此的文档(至少对于我正在搜索的内容)。
这是我的代码:
void setup()
{
// Setting up the page
size(screen.width, screen.height);
smooth();
background(0, 0, 0);
// Declaring the variable size ONCE
size = 50;
}
void draw()
{
background(0, 0, 0);
// I want the size variable to be greater as the cursor approches the ellipse and to be smaller as the cursor moves away from the ellipse. The size is limited if possible between 50 and 200
// Here is the variable that needs to be changed
size = 50;
// Drawing the concerned ellipse
ellipse(width/2, height/2, size, size);
}
谢谢。
【问题讨论】:
标签: javascript html processing processing.js