|
@@ -573,4 +573,30 @@ util.resetRgbaOpacity = (polyColor, opacity) => {
|
|
|
|
|
|
util.randomColor = (opacity) => `rgba(${randomNum(0, 255)}, ${randomNum(0, 255)}, ${randomNum(0, 255)}, ${opacity ? opacity : randomNum(0.5, 1, 1)})`
|
|
|
|
|
|
+util.multiplication = (...args) => {
|
|
|
+ const handle = (a, b) => {
|
|
|
+ let len = 0
|
|
|
+ if (String(a).indexOf('.') !== -1) {
|
|
|
+ len += String(a).split('.')[1].length
|
|
|
+ }
|
|
|
+ if (String(b).indexOf('.') !== -1) {
|
|
|
+ len += String(b).split('.')[1].length
|
|
|
+ }
|
|
|
+ let level = '1'
|
|
|
+ for (let i = 0; i < len; i++) {
|
|
|
+ level += '0'
|
|
|
+ }
|
|
|
+ return (Number(a) * Number(b) * Number(level) / Number(level)).toFixed(len)
|
|
|
+ }
|
|
|
+ if (args.length === 0) {
|
|
|
+ return Number(args[0])
|
|
|
+ } else if (args.length > 1) {
|
|
|
+ let total = args[0]
|
|
|
+ for (let i = 1; i < args.length; i++) {
|
|
|
+ total = handle(total, args[i])
|
|
|
+ }
|
|
|
+ return total
|
|
|
+ }
|
|
|
+ return 0
|
|
|
+}
|
|
|
export default util
|