* 生成 "getColor" 函数
()
| 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 | * 设置画布尺寸 |
nothing calls this directly
no test coverage detected