feat: 扩大体量参数范围
This commit is contained in:
+8
-1
@@ -86,7 +86,14 @@ app.innerHTML = `
|
|||||||
<output id="volume-value">100%</output>
|
<output id="volume-value">100%</output>
|
||||||
</span>
|
</span>
|
||||||
<span class="control__hint">结果相对原文的总长度</span>
|
<span class="control__hint">结果相对原文的总长度</span>
|
||||||
<input id="volume-control" type="range" min="85" max="115" value="100" />
|
<input
|
||||||
|
id="volume-control"
|
||||||
|
type="range"
|
||||||
|
min="10"
|
||||||
|
max="1000"
|
||||||
|
step="10"
|
||||||
|
value="100"
|
||||||
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label class="control" for="disorder-control">
|
<label class="control" for="disorder-control">
|
||||||
|
|||||||
@@ -74,6 +74,22 @@ describe('generateMosaic', () => {
|
|||||||
expect(ratio).toBeLessThanOrEqual(1.03)
|
expect(ratio).toBeLessThanOrEqual(1.03)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('支持将体量压缩到 10% 或膨胀到 1000%', () => {
|
||||||
|
const compressed = generateMosaic(SOURCE, [], {
|
||||||
|
volume: 10,
|
||||||
|
disorder: 0,
|
||||||
|
seed: 42,
|
||||||
|
})
|
||||||
|
const expanded = generateMosaic(SOURCE, [], {
|
||||||
|
volume: 1000,
|
||||||
|
disorder: 0,
|
||||||
|
seed: 42,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(compressed.outputLength).toBe(Math.round(compressed.inputLength * 0.1))
|
||||||
|
expect(expanded.outputLength).toBe(expanded.inputLength * 10)
|
||||||
|
})
|
||||||
|
|
||||||
it('相同种子可复现,不同种子会重新侵蚀', () => {
|
it('相同种子可复现,不同种子会重新侵蚀', () => {
|
||||||
const candidates = selectKeywords(SOURCE, 14, 1)
|
const candidates = selectKeywords(SOURCE, 14, 1)
|
||||||
const first = generateMosaic(SOURCE, candidates, {
|
const first = generateMosaic(SOURCE, candidates, {
|
||||||
|
|||||||
Reference in New Issue
Block a user