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

Method optionsNormalize

src/particle.ts:139–151  ·  view source on GitHub ↗

* 标准化配置参数,参考 calcQuantity 方法描述。 * 如: * num: 0.5 => 表示 0.5 倍画布宽度 => 标准化为具体数值,如 100 * num: 100 => 表示具体数值 => 标准化结果还是 100

()

Source from the content-addressed store, hash-verified

137 * num: 100 => 表示具体数值 => 标准化结果还是 100
138 */
139 private optionsNormalize(): void {
140 const { canvasWidth, options } = this
141 const props = ['num', 'proximity', 'range'] as const
142
143 props.forEach((prop: ValueOf<typeof props>) => {
144 options[prop] = pInt(calcQuantity(options[prop], canvasWidth))
145 })
146
147 // 设置触发事件的元素
148 if (!isElement(options.eventElem) && options.eventElem !== document) {
149 options.eventElem = this.canvas
150 }
151 }
152
153 /**
154 * 根据配置参数生成对应形状的连线函数

Callers 1

initMethod · 0.95

Calls 3

pIntFunction · 0.90
calcQuantityFunction · 0.90
isElementFunction · 0.90

Tested by

no test coverage detected