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

📄 metaball.pde

📁 This is processing for java examples.
💻 PDE
字号:
/** * Metaball Demo Effect * by luis2048.  *  * Organic-looking n-dimensional objects. The technique for rendering  * metaballs was invented by Jim Blinn in the early 1980s. Each metaball  * is defined as a function in n-dimensions.  */int numBlobs = 3;int[] blogPx = { 0, 90, 90 };int[] blogPy = { 0, 120, 45 };// Movement vector for each blobint[] blogDx = { 1, 1, 1 };int[] blogDy = { 1, 1, 1 };PGraphics pg;int[][] vy,vx; void setup() {  size(640, 360);  pg = createGraphics(160, 90, P2D);      vy = new int[numBlobs][pg.height];  vx = new int[numBlobs][pg.width];}void draw() {  for (int i=0; i<numBlobs; ++i) {    blogPx[i]+=blogDx[i];    blogPy[i]+=blogDy[i];    // bounce across screen    if (blogPx[i] < 0) {      blogDx[i] = 1;    }    if (blogPx[i] > pg.width) {      blogDx[i] = -1;    }    if (blogPy[i] < 0) {      blogDy[i] = 1;    }    if (blogPy[i] > pg.height) {      blogDy[i]=-1;    }    for (int x = 0; x < pg.width; x++) {      vx[i][x] = int(sq(blogPx[i]-x));    }    for (int y = 0; y < pg.height; y++) {      vy[i][y] = int(sq(blogPy[i]-y));     }  }  // Output into a buffered image for reuse  pg.beginDraw();  pg.loadPixels();  for (int y = 0; y < pg.height; y++) {    for (int x = 0; x < pg.width; x++) {      int m = 1;      for (int i = 0; i < numBlobs; i++) {        // Increase this number to make your blobs bigger        m += 60000/(vy[i][y] + vx[i][x]+1);      }      pg.pixels[x+y*pg.width] = color(0, m+x, (x+m+y)/2);    }  }  pg.updatePixels();  pg.endDraw();  // Display the results  image(pg, 0, 0, width, height); }

⌨️ 快捷键说明

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