MCPcopy Create free account
hub / github.com/Barrior/JParticles / makeColorMethod

Function makeColorMethod

src/common/base.ts:129–142  ·  view source on GitHub ↗

* 生成 "getColor" 函数

()

Source from the content-addressed store, hash-verified

127 * 生成 "getColor" 函数
128 */
129 protected makeColorMethod(): () => string {
130 const { color } = this.options
131 const colorLength = Array.isArray(color) ? color.length : 0
132
133 if (isString(color)) {
134 return () => color as string
135 }
136
137 if (colorLength === 0) {
138 return randomColor
139 }
140
141 return () => (color as string[])[Math.floor(Math.random() * colorLength)]
142 }
143
144 /**
145 * 设置画布尺寸

Callers

nothing calls this directly

Calls 1

isStringFunction · 0.90

Tested by

no test coverage detected