* * @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)
| 1573 | * @param {number} center_y 爆炸中心点y |
| 1574 | */ |
| 1575 | function 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. |
no test coverage detected