⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 movingoncurves.pde

📁 This is processing for java examples.
💻 PDE
字号:
/** * Moving On Curves.  *  * In this example, the circles moves along the curve y = x^4. * Click the mouse to have it move to a new position. */float beginX = 20.0;  // Initial x-coordinatefloat beginY = 10.0;  // Initial y-coordinatefloat endX = 570.0;   // Final x-coordinatefloat endY = 320.0;   // Final y-coordinatefloat distX;          // X-axis distance to movefloat distY;          // Y-axis distance to movefloat exponent = 4;   // Determines the curvefloat x = 0.0;        // Current x-coordinatefloat y = 0.0;        // Current y-coordinatefloat step = 0.01;    // Size of each step along the pathfloat pct = 0.0;      // Percentage traveled (0.0 to 1.0)void setup() {  size(640, 360);  noStroke();  smooth();  distX = endX - beginX;  distY = endY - beginY;}void draw() {  fill(0, 2);  rect(0, 0, width, height);  pct += step;  if (pct < 1.0) {    x = beginX + (pct * distX);    y = beginY + (pow(pct, exponent) * distY);  }  fill(255);  ellipse(x, y, 20, 20);}void mousePressed() {  pct = 0.0;  beginX = x;  beginY = y;  endX = mouseX;  endY = mouseY;  distX = endX - beginX;  distY = endY - beginY;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -