mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
ce9c94a77b
- Fifty more shapes: arches, paper cut-outs (leaves, coral, weed, organic circles, a wonky star and sun), stamps, a postmark, a rosette, tags and ticket stubs, sunbursts, ribbons and bands, speech bubbles, drawn arrows, hearts, stars, photo frames and ornaments (scroll, laurel, fleuron, corner). The broad ones are photo frames too, and each tile is drawn at its shape's own proportions, which a new shape is also placed at. - A cut edge on rectangles, circles, arches and the other broad shapes, painted or not, and on a photo's cut: zigzag, scallop, a postage stamp's perforation, wavy, torn and deckle, with a depth in millimetres. Cut in millimetres, so holes stay round on a wide frame. - A line element: two to 32 points dragged on the canvas (a handle pulled from the middle adds one, a double-click removes it), straight or curved, solid, dashed or dotted, a wave or a zigzag, a hand-drawn wobble, a head on either end and an ornament in the middle. A shelf of lines and dividers places them. - The assistant reaches all of it: add and style take the line (its points on the spread in mm) and the edges, describe_book_page says them, and two new findings say when a line is too thin to print and when an edge is set on a shape that takes none. A photo's mask is checked against the shape set rather than listed again, which keeps the page edit's schema smaller. - BOOK_SCHEMA_REV goes to 6.
33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
import { bookLineLength, bookLinePoints } from './book-line';
|
|
import type { BookLineElement, BookPhotoElement, BookShapeElement } from './book.schema';
|
|
|
|
/**
|
|
* The words describe-spread.ts says for a line and for a cut edge: what a
|
|
* model needs to move a line's end or to know a frame is a postage stamp.
|
|
*/
|
|
|
|
const n = (v: number) => `${Math.round(v * 10) / 10}`;
|
|
|
|
/** A shape's or a photo's cut edge, or nothing when it keeps its drawn outline. */
|
|
export function bookEdgeWords(el: Pick<BookShapeElement | BookPhotoElement, 'edge' | 'edgeSize'>): string | null {
|
|
if (!el.edge || el.edge === 'straight') return null;
|
|
return `${el.edge} edge ${n(el.edgeSize ?? 3)} mm`;
|
|
}
|
|
|
|
/** A line: where its points are on the spread, how long it runs, and how it is drawn. */
|
|
export function bookLineWords(el: BookLineElement): string {
|
|
const pts = bookLinePoints(el);
|
|
const shown = pts.slice(0, 6).map(([x, y]) => `(${n(x)}, ${n(y)})`);
|
|
const more = pts.length > 6 ? ` and ${pts.length - 6} more` : '';
|
|
const parts = [
|
|
`line through ${shown.join(' ')}${more}, ${n(bookLineLength(pts))} mm long`,
|
|
`${el.stroke} ${n(el.strokeWidth)} mm ${el.dash}`,
|
|
];
|
|
if (el.curve === 'smooth' && pts.length > 2) parts.push('smooth curve');
|
|
if (el.squiggle !== 'none') parts.push(`drawn as a ${el.squiggle}`);
|
|
if (el.startCap !== 'none' || el.endCap !== 'none') parts.push(`ends ${el.startCap} / ${el.endCap}`);
|
|
if (el.wobble > 0) parts.push(`hand-drawn wobble ${n(el.wobble)}`);
|
|
if (el.ornament !== 'none') parts.push(`${el.ornament} in the middle`);
|
|
return parts.join(', ');
|
|
}
|