MCPcopy
hub / github.com/processing/p5.js / rescale

Method rescale

src/webgl/p5.DataArray.js:26–34  ·  view source on GitHub ↗

* Can be used to scale a DataArray back down to fit its contents.

()

Source from the content-addressed store, hash-verified

24 * Can be used to scale a DataArray back down to fit its contents.
25 */
26 rescale() {
27 if (this.length < this.data.length / 2) {
28 // Find the power of 2 size that fits the data
29 const targetLength = 1 << Math.ceil(Math.log2(this.length));
30 const newData = new Float32Array(targetLength);
31 newData.set(this.data.subarray(0, this.length), 0);
32 this.data = newData;
33 }
34 }
35
36 /**
37 * A full reset, which allocates a new underlying Float32Array at its initial

Callers

nothing calls this directly

Calls 1

setMethod · 0.45

Tested by

no test coverage detected