(x, y, r, c)
| 61 | tex: p5.Image |
| 62 | |
| 63 | constructor(x, y, r, c) { |
| 64 | this.nodes = [] |
| 65 | this.springs = [] |
| 66 | this.c = color(c) |
| 67 | this.tex = createImage(20, 20) |
| 68 | this.tex.loadPixels() |
| 69 | for (let i = 0; i < this.tex.pixels.length; i++) { |
| 70 | this.tex.pixels[i] = 255 |
| 71 | } |
| 72 | // @ts-ignore |
| 73 | renderer.getTexture(this.tex).setInterpolation(NEAREST, NEAREST) |
| 74 | |
| 75 | const a = PI * r * r |
| 76 | const numBlobs = ceil(a / BLOB_NODE_AREA) |
| 77 | |
| 78 | while (this.nodes.length < numBlobs) { |
| 79 | const rx = random(-r, r) |
| 80 | const ry = random(-r, r) |
| 81 | if (Math.hypot(rx, ry) > r) continue |
| 82 | |
| 83 | const vert = Matter.Bodies.circle(x + rx, y + ry, BLOB_NODE_R, { inertia: Infinity, friction: 0.015 }) |
| 84 | this.nodes.push(vert) |
| 85 | } |
| 86 | |
| 87 | Matter.World.add(engine.world, this.nodes) |
| 88 | } |
| 89 | |
| 90 | bin(x: number, y: number) { |
| 91 | return [round(x/80), round(y/80)] |
nothing calls this directly
no test coverage detected