mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 03:26:07 +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.
63 lines
2.5 KiB
TypeScript
63 lines
2.5 KiB
TypeScript
import { BOOK_LINE_CAPS, BOOK_LINE_ORNAMENTS, MAX_LINE_POINTS } from './book-line.schema';
|
|
import { BOOK_EDGES, BOOK_EDGE_SIZE_MAX, BOOK_EDGE_SIZE_MIN } from './book-shapes-more';
|
|
|
|
import { z } from 'zod';
|
|
|
|
/**
|
|
* What the book tools take for the second shelf of shapes: the cut edge a
|
|
* shape or a photo can be given, and the drawn line. Joined into the props and
|
|
* the new-element union of book-element-ops.schema.ts, so `add` and `style`
|
|
* reach them as they reach every other kind.
|
|
*
|
|
* Each enum says in one line what its values draw, since the tool schema is
|
|
* all a model reads of them (book-op-enums.ts has the rest).
|
|
*/
|
|
|
|
const mmIn = z.number().finite().min(-10000).max(10000);
|
|
|
|
export const bookEdgeSchema = z
|
|
.enum(BOOK_EDGES)
|
|
.describe(
|
|
'A cut outline: zigzag, scallop, perforated (a stamp), wavy, torn, deckle (handmade paper); straight keeps it.',
|
|
);
|
|
|
|
/** The edge of a shape or a photo, each left as it is when not named. */
|
|
export const BOOK_EDGE_PROPS = {
|
|
edge: bookEdgeSchema.optional(),
|
|
edgeSize: z
|
|
.number()
|
|
.finite()
|
|
.min(BOOK_EDGE_SIZE_MIN)
|
|
.max(BOOK_EDGE_SIZE_MAX)
|
|
.describe('Depth of the cut in mm, 2 to 4 for a stamp.')
|
|
.optional(),
|
|
};
|
|
|
|
const capSchema = z.enum(BOOK_LINE_CAPS).describe('An end: arrow, open (a chevron), dot, bar or none.');
|
|
|
|
/** Points on the spread, in millimetres, from the first end to the last. */
|
|
export const bookLinePointsInSchema = z
|
|
.array(z.strictObject({ x: mmIn, y: mmIn }))
|
|
.min(2)
|
|
.max(MAX_LINE_POINTS)
|
|
.describe('Points on the spread in mm, start to end.');
|
|
|
|
/** How a line is drawn, each field left as it is when not named: the style op's, and the look of a new one. */
|
|
export const LINE_PROPS = {
|
|
opacity: z.number().min(0).max(1).optional(),
|
|
stroke: z
|
|
.string()
|
|
.regex(/^#[0-9a-fA-F]{6}$/, 'expected #rrggbb')
|
|
.optional(),
|
|
strokeWidth: z.number().finite().min(0.05).max(20).describe('Weight in mm.').optional(),
|
|
dash: z.enum(['solid', 'dashed', 'dotted']).optional(),
|
|
curve: z.enum(['straight', 'smooth']).describe('smooth is one curve through the points.').optional(),
|
|
squiggle: z.enum(['none', 'wave', 'zigzag']).describe('The body drawn as a wave or a zigzag.').optional(),
|
|
startCap: capSchema.optional(),
|
|
endCap: capSchema.optional(),
|
|
wobble: z.number().min(0).max(1).describe('Hand-drawn waver, 0 to 1.').optional(),
|
|
ornament: z.enum(BOOK_LINE_ORNAMENTS).describe('A motif in the middle, as on a divider.').optional(),
|
|
/** Moves the points; the frame is fitted around them. */
|
|
points: bookLinePointsInSchema.optional(),
|
|
};
|