MCPcopy Create free account
hub / github.com/NianBroken/Firework_Simulator / createWordBurst

Function createWordBurst

js/script.js:1575–1591  ·  view source on GitHub ↗

* * @param {string} wordText 文字内容 * @param {Function} particleFactory 每生成一颗星/粒子调用一次。传递参数: * `point `:恒星/粒子的起始位置_相对于canvas。 * `color `:粒子颜色。 * @param {number} center_x 爆炸中心点x * @param {number} center_y 爆炸中心点y

(wordText, particleFactory, center_x, center_y)

Source from the content-addressed store, hash-verified

1573 * @param {number} center_y 爆炸中心点y
1574 */
1575function createWordBurst(wordText, particleFactory, center_x, center_y) {
1576 //将点阵坐标转换为canvas坐标
1577 var map = getWordDots(wordText);
1578 if (!map) return;
1579 var dcenterX = map.width / 2;
1580 var dcenterY = map.height / 2;
1581 var color = randomColor();
1582 var strobed = Math.random() < 0.5;
1583 var strobeColor = strobed ? randomColor() : color;
1584
1585 for (let i = 0; i < map.points.length; i++) {
1586 const point = map.points[i];
1587 let x = center_x + (point.x - dcenterX);
1588 let y = center_y + (point.y - dcenterY);
1589 particleFactory({ x, y }, color, strobed, strobeColor);
1590 }
1591}
1592
1593// Various star effects.
1594// These are designed to be attached to a star's `onDeath` event.

Callers 1

burstMethod · 0.85

Calls 2

getWordDotsFunction · 0.85
randomColorFunction · 0.85

Tested by

no test coverage detected