Compare commits
2 Commits
48c17799bc
...
2f058981a6
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f058981a6 | |||
| 03bbb76a2c |
@@ -98,6 +98,18 @@ describe('generateMosaic', () => {
|
||||
expect(expanded.outputLength).toBe(expanded.inputLength * 10)
|
||||
})
|
||||
|
||||
it('不生成可能跳出正常行框的 Unicode 组合符', () => {
|
||||
const outputs = Array.from({ length: 20 }, (_, seed) =>
|
||||
generateMosaic(SOURCE, [], {
|
||||
volume: 1000,
|
||||
disorder: 100,
|
||||
seed,
|
||||
}).output,
|
||||
).join('')
|
||||
|
||||
expect(outputs).not.toMatch(/\p{Mark}/u)
|
||||
})
|
||||
|
||||
it('相同种子可复现,不同种子会重新侵蚀', () => {
|
||||
const candidates = selectKeywords(SOURCE, 14, 1)
|
||||
const first = generateMosaic(SOURCE, candidates, {
|
||||
|
||||
+1
-6
@@ -237,8 +237,6 @@ const ENCODING_FRAGMENTS = ['Ã', 'Â', 'æ', 'å', '¤', '锟', '斤', '拷'] a
|
||||
|
||||
const COMPLEX_HAN = ['黻', '鬯', '夔', '爨', '龘', '靐', '罅', '黹'] as const
|
||||
|
||||
const COMBINING_MARKS = ['\u0336', '\u0337', '\u0338', '\u035F'] as const
|
||||
|
||||
const HAN_PATTERN = /\p{Script=Han}/u
|
||||
const WORD_PATTERN = /[\p{L}\p{N}]/u
|
||||
|
||||
@@ -395,15 +393,12 @@ function generateNoise(length: number, disorder: number, random: Random): string
|
||||
let output = ''
|
||||
let previous = ''
|
||||
const repeatChance = 0.02 + disorder * 0.0015
|
||||
const combiningChance = 0.02 + disorder * 0.0011
|
||||
|
||||
for (let index = 0; index < length; index += 1) {
|
||||
const shouldRepeat = previous !== '' && random() < repeatChance
|
||||
const glyph = shouldRepeat ? previous : chooseNoiseGlyph(random)
|
||||
const combining =
|
||||
random() < combiningChance ? choose(COMBINING_MARKS, random) : ''
|
||||
|
||||
output += `${glyph}${combining}`
|
||||
output += glyph
|
||||
previous = glyph
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user