MCPcopy Index your code
hub / github.com/processing/p5.js / constructor

Method constructor

test/types/webgl-pixels.ts:63–88  ·  view source on GitHub ↗
(x, y, r, c)

Source from the content-addressed store, hash-verified

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)]

Callers

nothing calls this directly

Calls 7

colorFunction · 0.85
setInterpolationMethod · 0.80
randomFunction · 0.50
loadPixelsMethod · 0.45
getTextureMethod · 0.45
pushMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected