mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 09:22:15 +00:00
75d0593198
- A text can be cased (capitals, lower case, small caps), placed at the top, middle or foot of its frame, outlined, given a hard shadow or a marker band, bent on an arc or round a circle, filled with a gallery photo or left hollow, and shrunk to fit its frame. Every effect prints as vector: copies and strokes for HTML type, textPath and a clip over an <image> for SVG. - Fitting is solved when the text is edited, in the Studio and in the edit engine, and stored; the chosen size is kept as the ceiling. - Text sizes reach 400 pt and tracking 1.5 em. - The Elements panel opens on a Text tab: the plain styles and 24 lockups (titles, badges and stamps, chapter marks, quotes, captions, places), each drawn with the book's own title and placed as one group. - The assistant sets every effect through style and add, places a lockup with add_lockup, reads the effects in describe_book_page and gets two new findings (curve_overflow, effect_heavy) beside photo-fill and band checks. - Book format revision 6.
47 lines
2.2 KiB
TypeScript
47 lines
2.2 KiB
TypeScript
import { bookTextCurvePath } from './book-text-curve';
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
/** The line a curved text runs along, in the millimetres of its frame. */
|
|
|
|
describe('the path of a curved text', () => {
|
|
it('BKCRV-001: runs a flat arc as a straight line across the frame, inset by half an em', () => {
|
|
const p = bookTextCurvePath({ type: 'arc', bend: 0, start: 0 }, 100, 40, 10);
|
|
expect(p.d).toBe('M 5 23.5 L 95 23.5');
|
|
expect(p.length).toBe(90);
|
|
});
|
|
|
|
it('BKCRV-002: arches clockwise over the top for a positive bend and dips anticlockwise for a negative one', () => {
|
|
const up = bookTextCurvePath({ type: 'arc', bend: 50, start: 0 }, 100, 60, 10);
|
|
const down = bookTextCurvePath({ type: 'arc', bend: -50, start: 0 }, 100, 60, 10);
|
|
expect(up.d).toMatch(/ 0 0 1 95 /);
|
|
expect(down.d).toMatch(/ 0 0 0 95 /);
|
|
// Longer than the chord, the same either way.
|
|
expect(up.length).toBeGreaterThan(90);
|
|
expect(up.length).toBeCloseTo(down.length, 6);
|
|
});
|
|
|
|
it('BKCRV-003: bends a half circle at 100, whose length is half the circumference of the chord', () => {
|
|
const p = bookTextCurvePath({ type: 'arc', bend: 100, start: 0 }, 120, 80, 10);
|
|
expect(p.length).toBeCloseTo((Math.PI * 110) / 2, 4);
|
|
});
|
|
|
|
it('BKCRV-004: keeps a bend past the bounds to a half circle', () => {
|
|
const half = bookTextCurvePath({ type: 'arc', bend: 100, start: 0 }, 120, 80, 10);
|
|
expect(bookTextCurvePath({ type: 'arc', bend: 300, start: 0 }, 120, 80, 10)).toEqual(half);
|
|
});
|
|
|
|
it('BKCRV-005: runs a circle round the inscribed circle, brought in by the letters, starting half a turn before its centre', () => {
|
|
const p = bookTextCurvePath({ type: 'circle', bend: 0, start: 0 }, 100, 100, 8);
|
|
const r = 50 - 8 * 0.75;
|
|
expect(p.length).toBeCloseTo(2 * Math.PI * r, 6);
|
|
// From the bottom of the circle, so the middle of the words lands at the top.
|
|
expect(p.d.startsWith(`M 50 ${50 + r}`)).toBe(true);
|
|
expect(p.d.match(/ A /g)).toHaveLength(2);
|
|
});
|
|
|
|
it('BKCRV-006: never draws a circle smaller than a millimetre, whatever the letters', () => {
|
|
expect(bookTextCurvePath({ type: 'circle', bend: 0, start: 90 }, 4, 4, 30).length).toBeCloseTo(2 * Math.PI, 6);
|
|
});
|
|
});
|