@symbo.ls/scratch 0.7.19 → 0.7.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/defaultConfig/animation.js +3 -0
- package/src/defaultConfig/index.js +1 -0
- package/src/set.js +2 -1
- package/src/utils/sequence.js +17 -3
package/package.json
CHANGED
package/src/set.js
CHANGED
package/src/utils/sequence.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { toDashCase } from '@symbo.ls/utils'
|
|
4
|
-
import { UNIT } from '../defaultConfig'
|
|
4
|
+
import { SEQUENCE, SPACING, UNIT } from '../defaultConfig'
|
|
5
5
|
import { CONFIG } from '../factory'
|
|
6
6
|
import { isString } from './object'
|
|
7
7
|
|
|
@@ -82,6 +82,20 @@ export const generateSubSequence = (props, sequenceProps) => {
|
|
|
82
82
|
})
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
const switchSequenceOnNegative = (key, base, ratio) => {
|
|
86
|
+
const values = Object.values(SEQUENCE)
|
|
87
|
+
const index = values.indexOf(ratio)
|
|
88
|
+
const diffRatio = ratio / SPACING.ratio
|
|
89
|
+
const total = values[values.length - 1] - values[0]
|
|
90
|
+
const avg = total / 2
|
|
91
|
+
const diff = avg - ratio
|
|
92
|
+
const scale = total / ratio
|
|
93
|
+
const finalDiff = avg + avg / diffRatio
|
|
94
|
+
|
|
95
|
+
// if (key < 0) return base * Math.pow(avg, key)
|
|
96
|
+
return base * Math.pow(ratio, key)
|
|
97
|
+
}
|
|
98
|
+
|
|
85
99
|
export const generateSequence = (sequenceProps) => {
|
|
86
100
|
const { type, base, ratio, range, subSequence } = sequenceProps
|
|
87
101
|
const n = Math.abs(range[0]) + Math.abs(range[1])
|
|
@@ -90,8 +104,8 @@ export const generateSequence = (sequenceProps) => {
|
|
|
90
104
|
for (let i = 0; i <= n; i++) {
|
|
91
105
|
const key = range[1] - i
|
|
92
106
|
const letterKey = numToLetterMap[key]
|
|
93
|
-
const value = base
|
|
94
|
-
const scaling = ~~(value / base *
|
|
107
|
+
const value = switchSequenceOnNegative(key, base, ratio)
|
|
108
|
+
const scaling = ~~(value / base * 100) / 100
|
|
95
109
|
const variable = prefix + letterKey
|
|
96
110
|
|
|
97
111
|
const props = {
|